From c9f2e9b7b24182e830f39c176170d5ca64d3d05e Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Mon, 3 Feb 2020 10:44:49 -0800 Subject: 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`. --- scripts/test/wasm2js.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'scripts/test/wasm2js.py') 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) -- cgit v1.2.3