diff options
author | Alon Zakai <azakai@google.com> | 2022-09-16 14:11:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-16 21:11:25 +0000 |
commit | 4e24fdfd74347dc40ba32efee6b154e6ec9827c0 (patch) | |
tree | 42413adab127314c4b0bd5035db4aae55359ff08 /test/wasm2js/br_table_to_loop.2asm.js.opt | |
parent | 241dee74dd8e58e166a4aa64c15e0f71ed1819bf (diff) | |
download | binaryen-4e24fdfd74347dc40ba32efee6b154e6ec9827c0.tar.gz binaryen-4e24fdfd74347dc40ba32efee6b154e6ec9827c0.tar.bz2 binaryen-4e24fdfd74347dc40ba32efee6b154e6ec9827c0.zip |
Effects: Clarify trap effect meaning, and consider infinite loops to trap due to timeout (#5039)
I think this simplifies the logic behind what we consider to trap. Before we had kind of
a hack in visitLoop that now has a more clear reasoning behind it: we consider as
trapping things that trap in all VMs all the time, or will eventually. So a single allocation
doesn't trap, but an unbounded amount can, and an infinite loop is considered to
trap as well (a timeout in a VM will be hit eventually, somehow).
This means we cannot optimize way a trivial infinite loop with no effects in it,
while (1) {}
But we can optimize it out in trapsNeverHappen mode. In any event, such a loop
is not a realistic situation; an infinite loop with some other effect in it, like a call to
an import, will not be optimized out, of course.
Also clarify some other things regarding traps and trapsNeverHappen following
recent discussions in https://github.com/emscripten-core/emscripten/issues/17732
Specifically, TNH will never be allowed to remove calls to imports.
Diffstat (limited to 'test/wasm2js/br_table_to_loop.2asm.js.opt')
-rw-r--r-- | test/wasm2js/br_table_to_loop.2asm.js.opt | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/test/wasm2js/br_table_to_loop.2asm.js.opt b/test/wasm2js/br_table_to_loop.2asm.js.opt index fb8e7f956..cac6dc28c 100644 --- a/test/wasm2js/br_table_to_loop.2asm.js.opt +++ b/test/wasm2js/br_table_to_loop.2asm.js.opt @@ -1,4 +1,6 @@ +function wasm2js_trap() { throw new Error('abort'); } + function asmFunc(importObject) { var env = importObject.env || importObject; var Math_imul = Math.imul; @@ -14,7 +16,7 @@ function asmFunc(importObject) { var nan = NaN; var infinity = Infinity; function $0() { - while (1) continue; + wasm2js_trap(); } function $1() { |