Skip to content

Commit 2afdd29

Browse files
evicyV8-internal LUCI CQ
authored andcommitted
[improve livetests] Truncate integral f32 to i64
As in https://crrev.com/i/7960389, this generator was just forgotten: The WasmTruncatef32Toi64Generator got Wasm floats as inputs. Any non-integral float cannot be converted and the Wasm function will trap. After this change we generate integral floats to be truncated. Change-Id: Ia0e66bb94669310e335ce7b69d8f093aab124c4a Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/7967836 Commit-Queue: Eva Herencsárová <[email protected]> Reviewed-by: Carl Smith <[email protected]>
1 parent 3061400 commit 2afdd29

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Sources/Fuzzilli/CodeGen/WasmCodeGenerators.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,14 @@ public let WasmCodeGenerators: [CodeGenerator] = [
400400
function.extendi32Toi64(input, isSigned: probability(0.5))
401401
},
402402

403-
CodeGenerator("WasmTruncatef32Toi64Generator", inContext: .wasmFunction, inputs: .required(.wasmf32)) { b, input in
403+
CodeGenerator("WasmTruncatef32Toi64Generator", inContext: .wasmFunction) { b in
404404
let function = b.currentWasmModule.currentWasmFunction
405405
if probability(0.5) {
406-
let res = function.wasmf32UnOp(input, unOpKind: .Abs)
407-
function.truncatef32Toi64(res, isSigned: false)
406+
let value = function.constf32(Float32(b.randomSize(upTo: Int64(Int32.max))))
407+
function.truncatef32Toi64(value, isSigned: false)
408408
} else {
409-
function.truncatef32Toi64(input, isSigned: true)
409+
let value = function.constf32(Float32(b.randomInt() % Int64(Int32.max)))
410+
function.truncatef32Toi64(value, isSigned: true)
410411
}
411412
},
412413

0 commit comments

Comments
 (0)