diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-06-17 10:53:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-17 14:53:54 +0000 |
commit | fb9d2a779c0267b9348bb87a9de6974658dda69d (patch) | |
tree | 267b8ec888592959abe8c9dc53bc84cc49119cd3 /test | |
parent | c36c6fa9e42f4e917864312780ba95fb996eda79 (diff) | |
download | binaryen-fb9d2a779c0267b9348bb87a9de6974658dda69d.tar.gz binaryen-fb9d2a779c0267b9348bb87a9de6974658dda69d.tar.bz2 binaryen-fb9d2a779c0267b9348bb87a9de6974658dda69d.zip |
[wasm2js] Refactor assertion parsing (#3938)
Assertions were previously parsed by replacing "invoke" with "call" and using
the normal s-expr parser. The parseCall method of the s-expr parser uses the
call target to look up the correct signature on the module, but the invoke
targets in assertions use export names rather than internal function names, so
the signature lookups were inserting new bogus entries with default values.
This issue didn't seem to cause any big problems before, but #3935 turns it into
a hard error because the default `HeapType` does not have an associated
signature.
Fix the problem (at least in the common case of trivial arguments and expected
results) by manually construction a `Call` expression rather than depending on
the s-expr parser to construct it.
Diffstat (limited to 'test')
-rw-r--r-- | test/wasm2js.asserts.js | 4 | ||||
-rw-r--r-- | test/wasm2js.traps.js | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/test/wasm2js.asserts.js b/test/wasm2js.asserts.js index 6ff356893..2770c07dd 100644 --- a/test/wasm2js.asserts.js +++ b/test/wasm2js.asserts.js @@ -74,9 +74,9 @@ function check1() { return 1 | 0; } -if (!check1()) throw 'assertion failed: ( assert_return ( call $empty ) )'; +if (!check1()) throw 'assertion failed: ( assert_return ( invoke empty ) )'; function check2() { return (retasmFunc0.add(1 | 0, 1 | 0) | 0 | 0) == (2 | 0) | 0; } -if (!check2()) throw 'assertion failed: ( assert_return ( call $add ( i32.const 1 ) ( i32.const 1 ) ) ( i32.const 2 ) )'; +if (!check2()) throw 'assertion failed: ( assert_return ( invoke add ( i32.const 1 ) ( i32.const 1 ) ) ( i32.const 2 ) )'; diff --git a/test/wasm2js.traps.js b/test/wasm2js.traps.js index f5bb8477f..d3b672dd1 100644 --- a/test/wasm2js.traps.js +++ b/test/wasm2js.traps.js @@ -74,15 +74,15 @@ function check1() { return 1 | 0; } -if (!check1()) throw 'assertion failed: ( assert_return ( call $empty ) )'; +if (!check1()) throw 'assertion failed: ( assert_return ( invoke empty ) )'; function check2() { return (retasmFunc0.add(1 | 0, 1 | 0) | 0 | 0) == (2 | 0) | 0; } -if (!check2()) throw 'assertion failed: ( assert_return ( call $add ( i32.const 1 ) ( i32.const 1 ) ) ( i32.const 2 ) )'; +if (!check2()) throw 'assertion failed: ( assert_return ( invoke add ( i32.const 1 ) ( i32.const 1 ) ) ( i32.const 2 ) )'; function check3() { function f() { - retasmFunc0.div_s(0 | 0, 0 | 0); + return retasmFunc0.div_s(0 | 0, 0 | 0) | 0 | 0; } try { @@ -93,10 +93,10 @@ function check3() { return 0; } -if (!check3()) throw 'assertion failed: ( assert_trap ( call $div_s ( i32.const 0 ) ( i32.const 0 ) ) integer divide by zero )'; +if (!check3()) throw 'assertion failed: ( assert_trap ( invoke div_s ( i32.const 0 ) ( i32.const 0 ) ) integer divide by zero )'; function check4() { function f() { - retasmFunc0.div_s(-2147483648 | 0, -1 | 0); + return retasmFunc0.div_s(-2147483648 | 0, -1 | 0) | 0 | 0; } try { @@ -107,4 +107,4 @@ function check4() { return 0; } -if (!check4()) throw 'assertion failed: ( assert_trap ( call $div_s ( i32.const 0x80000000 ) ( i32.const -1 ) ) integer overflow )'; +if (!check4()) throw 'assertion failed: ( assert_trap ( invoke div_s ( i32.const 0x80000000 ) ( i32.const -1 ) ) integer overflow )'; |