summaryrefslogtreecommitdiff
path: root/scripts/test/wasm2js.py
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 /scripts/test/wasm2js.py
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 'scripts/test/wasm2js.py')
-rwxr-xr-xscripts/test/wasm2js.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/scripts/test/wasm2js.py b/scripts/test/wasm2js.py
index 31df227cf..975262efe 100755
--- a/scripts/test/wasm2js.py
+++ b/scripts/test/wasm2js.py
@@ -50,7 +50,10 @@ def test_wasm2js_output():
for module, asserts in support.split_wast(t):
support.write_wast('split.wast', module, asserts)
- cmd = shared.WASM2JS + ['split.wast', '-all']
+ # wasm2js does not yet support EH, and enabling it can reduce
+ # optimization opportunities
+ cmd = shared.WASM2JS + ['split.wast', '-all',
+ '--disable-exception-handling']
if opt:
cmd += ['-O']
if 'emscripten' in t:
@@ -99,7 +102,8 @@ def test_asserts_output():
traps_expected_file = os.path.join(shared.options.binaryen_test, traps)
wasm = os.path.join(shared.get_test_dir('wasm2js'), wasm)
- cmd = shared.WASM2JS + [wasm, '--allow-asserts', '-all']
+ cmd = shared.WASM2JS + [wasm, '--allow-asserts', '-all',
+ '--disable-exception-handling']
out = support.run_command(cmd)
shared.fail_if_not_identical_to_file(out, asserts_expected_file)
@@ -146,7 +150,10 @@ def update_wasm2js_tests():
for module, asserts in support.split_wast(t):
support.write_wast('split.wast', module, asserts)
- cmd = shared.WASM2JS + ['split.wast', '-all']
+ # wasm2js does not yet support EH, and enable it can reduce
+ # optimization opportunities
+ cmd = shared.WASM2JS + ['split.wast', '-all',
+ '--disable-exception-handling']
if opt:
cmd += ['-O']
if 'emscripten' in wasm:
@@ -165,7 +172,7 @@ def update_wasm2js_tests():
asserts_expected_file = os.path.join(shared.options.binaryen_test, asserts)
traps_expected_file = os.path.join(shared.options.binaryen_test, traps)
- cmd = shared.WASM2JS + [os.path.join(shared.get_test_dir('wasm2js'), wasm), '--allow-asserts', '-all']
+ cmd = shared.WASM2JS + [os.path.join(shared.get_test_dir('wasm2js'), wasm), '--allow-asserts', '-all', '--disable-exception-handling']
out = support.run_command(cmd)
with open(asserts_expected_file, 'w') as o:
o.write(out)