diff options
author | Alon Zakai <azakai@google.com> | 2023-05-10 12:36:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 12:36:08 -0700 |
commit | c5c223943770412b2ebd7d9f23fce8c11cf5982e (patch) | |
tree | 4a4038c2a6caee19d0dc0f803535a57fa06a9d01 /test/wasm2js | |
parent | ee738ac1f838a090cac74ba8981e2104b6c02d44 (diff) | |
download | binaryen-c5c223943770412b2ebd7d9f23fce8c11cf5982e.tar.gz binaryen-c5c223943770412b2ebd7d9f23fce8c11cf5982e.tar.bz2 binaryen-c5c223943770412b2ebd7d9f23fce8c11cf5982e.zip |
Add a "mayNotReturn" effect (#5711)
This changes loops from having the effect "may trap (timeout)" to having
"may not return." The only noticeable difference is in TrapsNeverHappen mode,
which ignores the former but not the latter. So after this PR, in TNH mode we do
not optimize away an infinite loop that seems to have no other side effects. We
may also use this for other things in the future, like continuations/stack switching.
There are upsides and downsides to allowing the optimizer to remove infinite
loops (the C and C++ communities have had interesting discussions on that topic
over the years...) but it seems safer to not optimize them out for now, to let the
most code work properly. If a need comes up to optimize such code, we can look
at various options then (like a flag to ignore infinite loops).
See discussion in #5228
Diffstat (limited to 'test/wasm2js')
-rw-r--r-- | test/wasm2js/br_table_to_loop.2asm.js.opt | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/test/wasm2js/br_table_to_loop.2asm.js.opt b/test/wasm2js/br_table_to_loop.2asm.js.opt index 5c6fa5e7f..4c9f97311 100644 --- a/test/wasm2js/br_table_to_loop.2asm.js.opt +++ b/test/wasm2js/br_table_to_loop.2asm.js.opt @@ -1,6 +1,4 @@ -function wasm2js_trap() { throw new Error('abort'); } - function asmFunc(imports) { var Math_imul = Math.imul; var Math_fround = Math.fround; @@ -13,7 +11,7 @@ function asmFunc(imports) { var Math_trunc = Math.trunc; var Math_sqrt = Math.sqrt; function $0() { - wasm2js_trap(); + while (1) continue; } function $1() { |