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 /src/wasm2js.h | |
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 'src/wasm2js.h')
-rw-r--r-- | src/wasm2js.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/wasm2js.h b/src/wasm2js.h index 982184510..db394c36c 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -173,8 +173,11 @@ public: // and store would need to do a check. Given that, we can just ignore // implicit traps like those when optimizing. (When not optimizing, it's // nice to see codegen that matches wasm more precisely.) + // It is also important to prevent the optimizer from adding new things that + // require additional lowering, as we could hit a cycle. if (options.optimizeLevel > 0) { options.ignoreImplicitTraps = true; + options.targetJS = true; } } |