summaryrefslogtreecommitdiff
path: root/test/binaryen.js
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2020-02-03 10:44:49 -0800
committerGitHub <noreply@github.com>2020-02-03 10:44:49 -0800
commitc9f2e9b7b24182e830f39c176170d5ca64d3d05e (patch)
treeb9aeb5648997393c474d1e3ebf4513d640395c70 /test/binaryen.js
parentcd8d82910d229aa8357eb18882745397f6ed87eb (diff)
downloadbinaryen-c9f2e9b7b24182e830f39c176170d5ca64d3d05e.tar.gz
binaryen-c9f2e9b7b24182e830f39c176170d5ca64d3d05e.tar.bz2
binaryen-c9f2e9b7b24182e830f39c176170d5ca64d3d05e.zip
Add EH support for EffectAnalyzer (#2631)
This adds EH support to `EffectAnalyzer`. Before `throw` and `rethrow` conservatively set property. Now `EffectAnalyzer` has a new property `throws` to represent an expression that can throw, and expression that can throw sets `throws` correctly. When EH is enabled, any calls can throw too, so we cannot reorder them with another expression with any side effects, meaning all calls should be treated in the same way as branches when evaluating `invalidate`. This prevents many reorderings, so this patch sets `throws` for calls only when the exception handling features is enabled. This is also why I passed `--disable-exception-handling` to `wasm2js` tests. Most of code changes outside of `EffectAnalyzer` class was made in order to pass `FeatureSet` to it. `throws` isn't always set whenever an expression contains a throwable instruction. When an throwable instruction is within an inner try, it will be caught by the corresponding inner catch, so it does not set `throws`.
Diffstat (limited to 'test/binaryen.js')
-rw-r--r--test/binaryen.js/sideffects.js12
-rw-r--r--test/binaryen.js/sideffects.js.txt3
2 files changed, 14 insertions, 1 deletions
diff --git a/test/binaryen.js/sideffects.js b/test/binaryen.js/sideffects.js
index a486099dc..7db9ab329 100644
--- a/test/binaryen.js/sideffects.js
+++ b/test/binaryen.js/sideffects.js
@@ -9,6 +9,7 @@ console.log("SideEffects.ReadsMemory=" + binaryen.SideEffects.ReadsMemory);
console.log("SideEffects.WritesMemory=" + binaryen.SideEffects.WritesMemory);
console.log("SideEffects.ImplicitTrap=" + binaryen.SideEffects.ImplicitTrap);
console.log("SideEffects.IsAtomic=" + binaryen.SideEffects.IsAtomic);
+console.log("SideEffects.Throws=" + binaryen.SideEffects.Throws);
console.log("SideEffects.Any=" + binaryen.SideEffects.Any);
var module = new binaryen.Module();
@@ -92,3 +93,14 @@ assert(
==
binaryen.SideEffects.ImplicitTrap
);
+
+// If exception handling feature is enabled, calls can throw
+var module_all_features = new binaryen.Module();
+module_all_features.setFeatures(binaryen.Features.All);
+assert(
+ binaryen.getSideEffects(
+ module.call("test", [], binaryen.i32)
+ )
+ ==
+ binaryen.SideEffects.Calls | binaryen.SideEffects.Throws
+);
diff --git a/test/binaryen.js/sideffects.js.txt b/test/binaryen.js/sideffects.js.txt
index 54a1e14bc..4aca0ac46 100644
--- a/test/binaryen.js/sideffects.js.txt
+++ b/test/binaryen.js/sideffects.js.txt
@@ -9,4 +9,5 @@ SideEffects.ReadsMemory=64
SideEffects.WritesMemory=128
SideEffects.ImplicitTrap=256
SideEffects.IsAtomic=512
-SideEffects.Any=1023
+SideEffects.Throws=1024
+SideEffects.Any=2047