diff options
author | Heejin Ahn <aheejin@gmail.com> | 2021-01-15 18:48:00 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 18:48:00 +0900 |
commit | beccdf70258cd99ea25f10af13103e14dc243ffa (patch) | |
tree | 1081d7d350fbab7f901b917f2f082c8d351c3157 /test/passes/remove-unused-names_optimize-instructions_all-features.wast | |
parent | f18c18e01d03d6d293fe3d701408855bbcea58bd (diff) | |
download | binaryen-beccdf70258cd99ea25f10af13103e14dc243ffa.tar.gz binaryen-beccdf70258cd99ea25f10af13103e14dc243ffa.tar.bz2 binaryen-beccdf70258cd99ea25f10af13103e14dc243ffa.zip |
Basic EH instrucion support for the new spec (#3487)
This updates `try`-`catch`-`catch_all` and `rethrow` instructions to
match the new spec. `delegate` is not included. Now `Try` contains not a
single `catchBody` expression but a vector of catch
bodies and events.
This updates most existing routines, optimizations, and tests modulo the
interpreter and the CFG traversal. Because the interpreter has not been
updated yet, the EH spec test is temporarily disabled in check.py. Also,
because the CFG traversal for EH is not yet updated, several EH tests in
`rse_all-features.wast`, which uses CFG traversal, are temporarily
commented out.
Also added a few more tests in existing EH test functions in
test/passes. In the previous spec, `catch` was catching all exceptions
so it was assumed that anything `try` body throws is caught by its
`catch`, but now we can assume the same only if there is a `catch_all`.
Newly added tests test cases when there is a `catch_all` and cases there
are only `catch`es separately.
Diffstat (limited to 'test/passes/remove-unused-names_optimize-instructions_all-features.wast')
-rw-r--r-- | test/passes/remove-unused-names_optimize-instructions_all-features.wast | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/test/passes/remove-unused-names_optimize-instructions_all-features.wast b/test/passes/remove-unused-names_optimize-instructions_all-features.wast index 7c75c2bcf..e08c42169 100644 --- a/test/passes/remove-unused-names_optimize-instructions_all-features.wast +++ b/test/passes/remove-unused-names_optimize-instructions_all-features.wast @@ -7,6 +7,7 @@ (local $x1 i32) (local $x2 i32) (local $x3 i32) + (local $x4 i32) ;; try - try body does not throw, can (local.set $x0 @@ -14,8 +15,7 @@ (do (i32.const 1) ) - (catch - (drop (pop exnref)) + (catch_all (i32.const 3) ) ) @@ -29,15 +29,15 @@ (call $dummy) (i32.const 1) ) - (catch - (drop (pop exnref)) + (catch_all (i32.const 3) ) ) ) (drop (i32.and (local.get $x1) (i32.const 7))) - ;; nested try - inner try may throw but will be caught by inner catch, can + ;; nested try - inner try may throw and may not be caught by inner catch, + ;; can't (local.set $x2 (try (result i32) (do @@ -45,39 +45,57 @@ (do (throw $e (i32.const 0)) ) - (catch - (drop (pop exnref)) + (catch $e + (drop (pop i32)) ) ) (i32.const 1) ) - (catch - (drop (pop exnref)) + (catch $e + (drop (pop i32)) (i32.const 3) ) ) ) (drop (i32.and (local.get $x2) (i32.const 7))) - ;; nested try - inner catch may throw, can't + ;; nested try - inner try may throw but will be caught by inner catch_all, + ;; can (local.set $x3 (try (result i32) (do (try - (do) - (catch - (drop (pop exnref)) + (do (throw $e (i32.const 0)) ) + (catch_all) ) (i32.const 1) ) - (catch - (drop (pop exnref)) + (catch_all (i32.const 3) ) ) ) (drop (i32.and (local.get $x3) (i32.const 7))) + + ;; nested try - inner catch_all may throw, can't + (local.set $x4 + (try (result i32) + (do + (try + (do) + (catch_all + (throw $e (i32.const 0)) + ) + ) + (i32.const 1) + ) + (catch_all + (i32.const 3) + ) + ) + ) + (drop (i32.and (local.get $x4) (i32.const 7))) ) ) |