summaryrefslogtreecommitdiff
path: root/test/passes/remove-unused-names_optimize-instructions_all-features.wast
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2020-02-05 14:37:53 -0800
committerGitHub <noreply@github.com>2020-02-05 14:37:53 -0800
commit7be22c4d68270573ee010938aa8cd06be89e54d2 (patch)
treeef9607bef85aabb344234484818ffc29f2235919 /test/passes/remove-unused-names_optimize-instructions_all-features.wast
parent33f92aa06fe5de7bcf9f6b7fe2e74ba5e8e1e782 (diff)
downloadbinaryen-7be22c4d68270573ee010938aa8cd06be89e54d2.tar.gz
binaryen-7be22c4d68270573ee010938aa8cd06be89e54d2.tar.bz2
binaryen-7be22c4d68270573ee010938aa8cd06be89e54d2.zip
Add EH support for OptimizeInstructions (#2608)
- Adds support for `Try` in `optimizeBoolean` function - Adds support for `Try` in `getFallThrough` function - Adds approximate cost values for instructions in EH and reference types proposals.
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.wast78
1 files changed, 78 insertions, 0 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
new file mode 100644
index 000000000..bb8f90074
--- /dev/null
+++ b/test/passes/remove-unused-names_optimize-instructions_all-features.wast
@@ -0,0 +1,78 @@
+(module
+ (func $dummy)
+ (event $e (attr 0) (param i32))
+
+ (func $getFallthrough ;; unit tests for Properties::getFallthrough
+ (local $x0 i32)
+ (local $x1 i32)
+ (local $x2 i32)
+ (local $x3 i32)
+
+ ;; try - try body does not throw, can
+ (local.set $x0
+ (try (result i32)
+ (i32.const 1)
+ (catch
+ (drop (exnref.pop))
+ (i32.const 3)
+ )
+ )
+ )
+ (drop (i32.and (local.get $x0) (i32.const 7)))
+
+ ;; try - try body may throw, can't
+ (local.set $x1
+ (try (result i32)
+ (block (result i32)
+ (call $dummy)
+ (i32.const 1)
+ )
+ (catch
+ (drop (exnref.pop))
+ (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
+ (local.set $x2
+ (try (result i32)
+ (block (result i32)
+ (try
+ (throw $e (i32.const 0))
+ (catch
+ (drop (exnref.pop))
+ )
+ )
+ (i32.const 1)
+ )
+ (catch
+ (drop (exnref.pop))
+ (i32.const 3)
+ )
+ )
+ )
+ (drop (i32.and (local.get $x2) (i32.const 7)))
+
+ ;; nested try - inner catch may throw, can't
+ (local.set $x3
+ (try (result i32)
+ (block (result i32)
+ (try
+ (catch
+ (drop (exnref.pop))
+ (throw $e (i32.const 0))
+ )
+ )
+ (i32.const 1)
+ )
+ (catch
+ (drop (exnref.pop))
+ (i32.const 3)
+ )
+ )
+ )
+ (drop (i32.and (local.get $x3) (i32.const 7)))
+ )
+)