diff options
author | Heejin Ahn <aheejin@gmail.com> | 2021-05-20 19:54:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-20 19:54:46 -0700 |
commit | 24d71aa0146a6dacfce5d84a11c88195e66eee0a (patch) | |
tree | 76378ea766849e5be3ba85648b5a27a0af5bc33e /test | |
parent | dede877475625fa37e86400e3f4db363b76cd151 (diff) | |
download | binaryen-24d71aa0146a6dacfce5d84a11c88195e66eee0a.tar.gz binaryen-24d71aa0146a6dacfce5d84a11c88195e66eee0a.tar.bz2 binaryen-24d71aa0146a6dacfce5d84a11c88195e66eee0a.zip |
[EH] Change Walker::TaskFunc back to function pointer (#3899)
`Walker::TaskFunc` has changed from a function pointer to
`std::function` in #3494, mainly to make the EH support for `CFGWalker`
easier. We didn't notice much performance difference then, but it was
recently reported that it creased binaryen.js code size and performance.
This changes `Walker::TaskFunc` back to a function pointer and does a
little more work to manage catch index in `CFGWalker` side.
Hopefully fixes #3857.
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/rse_all-features.txt | 81 | ||||
-rw-r--r-- | test/passes/rse_all-features.wast | 58 |
2 files changed, 139 insertions, 0 deletions
diff --git a/test/passes/rse_all-features.txt b/test/passes/rse_all-features.txt index 6c9d52585..1594425cf 100644 --- a/test/passes/rse_all-features.txt +++ b/test/passes/rse_all-features.txt @@ -4,6 +4,7 @@ (type $i32_i32_=>_none (func (param i32 i32))) (type $i32_f64_=>_none (func (param i32 f64))) (event $e (attr 0) (param i32)) + (event $e2 (attr 0) (param)) (func $basic (param $x i32) (param $y f64) (local $a f32) (local $b i64) @@ -645,4 +646,84 @@ (i32.const 1) ) ) + (func $nested-catch1 + (local $x i32) + (try $try + (do + (throw $e + (i32.const 0) + ) + ) + (catch $e + (drop + (pop i32) + ) + ) + (catch $e2 + (try $try6 + (do + (throw $e + (i32.const 0) + ) + ) + (catch $e + (drop + (pop i32) + ) + ) + (catch $e2 + (local.set $x + (i32.const 1) + ) + ) + ) + ) + ) + (local.set $x + (i32.const 1) + ) + ) + (func $nested-catch2 + (local $x i32) + (try $try + (do + (throw $e + (i32.const 0) + ) + ) + (catch $e + (drop + (pop i32) + ) + (local.set $x + (i32.const 1) + ) + ) + (catch_all + (try $try7 + (do + (throw $e + (i32.const 0) + ) + ) + (catch $e + (drop + (pop i32) + ) + (local.set $x + (i32.const 1) + ) + ) + (catch_all + (local.set $x + (i32.const 1) + ) + ) + ) + ) + ) + (drop + (i32.const 1) + ) + ) ) diff --git a/test/passes/rse_all-features.wast b/test/passes/rse_all-features.wast index b3c684fbd..8192ecea1 100644 --- a/test/passes/rse_all-features.wast +++ b/test/passes/rse_all-features.wast @@ -288,6 +288,7 @@ ) (event $e (attr 0) (param i32)) + (event $e2 (attr 0)) (func $try1 (local $x i32) (try @@ -416,4 +417,61 @@ ;; so the local.set may not run. So this should NOT be dropped. (local.set $x (i32.const 1)) ) + (func $nested-catch1 + (local $x i32) + (try + (do + (throw $e (i32.const 0)) + ) + (catch $e + (drop (pop i32)) + ) + (catch $e2 + (try + (do + (throw $e (i32.const 0)) + ) + (catch $e + (drop (pop i32)) + ) + (catch $e2 + (local.set $x (i32.const 1)) + ) + ) + ) + ) + ;; This should NOT be dropped because the exception might not be caught by + ;; the inner catches, and the local.set above us may not have run, and + ;; other possible code paths do not even set the local. + (local.set $x (i32.const 1)) + ) + (func $nested-catch2 + (local $x i32) + (try + (do + (throw $e (i32.const 0)) + ) + (catch $e + (drop (pop i32)) + (local.set $x (i32.const 1)) + ) + (catch_all + (try + (do + (throw $e (i32.const 0)) + ) + (catch $e + (drop (pop i32)) + (local.set $x (i32.const 1)) + ) + (catch_all + (local.set $x (i32.const 1)) + ) + ) + ) + ) + ;; This should be dropped because the exception is guaranteed to be caught + ;; by one of the catches and it will set the local to 1. + (local.set $x (i32.const 1)) + ) ) |