diff options
author | Will Cohen <willcohen@users.noreply.github.com> | 2023-01-04 13:47:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-04 18:47:47 +0000 |
commit | a96fe1a8422140072db7ad7db421378b87898a0d (patch) | |
tree | 050682903ba63c12bf6cb38810642b708bc22bc4 /test/wasm2js/target_js.2asm.js | |
parent | 85e5d52e860adf1fa149b731ace79c9ea88b1bd2 (diff) | |
download | binaryen-a96fe1a8422140072db7ad7db421378b87898a0d.tar.gz binaryen-a96fe1a8422140072db7ad7db421378b87898a0d.tar.bz2 binaryen-a96fe1a8422140072db7ad7db421378b87898a0d.zip |
wasm2js: Avoid emitting non-JS code during opt (#5378)
As noted in #4806, trying to optimize past level 0 can result in
passes emitting non-JS code, which is then unable to be converted during
final output.
This commit creates a new targetJS option in PassOptions, which can
be checked inside each pass where non-JS code might be emitted.
This commit initially adds that logic to OptimizeInstructions, where
this issue was first noticed.
Diffstat (limited to 'test/wasm2js/target_js.2asm.js')
-rw-r--r-- | test/wasm2js/target_js.2asm.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/wasm2js/target_js.2asm.js b/test/wasm2js/target_js.2asm.js new file mode 100644 index 000000000..f9f4b4a67 --- /dev/null +++ b/test/wasm2js/target_js.2asm.js @@ -0,0 +1,27 @@ + +function asmFunc(imports) { + var Math_imul = Math.imul; + var Math_fround = Math.fround; + var Math_abs = Math.abs; + var Math_clz32 = Math.clz32; + var Math_min = Math.min; + var Math_max = Math.max; + var Math_floor = Math.floor; + var Math_ceil = Math.ceil; + var Math_trunc = Math.trunc; + var Math_sqrt = Math.sqrt; + var nan = NaN; + var infinity = Infinity; + function func(x) { + x = x | 0; + return (1 << x | 0) ^ -1 | 0 | 0; + } + + return { + "func": func + }; +} + +var retasmFunc = asmFunc({ +}); +export var func = retasmFunc.func; |