summaryrefslogtreecommitdiff
path: root/src/wasm2js.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-05-02 14:17:49 -0700
committerGitHub <noreply@github.com>2019-05-02 14:17:49 -0700
commit29e7e4483dc04ca8e882f12871c7eb395c82de00 (patch)
tree40b968dfef03b6cb4b877850bce1c2507e2bc8df /src/wasm2js.h
parentb394fcc887dbb2e02b5ff5b307004e4dc7ec2baf (diff)
downloadbinaryen-29e7e4483dc04ca8e882f12871c7eb395c82de00.tar.gz
binaryen-29e7e4483dc04ca8e882f12871c7eb395c82de00.tar.bz2
binaryen-29e7e4483dc04ca8e882f12871c7eb395c82de00.zip
wasm2js: ignore implicit traps (#2079)
We don't actually try to emit traps for loads, stores, invalid float to ints, etc., so when optimizing we may as well do so under the assumption those traps do not exist. This lets us emit nice code for a select whose operands are loads, for example - otherwise, the values seem to have side effects.
Diffstat (limited to 'src/wasm2js.h')
-rw-r--r--src/wasm2js.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/wasm2js.h b/src/wasm2js.h
index f15e8f9b7..731bf0a8c 100644
--- a/src/wasm2js.h
+++ b/src/wasm2js.h
@@ -124,7 +124,15 @@ public:
bool emscripten = false;
};
- Wasm2JSBuilder(Flags f, PassOptions options) : flags(f), options(options) {}
+ Wasm2JSBuilder(Flags f, PassOptions options_) : flags(f), options(options_) {
+ // We don't try to model wasm's trapping precisely - if we did, each load
+ // 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.)
+ if (options.optimizeLevel > 0) {
+ options.ignoreImplicitTraps = true;
+ }
+ }
Ref processWasm(Module* wasm, Name funcName = ASM_FUNC);
Ref processFunction(Module* wasm, Function* func, bool standalone = false);