summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/break-within-catch.wasm.fromBinary2
-rw-r--r--test/exception-handling.wast87
-rw-r--r--test/exception-handling.wast.from-wast122
-rw-r--r--test/exception-handling.wast.fromBinary126
-rw-r--r--test/exception-handling.wast.fromBinary.noDebugInfo126
-rw-r--r--test/lit/passes/optimize-instructions-exceptions.wast2
-rw-r--r--test/lit/passes/poppify.wast38
-rw-r--r--test/passes/code-pushing_all-features.txt6
-rw-r--r--test/passes/dce_all-features.txt8
-rw-r--r--test/passes/dwarf_with_exceptions.bin.txt12
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt40
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast18
-rw-r--r--test/passes/instrument-locals_all-features_disable-typed-function-references.txt2
-rw-r--r--test/passes/remove-unused-module-elements_all-features.txt2
-rw-r--r--test/passes/rse_all-features.txt22
-rw-r--r--test/passes/simplify-locals_all-features.txt10
-rw-r--r--test/passes/vacuum_all-features.txt6
-rw-r--r--test/reference-types.wast.from-wast8
-rw-r--r--test/reference-types.wast.fromBinary8
-rw-r--r--test/reference-types.wast.fromBinary.noDebugInfo8
-rw-r--r--test/spec/exception-handling.wast38
-rw-r--r--test/try-delegate.wasmbin0 -> 59 bytes
-rw-r--r--test/try-delegate.wasm.fromBinary40
23 files changed, 639 insertions, 92 deletions
diff --git a/test/break-within-catch.wasm.fromBinary b/test/break-within-catch.wasm.fromBinary
index d7e2dc57b..fd16d9fcc 100644
--- a/test/break-within-catch.wasm.fromBinary
+++ b/test/break-within-catch.wasm.fromBinary
@@ -4,7 +4,7 @@
(event $event$0 (attr 0) (param i32))
(func $0
(block $label$2
- (try
+ (try $label$3
(do
(nop)
)
diff --git a/test/exception-handling.wast b/test/exception-handling.wast
index b96c4d25f..399fef14c 100644
--- a/test/exception-handling.wast
+++ b/test/exception-handling.wast
@@ -102,6 +102,35 @@
)
)
+ ;; nested try-catch
+ (try
+ (do
+ (try
+ (do
+ (throw $e-i32 (i32.const 0))
+ )
+ (catch $e-i32
+ (drop (pop i32))
+ )
+ (catch_all)
+ )
+ )
+ (catch $e-i32
+ (drop (pop i32))
+ )
+ (catch_all
+ (try
+ (do
+ (throw $e-i32 (i32.const 0))
+ )
+ (catch $e-i32
+ (drop (pop i32))
+ )
+ (catch_all)
+ )
+ )
+ )
+
;; rethrow
(try
(do
@@ -113,4 +142,62 @@
)
)
)
+
+ (func $delegate-test
+ ;; Inner delegates target an outer catch
+ (try $l0
+ (do
+ (try
+ (do
+ (call $foo)
+ )
+ (delegate $l0) ;; by label
+ )
+ (try
+ (do
+ (call $foo)
+ )
+ (delegate 0) ;; by depth
+ )
+ )
+ (catch_all)
+ )
+
+ ;; When there are both a branch and a delegate that target the same try
+ ;; label. Because binaryen only allows blocks and loops to be targetted by
+ ;; branches, we wrap the try with a block and make branches that block
+ ;; instead, resulting in the br and delegate target different labels in the
+ ;; output.
+ (try $l0
+ (do
+ (try
+ (do
+ (br_if $l0 (i32.const 1))
+ )
+ (delegate $l0) ;; by label
+ )
+ (try
+ (do
+ (br_if $l0 (i32.const 1))
+ )
+ (delegate 0) ;; by depth
+ )
+ )
+ (catch_all)
+ )
+
+ ;; The inner delegate targets the outer delegate, which in turn targets the
+ ;; caller.
+ (try $l0
+ (do
+ (try
+ (do
+ (call $foo)
+ )
+ (delegate $l0)
+ )
+ )
+ (delegate 0)
+ )
+ )
)
diff --git a/test/exception-handling.wast.from-wast b/test/exception-handling.wast.from-wast
index 224df569b..5a0a1249d 100644
--- a/test/exception-handling.wast.from-wast
+++ b/test/exception-handling.wast.from-wast
@@ -14,7 +14,7 @@
)
(func $eh_test
(local $x (i32 i64))
- (try
+ (try $try
(do
(throw $e-i32
(i32.const 0)
@@ -26,7 +26,7 @@
)
)
)
- (try
+ (try $try0
(do
(throw $e-i32-i64
(i32.const 0)
@@ -44,20 +44,20 @@
)
)
)
- (block $l1
- (try
+ (block $l11
+ (try $l1
(do
- (br $l1)
+ (br $l11)
)
(catch $e-i32
(drop
(pop i32)
)
- (br $l1)
+ (br $l11)
)
)
)
- (try
+ (try $try2
(do
(nop)
)
@@ -67,7 +67,7 @@
)
)
)
- (try
+ (try $try3
(do
(call $foo)
(call $bar)
@@ -80,7 +80,7 @@
(call $bar)
)
)
- (try
+ (try $try4
(do
(throw $e-i32
(i32.const 0)
@@ -97,7 +97,7 @@
)
)
)
- (try
+ (try $try5
(do
(throw $e-i32
(i32.const 0)
@@ -107,7 +107,7 @@
(nop)
)
)
- (try
+ (try $try6
(do
(throw $e-i32
(i32.const 0)
@@ -128,7 +128,48 @@
(call $bar)
)
)
- (try
+ (try $try7
+ (do
+ (try $try8
+ (do
+ (throw $e-i32
+ (i32.const 0)
+ )
+ )
+ (catch $e-i32
+ (drop
+ (pop i32)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ (catch $e-i32
+ (drop
+ (pop i32)
+ )
+ )
+ (catch_all
+ (try $try9
+ (do
+ (throw $e-i32
+ (i32.const 0)
+ )
+ )
+ (catch $e-i32
+ (drop
+ (pop i32)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ )
+ (try $try10
(do
(throw $e-i32
(i32.const 0)
@@ -142,4 +183,61 @@
)
)
)
+ (func $delegate-test
+ (try $l0
+ (do
+ (try $try
+ (do
+ (call $foo)
+ )
+ (delegate $l0)
+ )
+ (try $try11
+ (do
+ (call $foo)
+ )
+ (delegate $l0)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ (block $l015
+ (try $l012
+ (do
+ (try $try13
+ (do
+ (br_if $l015
+ (i32.const 1)
+ )
+ )
+ (delegate $l012)
+ )
+ (try $try14
+ (do
+ (br_if $l015
+ (i32.const 1)
+ )
+ )
+ (delegate $l012)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ (try $l016
+ (do
+ (try $try17
+ (do
+ (call $foo)
+ )
+ (delegate $l016)
+ )
+ )
+ (delegate 0)
+ )
+ )
)
diff --git a/test/exception-handling.wast.fromBinary b/test/exception-handling.wast.fromBinary
index d305aaaa9..d6dd331b1 100644
--- a/test/exception-handling.wast.fromBinary
+++ b/test/exception-handling.wast.fromBinary
@@ -18,7 +18,7 @@
(local $2 (i32 i64))
(local $3 i32)
(local $4 i32)
- (try
+ (try $label$3
(do
(throw $event$0
(i32.const 0)
@@ -30,7 +30,7 @@
)
)
)
- (try
+ (try $label$6
(do
(throw $event$2
(i32.const 0)
@@ -69,20 +69,20 @@
)
)
)
- (block $label$5
- (try
+ (block $label$7
+ (try $label$10
(do
- (br $label$5)
+ (br $label$7)
)
(catch $event$0
(drop
(pop i32)
)
- (br $label$5)
+ (br $label$7)
)
)
)
- (try
+ (try $label$13
(do
(nop)
)
@@ -92,7 +92,7 @@
)
)
)
- (try
+ (try $label$16
(do
(call $foo)
(call $bar)
@@ -105,7 +105,7 @@
(call $bar)
)
)
- (try
+ (try $label$19
(do
(throw $event$0
(i32.const 0)
@@ -122,7 +122,7 @@
)
)
)
- (try
+ (try $label$22
(do
(throw $event$0
(i32.const 0)
@@ -132,7 +132,7 @@
(nop)
)
)
- (try
+ (try $label$25
(do
(throw $event$0
(i32.const 0)
@@ -153,7 +153,48 @@
(call $bar)
)
)
- (try
+ (try $label$34
+ (do
+ (try $label$29
+ (do
+ (throw $event$0
+ (i32.const 0)
+ )
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ )
+ (catch_all
+ (try $label$33
+ (do
+ (throw $event$0
+ (i32.const 0)
+ )
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ )
+ (try $label$37
(do
(throw $event$0
(i32.const 0)
@@ -167,5 +208,66 @@
)
)
)
+ (func $delegate-test
+ (try $label$9
+ (do
+ (block $label$1
+ (try $label$4
+ (do
+ (call $foo)
+ )
+ (delegate $label$9)
+ )
+ (try $label$7
+ (do
+ (call $foo)
+ )
+ (delegate $label$9)
+ )
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ (block $label$10
+ (try $label$19
+ (do
+ (block $label$11
+ (try $label$14
+ (do
+ (br_if $label$10
+ (i32.const 1)
+ )
+ )
+ (delegate $label$19)
+ )
+ (try $label$17
+ (do
+ (br_if $label$10
+ (i32.const 1)
+ )
+ )
+ (delegate $label$19)
+ )
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ (try $label$25
+ (do
+ (try $label$23
+ (do
+ (call $foo)
+ )
+ (delegate $label$25)
+ )
+ )
+ (delegate 0)
+ )
+ )
)
diff --git a/test/exception-handling.wast.fromBinary.noDebugInfo b/test/exception-handling.wast.fromBinary.noDebugInfo
index d6dc4268e..cf7372b6e 100644
--- a/test/exception-handling.wast.fromBinary.noDebugInfo
+++ b/test/exception-handling.wast.fromBinary.noDebugInfo
@@ -18,7 +18,7 @@
(local $2 (i32 i64))
(local $3 i32)
(local $4 i32)
- (try
+ (try $label$3
(do
(throw $event$0
(i32.const 0)
@@ -30,7 +30,7 @@
)
)
)
- (try
+ (try $label$6
(do
(throw $event$2
(i32.const 0)
@@ -69,20 +69,20 @@
)
)
)
- (block $label$5
- (try
+ (block $label$7
+ (try $label$10
(do
- (br $label$5)
+ (br $label$7)
)
(catch $event$0
(drop
(pop i32)
)
- (br $label$5)
+ (br $label$7)
)
)
)
- (try
+ (try $label$13
(do
(nop)
)
@@ -92,7 +92,7 @@
)
)
)
- (try
+ (try $label$16
(do
(call $0)
(call $1)
@@ -105,7 +105,7 @@
(call $1)
)
)
- (try
+ (try $label$19
(do
(throw $event$0
(i32.const 0)
@@ -122,7 +122,7 @@
)
)
)
- (try
+ (try $label$22
(do
(throw $event$0
(i32.const 0)
@@ -132,7 +132,7 @@
(nop)
)
)
- (try
+ (try $label$25
(do
(throw $event$0
(i32.const 0)
@@ -153,7 +153,48 @@
(call $1)
)
)
- (try
+ (try $label$34
+ (do
+ (try $label$29
+ (do
+ (throw $event$0
+ (i32.const 0)
+ )
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ )
+ (catch_all
+ (try $label$33
+ (do
+ (throw $event$0
+ (i32.const 0)
+ )
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ )
+ (try $label$37
(do
(throw $event$0
(i32.const 0)
@@ -167,5 +208,66 @@
)
)
)
+ (func $3
+ (try $label$9
+ (do
+ (block $label$1
+ (try $label$4
+ (do
+ (call $0)
+ )
+ (delegate $label$9)
+ )
+ (try $label$7
+ (do
+ (call $0)
+ )
+ (delegate $label$9)
+ )
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ (block $label$10
+ (try $label$19
+ (do
+ (block $label$11
+ (try $label$14
+ (do
+ (br_if $label$10
+ (i32.const 1)
+ )
+ )
+ (delegate $label$19)
+ )
+ (try $label$17
+ (do
+ (br_if $label$10
+ (i32.const 1)
+ )
+ )
+ (delegate $label$19)
+ )
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ (try $label$25
+ (do
+ (try $label$23
+ (do
+ (call $0)
+ )
+ (delegate $label$25)
+ )
+ )
+ (delegate 0)
+ )
+ )
)
diff --git a/test/lit/passes/optimize-instructions-exceptions.wast b/test/lit/passes/optimize-instructions-exceptions.wast
index e2b60e0f1..9d22224fb 100644
--- a/test/lit/passes/optimize-instructions-exceptions.wast
+++ b/test/lit/passes/optimize-instructions-exceptions.wast
@@ -5,7 +5,7 @@
(module
;; CHECK: (func $test
;; CHECK-NEXT: (if
- ;; CHECK-NEXT: (try (result i32)
+ ;; CHECK-NEXT: (try $try (result i32)
;; CHECK-NEXT: (do
;; CHECK-NEXT: (i32.const 123)
;; CHECK-NEXT: )
diff --git a/test/lit/passes/poppify.wast b/test/lit/passes/poppify.wast
index 1b9ba1fb3..bc88dd878 100644
--- a/test/lit/passes/poppify.wast
+++ b/test/lit/passes/poppify.wast
@@ -178,7 +178,7 @@
)
;; CHECK: (func $try-catch (result i32)
- ;; CHECK-NEXT: (try (result i32)
+ ;; CHECK-NEXT: (try $try (result i32)
;; CHECK-NEXT: (do
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (throw $e
@@ -208,6 +208,42 @@
)
)
+ ;; CHECK: (func $try-delegate (result i32)
+ ;; CHECK-NEXT: (try $l0 (result i32)
+ ;; CHECK-NEXT: (do
+ ;; CHECK-NEXT: (try $try
+ ;; CHECK-NEXT: (do
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (throw $e
+ ;; CHECK-NEXT: (pop i32)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (delegate $l0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (catch $e
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $try-delegate (result i32)
+ (try $l0 i32
+ (do
+ (try
+ (do
+ (throw $e
+ (i32.const 0)
+ )
+ )
+ (delegate $l0)
+ )
+ )
+ (catch $e
+ (pop i32)
+ )
+ )
+ )
+
;; CHECK: (func $tuple (result i32 i64)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (i64.const 1)
diff --git a/test/passes/code-pushing_all-features.txt b/test/passes/code-pushing_all-features.txt
index 4b3d93208..5226a7b3c 100644
--- a/test/passes/code-pushing_all-features.txt
+++ b/test/passes/code-pushing_all-features.txt
@@ -43,7 +43,7 @@
(func $can-push-past-try
(local $x i32)
(block $out
- (try
+ (try $try
(do
(throw $e
(i32.const 0)
@@ -78,7 +78,7 @@
(local.set $x
(i32.const 1)
)
- (try
+ (try $try
(do
(call $foo)
)
@@ -105,7 +105,7 @@
(local.set $x
(i32.const 1)
)
- (try
+ (try $try
(do
(throw $e
(i32.const 0)
diff --git a/test/passes/dce_all-features.txt b/test/passes/dce_all-features.txt
index 447077b6c..575d04065 100644
--- a/test/passes/dce_all-features.txt
+++ b/test/passes/dce_all-features.txt
@@ -547,7 +547,7 @@
(nop)
)
(func $try_unreachable
- (try
+ (try $try
(do
(unreachable)
)
@@ -558,7 +558,7 @@
(call $foo)
)
(func $catch_unreachable
- (try
+ (try $try
(do
(nop)
)
@@ -569,7 +569,7 @@
(call $foo)
)
(func $both_unreachable
- (try
+ (try $try
(do
(unreachable)
)
@@ -616,7 +616,7 @@
)
)
(func $unnecessary-concrete-try (result i32)
- (try
+ (try $try
(do
(unreachable)
)
diff --git a/test/passes/dwarf_with_exceptions.bin.txt b/test/passes/dwarf_with_exceptions.bin.txt
index 324e1d44d..b11fa6437 100644
--- a/test/passes/dwarf_with_exceptions.bin.txt
+++ b/test/passes/dwarf_with_exceptions.bin.txt
@@ -22,7 +22,7 @@
(global.get $global$0)
)
;; code offset: 0x10
- (try
+ (try $label$9
(do
;; code offset: 0x12
(call $foo)
@@ -47,7 +47,7 @@
)
)
;; code offset: 0x31
- (try
+ (try $label$8
(do
;; code offset: 0x33
(call $foo)
@@ -60,7 +60,7 @@
;; code offset: 0x41
(catch_all
;; code offset: 0x42
- (try
+ (try $label$7
(do
;; code offset: 0x44
(call $__cxa_end_catch)
@@ -443,7 +443,7 @@ file_names[ 1]:
(global.get $global$0)
)
;; code offset: 0xe
- (try
+ (try $label$9
(do
;; code offset: 0x10
(call $foo)
@@ -468,7 +468,7 @@ file_names[ 1]:
)
)
;; code offset: 0x1f
- (try
+ (try $label$8
(do
;; code offset: 0x21
(call $foo)
@@ -481,7 +481,7 @@ file_names[ 1]:
;; code offset: 0x27
(catch_all
;; code offset: 0x28
- (try
+ (try $label$7
(do
;; code offset: 0x2a
(call $__cxa_end_catch)
diff --git a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt
index ffb2da5be..f8e7778c5 100644
--- a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt
+++ b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt
@@ -3,17 +3,27 @@
(type $i32_=>_none (func (param i32)))
(event $e0 (attr 0) (param i32))
(func $eh
- try
+ try $try
i32.const 0
throw $e0
catch $e0
drop
- rethrow 0
catch_all
rethrow 0
end
- unreachable
+ try $l0
+ try $try0
+ i32.const 0
+ throw $e0
+ delegate $l0
+ unreachable
+ catch_all
+ nop
+ end
+ try $l01
+ nop
+ delegate 0
)
)
(module
@@ -21,7 +31,7 @@
(type $i32_=>_none (func (param i32)))
(event $e0 (attr 0) (param i32))
(func $eh (; has Stack IR ;)
- (try
+ (try $try
(do
(throw $e0
(i32.const 0)
@@ -31,11 +41,31 @@
(drop
(pop i32)
)
- (rethrow 0)
)
(catch_all
(rethrow 0)
)
)
+ (try $l0
+ (do
+ (try $try0
+ (do
+ (throw $e0
+ (i32.const 0)
+ )
+ )
+ (delegate $l0)
+ )
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ (try $l01
+ (do
+ (nop)
+ )
+ (delegate 0)
+ )
)
)
diff --git a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast
index 047d9c126..f82f7e19a 100644
--- a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast
+++ b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast
@@ -8,11 +8,27 @@
)
(catch $e0
(drop (pop i32))
- (rethrow 0)
)
(catch_all
(rethrow 0)
)
)
+
+ (try $l0
+ (do
+ (try
+ (do
+ (throw $e0 (i32.const 0))
+ )
+ (delegate $l0)
+ )
+ )
+ (catch_all)
+ )
+
+ (try $l0
+ (do)
+ (delegate 0) ;; delegate to caller
+ )
)
)
diff --git a/test/passes/instrument-locals_all-features_disable-typed-function-references.txt b/test/passes/instrument-locals_all-features_disable-typed-function-references.txt
index edd927851..481d7a72b 100644
--- a/test/passes/instrument-locals_all-features_disable-typed-function-references.txt
+++ b/test/passes/instrument-locals_all-features_disable-typed-function-references.txt
@@ -203,7 +203,7 @@
)
)
)
- (try
+ (try $try
(do
(nop)
)
diff --git a/test/passes/remove-unused-module-elements_all-features.txt b/test/passes/remove-unused-module-elements_all-features.txt
index 22751f9f5..fdd768e8b 100644
--- a/test/passes/remove-unused-module-elements_all-features.txt
+++ b/test/passes/remove-unused-module-elements_all-features.txt
@@ -299,7 +299,7 @@
(export "e-export" (event $e-export))
(start $start)
(func $start
- (try
+ (try $try
(do
(throw $e-throw
(i32.const 0)
diff --git a/test/passes/rse_all-features.txt b/test/passes/rse_all-features.txt
index 9a428266e..eaef14455 100644
--- a/test/passes/rse_all-features.txt
+++ b/test/passes/rse_all-features.txt
@@ -477,7 +477,7 @@
)
(func $try1
(local $x i32)
- (try
+ (try $try
(do
(nop)
)
@@ -493,7 +493,7 @@
)
(func $try2
(local $x i32)
- (try
+ (try $try
(do
(throw $e
(i32.const 0)
@@ -512,7 +512,7 @@
)
(func $try3
(local $x i32)
- (try
+ (try $try
(do
(throw $e
(i32.const 0)
@@ -533,7 +533,7 @@
)
(func $try4
(local $x i32)
- (try
+ (try $try
(do
(call $foo)
(local.set $x
@@ -550,7 +550,7 @@
)
(func $try5
(local $x i32)
- (try
+ (try $try
(do
(local.set $x
(i32.const 1)
@@ -567,9 +567,9 @@
)
(func $nested-try1
(local $x i32)
- (try
+ (try $try
(do
- (try
+ (try $try6
(do
(throw $e
(i32.const 0)
@@ -592,9 +592,9 @@
)
(func $nested-try2
(local $x i32)
- (try
+ (try $try
(do
- (try
+ (try $try7
(do
(throw $e
(i32.const 0)
@@ -618,9 +618,9 @@
)
(func $nested-try3
(local $x i32)
- (try
+ (try $try
(do
- (try
+ (try $try8
(do
(throw $e
(i32.const 0)
diff --git a/test/passes/simplify-locals_all-features.txt b/test/passes/simplify-locals_all-features.txt
index 34c13d442..21361af65 100644
--- a/test/passes/simplify-locals_all-features.txt
+++ b/test/passes/simplify-locals_all-features.txt
@@ -1905,7 +1905,7 @@
)
(func $pop-cannot-be-sinked
(local $0 i32)
- (try
+ (try $try
(do
(nop)
)
@@ -1922,7 +1922,7 @@
)
(func $pop-within-catch-can-be-sinked
(local $0 i32)
- (try
+ (try $try
(do
(nop)
)
@@ -1930,7 +1930,7 @@
(nop)
(call $foo
(i32.const 3)
- (try (result i32)
+ (try $try0 (result i32)
(do
(i32.const 0)
)
@@ -1950,7 +1950,7 @@
(local.set $0
(call $bar)
)
- (try
+ (try $try
(do
(drop
(local.get $0)
@@ -1966,7 +1966,7 @@
(func $non-call-can-be-sinked-into-try
(local $0 i32)
(nop)
- (try
+ (try $try
(do
(drop
(i32.const 3)
diff --git a/test/passes/vacuum_all-features.txt b/test/passes/vacuum_all-features.txt
index 82fb7e506..9acd26665 100644
--- a/test/passes/vacuum_all-features.txt
+++ b/test/passes/vacuum_all-features.txt
@@ -444,7 +444,7 @@
)
(func $inner-try-catch_all-test
(local $0 i32)
- (try
+ (try $try0
(do
(throw $e
(i32.const 0)
@@ -459,9 +459,9 @@
)
(func $inner-try-catch-test
(local $0 i32)
- (try
+ (try $try
(do
- (try
+ (try $try1
(do
(throw $e2
(i32.const 0)
diff --git a/test/reference-types.wast.from-wast b/test/reference-types.wast.from-wast
index 29aab9bea..9a89da4db 100644
--- a/test/reference-types.wast.from-wast
+++ b/test/reference-types.wast.from-wast
@@ -507,7 +507,7 @@
)
)
(drop
- (try (result externref)
+ (try $try (result externref)
(do
(local.get $local_externref)
)
@@ -520,7 +520,7 @@
)
)
(drop
- (try (result funcref)
+ (try $try35 (result funcref)
(do
(ref.func $foo)
)
@@ -533,7 +533,7 @@
)
)
(drop
- (try (result anyref)
+ (try $try36 (result anyref)
(do
(local.get $local_externref)
)
@@ -546,7 +546,7 @@
)
)
(drop
- (try (result anyref)
+ (try $try37 (result anyref)
(do
(ref.func $foo)
)
diff --git a/test/reference-types.wast.fromBinary b/test/reference-types.wast.fromBinary
index 5e51309ec..02be5171e 100644
--- a/test/reference-types.wast.fromBinary
+++ b/test/reference-types.wast.fromBinary
@@ -507,7 +507,7 @@
)
)
(drop
- (try (result externref)
+ (try $label$47 (result externref)
(do
(local.get $local_funcref)
)
@@ -520,7 +520,7 @@
)
)
(drop
- (try (result funcref)
+ (try $label$50 (result funcref)
(do
(ref.func $foo)
)
@@ -533,7 +533,7 @@
)
)
(drop
- (try (result anyref)
+ (try $label$53 (result anyref)
(do
(local.get $local_funcref)
)
@@ -546,7 +546,7 @@
)
)
(drop
- (try (result anyref)
+ (try $label$56 (result anyref)
(do
(ref.func $foo)
)
diff --git a/test/reference-types.wast.fromBinary.noDebugInfo b/test/reference-types.wast.fromBinary.noDebugInfo
index 23c2bb03b..9613c300b 100644
--- a/test/reference-types.wast.fromBinary.noDebugInfo
+++ b/test/reference-types.wast.fromBinary.noDebugInfo
@@ -507,7 +507,7 @@
)
)
(drop
- (try (result externref)
+ (try $label$47 (result externref)
(do
(local.get $1)
)
@@ -520,7 +520,7 @@
)
)
(drop
- (try (result funcref)
+ (try $label$50 (result funcref)
(do
(ref.func $3)
)
@@ -533,7 +533,7 @@
)
)
(drop
- (try (result anyref)
+ (try $label$53 (result anyref)
(do
(local.get $1)
)
@@ -546,7 +546,7 @@
)
)
(drop
- (try (result anyref)
+ (try $label$56 (result anyref)
(do
(ref.func $3)
)
diff --git a/test/spec/exception-handling.wast b/test/spec/exception-handling.wast
index ebca3a009..807ee0a52 100644
--- a/test/spec/exception-handling.wast
+++ b/test/spec/exception-handling.wast
@@ -241,7 +241,7 @@
)
)
)
- "try's type does not match try body's type"
+ "try's type does not match try body's type"
)
(assert_invalid
@@ -263,3 +263,39 @@
)
"event's param numbers must match"
)
+
+(assert_invalid
+ (module
+ (func $f0
+ (block $l0
+ (try
+ (do
+ (try
+ (do)
+ (delegate $l0) ;; target is a block
+ )
+ )
+ (catch_all)
+ )
+ )
+ )
+ )
+ "all delegate targets must be valid"
+)
+
+(assert_invalid
+ (module
+ (func $f0
+ (try $l0
+ (do)
+ (catch_all
+ (try
+ (do)
+ (delegate $l0) ;; the target catch is above the delegate
+ )
+ )
+ )
+ )
+ )
+ "all delegate targets must be valid"
+)
diff --git a/test/try-delegate.wasm b/test/try-delegate.wasm
new file mode 100644
index 000000000..dd39a4f3a
--- /dev/null
+++ b/test/try-delegate.wasm
Binary files differ
diff --git a/test/try-delegate.wasm.fromBinary b/test/try-delegate.wasm.fromBinary
new file mode 100644
index 000000000..fabbfebd0
--- /dev/null
+++ b/test/try-delegate.wasm.fromBinary
@@ -0,0 +1,40 @@
+(module
+ (type $none_=>_none (func))
+ (event $event$0 (attr 0) (param))
+ (func $0
+ (try $label$6
+ (do
+ (try $label$4
+ (do
+ )
+ (delegate $label$6)
+ )
+ )
+ (catch $event$0
+ )
+ )
+ )
+ (func $1
+ (try $label$9
+ (do
+ (try $label$7
+ (do
+ )
+ (catch $event$0
+ (drop
+ (i32.const 0)
+ )
+ (try $label$6
+ (do
+ )
+ (delegate $label$9)
+ )
+ )
+ )
+ )
+ (catch $event$0
+ )
+ )
+ )
+)
+