summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/binaryen.js/exception-handling.js10
-rw-r--r--test/binaryen.js/exception-handling.js.txt8
-rw-r--r--test/binaryen.js/expressions.js10
-rw-r--r--test/binaryen.js/expressions.js.txt2
-rw-r--r--test/exception-handling.wast119
-rw-r--r--test/exception-handling.wast.from-wast145
-rw-r--r--test/exception-handling.wast.fromBinary119
-rw-r--r--test/exception-handling.wast.fromBinary.noDebugInfo119
-rw-r--r--test/passes/code-pushing_all-features.txt4
-rw-r--r--test/passes/code-pushing_all-features.wast4
-rw-r--r--test/passes/dce_all-features.txt12
-rw-r--r--test/passes/dce_all-features.wast18
-rw-r--r--test/passes/dwarf_with_exceptions.bin.txt4
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt20
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast4
-rw-r--r--test/passes/rse_all-features.txt12
-rw-r--r--test/passes/rse_all-features.wast12
-rw-r--r--test/spec/exception-handling.wast64
18 files changed, 550 insertions, 136 deletions
diff --git a/test/binaryen.js/exception-handling.js b/test/binaryen.js/exception-handling.js
index 40dc9d489..a8d3dd3a4 100644
--- a/test/binaryen.js/exception-handling.js
+++ b/test/binaryen.js/exception-handling.js
@@ -3,7 +3,7 @@ function cleanInfo(info) {
for (var x in info) {
// Filter out address pointers and only print meaningful info
if (x == 'id' || x == 'type' || x == 'name' || x == 'event' ||
- x == 'depth' || x == 'hasCatchAll' || x == 'delegateTarget' ||
+ x == 'target' || x == 'hasCatchAll' || x == 'delegateTarget' ||
x == 'isDelegate') {
ret[x] = info[x];
}
@@ -21,19 +21,19 @@ module.setFeatures(binaryen.Features.ReferenceTypes |
var event_ = module.addEvent("e", 0, binaryen.i32, binaryen.none);
-// (try
+// (try $l0
// (do
// (throw $e (i32.const 0))
// )
// (catch
// (drop (pop i32))
-// (rethrow 0)
+// (rethrow $l0)
// )
// )
var throw_ = module.throw("e", [module.i32.const(0)]);
-var rethrow = module.rethrow(0);
+var rethrow = module.rethrow("l0");
var try_catch = module.try(
- '',
+ "l0",
throw_,
["e"],
[
diff --git a/test/binaryen.js/exception-handling.js.txt b/test/binaryen.js/exception-handling.js.txt
index 350d543e5..434546126 100644
--- a/test/binaryen.js/exception-handling.js.txt
+++ b/test/binaryen.js/exception-handling.js.txt
@@ -3,7 +3,7 @@
(type $i32_=>_none (func (param i32)))
(event $e (attr 0) (param i32))
(func $test
- (try
+ (try $l0
(do
(throw $e
(i32.const 0)
@@ -13,7 +13,7 @@
(drop
(pop i32)
)
- (rethrow 0)
+ (rethrow $l0)
)
)
(try $try_outer
@@ -35,6 +35,6 @@
)
getExpressionInfo(throw) = {"id":48,"type":1,"event":"e"}
-getExpressionInfo(rethrow) = {"id":49,"type":1,"depth":0}
-getExpressionInfo(try_catch) = {"id":47,"type":1,"name":"","hasCatchAll":0,"delegateTarget":"","isDelegate":0}
+getExpressionInfo(rethrow) = {"id":49,"type":1,"target":"l0"}
+getExpressionInfo(try_catch) = {"id":47,"type":1,"name":"l0","hasCatchAll":0,"delegateTarget":"","isDelegate":0}
getExpressionInfo(try_delegate) = {"id":47,"type":0,"name":"try_outer","hasCatchAll":1,"delegateTarget":"","isDelegate":0}
diff --git a/test/binaryen.js/expressions.js b/test/binaryen.js/expressions.js
index 688321675..1ffd45362 100644
--- a/test/binaryen.js/expressions.js
+++ b/test/binaryen.js/expressions.js
@@ -1585,14 +1585,14 @@ console.log("# Rethrow");
(function testRethrow() {
const module = new binaryen.Module();
- const theRethrow = binaryen.Rethrow(module.rethrow(0));
+ const theRethrow = binaryen.Rethrow(module.rethrow("l0"));
assert(theRethrow instanceof binaryen.Rethrow);
assert(theRethrow instanceof binaryen.Expression);
- assert(theRethrow.depth === 0);
+ assert(theRethrow.target === "l0");
assert(theRethrow.type === binaryen.unreachable);
- theRethrow.depth = 1
- assert(theRethrow.depth === 1);
+ theRethrow.target = "l1";
+ assert(theRethrow.target === "l1");
theRethrow.type = binaryen.f64;
theRethrow.finalize();
assert(theRethrow.type === binaryen.unreachable);
@@ -1601,7 +1601,7 @@ console.log("# Rethrow");
assert(
theRethrow.toText()
==
- "(rethrow 1)\n"
+ "(rethrow $l1)\n"
);
module.dispose();
diff --git a/test/binaryen.js/expressions.js.txt b/test/binaryen.js/expressions.js.txt
index 8467c55c0..1efbd9e13 100644
--- a/test/binaryen.js/expressions.js.txt
+++ b/test/binaryen.js/expressions.js.txt
@@ -297,7 +297,7 @@
)
# Rethrow
-(rethrow 1)
+(rethrow $l1)
# TupleMake
(tuple.make
diff --git a/test/exception-handling.wast b/test/exception-handling.wast
index 399fef14c..45cb21910 100644
--- a/test/exception-handling.wast
+++ b/test/exception-handling.wast
@@ -130,17 +130,6 @@
)
)
)
-
- ;; rethrow
- (try
- (do
- (throw $e-i32 (i32.const 0))
- )
- (catch $e-i32
- (drop (pop i32))
- (rethrow 0)
- )
- )
)
(func $delegate-test
@@ -200,4 +189,112 @@
(delegate 0)
)
)
+
+ (func $rethrow-test
+ ;; Simple try-catch-rethrow
+ (try $l0
+ (do
+ (call $foo)
+ )
+ (catch $e-i32
+ (drop (pop i32))
+ (rethrow $l0) ;; by label
+ )
+ (catch_all
+ (rethrow 0) ;; by depth
+ )
+ )
+
+ ;; When there are both a branch and a rethrow 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 rethrow target different labels in the
+ ;; output.
+ (try $l0
+ (do
+ (call $foo)
+ )
+ (catch $e-i32
+ (drop (pop i32))
+ (rethrow $l0)
+ )
+ (catch_all
+ (br $l0)
+ )
+ )
+
+ ;; One more level deep
+ (try $l0
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try
+ (do
+ (call $foo)
+ )
+ (catch $e-i32
+ (drop (pop i32))
+ (rethrow $l0) ;; by label
+ )
+ (catch_all
+ (rethrow 1) ;; by depth
+ )
+ )
+ )
+ )
+
+ ;; Interleaving block
+ (try $l0
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try
+ (do
+ (call $foo)
+ )
+ (catch $e-i32
+ (drop (pop i32))
+ (block $b0
+ (rethrow $l0) ;; by label
+ )
+ )
+ (catch_all
+ (block $b1
+ (rethrow 2) ;; by depth
+ )
+ )
+ )
+ )
+ )
+
+ ;; Within nested try, but rather in 'try' part and not 'catch'
+ (try $l0
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try
+ (do
+ (rethrow $l0) ;; by label
+ )
+ (catch_all)
+ )
+ )
+ )
+ (try $l0
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try
+ (do
+ (rethrow 1) ;; by depth
+ )
+ (catch_all)
+ )
+ )
+ )
+ )
)
diff --git a/test/exception-handling.wast.from-wast b/test/exception-handling.wast.from-wast
index 5a0a1249d..c397edcd8 100644
--- a/test/exception-handling.wast.from-wast
+++ b/test/exception-handling.wast.from-wast
@@ -169,19 +169,6 @@
)
)
)
- (try $try10
- (do
- (throw $e-i32
- (i32.const 0)
- )
- )
- (catch $e-i32
- (drop
- (pop i32)
- )
- (rethrow 0)
- )
- )
)
(func $delegate-test
(try $l0
@@ -192,7 +179,7 @@
)
(delegate $l0)
)
- (try $try11
+ (try $try10
(do
(call $foo)
)
@@ -203,24 +190,24 @@
(nop)
)
)
- (block $l015
- (try $l012
+ (block $l014
+ (try $l011
(do
- (try $try13
+ (try $try12
(do
- (br_if $l015
+ (br_if $l014
(i32.const 1)
)
)
- (delegate $l012)
+ (delegate $l011)
)
- (try $try14
+ (try $try13
(do
- (br_if $l015
+ (br_if $l014
(i32.const 1)
)
)
- (delegate $l012)
+ (delegate $l011)
)
)
(catch_all
@@ -228,16 +215,124 @@
)
)
)
- (try $l016
+ (try $l015
(do
- (try $try17
+ (try $try16
(do
(call $foo)
)
- (delegate $l016)
+ (delegate $l015)
)
)
(delegate 0)
)
)
+ (func $rethrow-test
+ (try $l0
+ (do
+ (call $foo)
+ )
+ (catch $e-i32
+ (drop
+ (pop i32)
+ )
+ (rethrow $l0)
+ )
+ (catch_all
+ (rethrow $l0)
+ )
+ )
+ (block $l018
+ (try $l017
+ (do
+ (call $foo)
+ )
+ (catch $e-i32
+ (drop
+ (pop i32)
+ )
+ (rethrow $l017)
+ )
+ (catch_all
+ (br $l018)
+ )
+ )
+ )
+ (try $l019
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try $try
+ (do
+ (call $foo)
+ )
+ (catch $e-i32
+ (drop
+ (pop i32)
+ )
+ (rethrow $l019)
+ )
+ (catch_all
+ (rethrow $l019)
+ )
+ )
+ )
+ )
+ (try $l020
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try $try21
+ (do
+ (call $foo)
+ )
+ (catch $e-i32
+ (drop
+ (pop i32)
+ )
+ (block $b0
+ (rethrow $l020)
+ )
+ )
+ (catch_all
+ (block $b1
+ (rethrow $l020)
+ )
+ )
+ )
+ )
+ )
+ (try $l022
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try $try23
+ (do
+ (rethrow $l022)
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ )
+ (try $l024
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try $try25
+ (do
+ (rethrow $l024)
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ )
+ )
)
diff --git a/test/exception-handling.wast.fromBinary b/test/exception-handling.wast.fromBinary
index d6dd331b1..89d0bb7fb 100644
--- a/test/exception-handling.wast.fromBinary
+++ b/test/exception-handling.wast.fromBinary
@@ -194,19 +194,6 @@
)
)
)
- (try $label$37
- (do
- (throw $event$0
- (i32.const 0)
- )
- )
- (catch $event$0
- (drop
- (pop i32)
- )
- (rethrow 0)
- )
- )
)
(func $delegate-test
(try $label$9
@@ -269,5 +256,111 @@
(delegate 0)
)
)
+ (func $rethrow-test
+ (try $label$3
+ (do
+ (call $foo)
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ (rethrow $label$3)
+ )
+ (catch_all
+ (rethrow $label$3)
+ )
+ )
+ (block $label$4
+ (try $label$7
+ (do
+ (call $foo)
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ (rethrow $label$7)
+ )
+ (catch_all
+ (br $label$4)
+ )
+ )
+ )
+ (try $label$13
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try $label$12
+ (do
+ (call $foo)
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ (rethrow $label$13)
+ )
+ (catch_all
+ (rethrow $label$13)
+ )
+ )
+ )
+ )
+ (try $label$20
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try $label$19
+ (do
+ (call $foo)
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ (block $label$18
+ (rethrow $label$20)
+ )
+ )
+ (catch_all
+ (rethrow $label$20)
+ )
+ )
+ )
+ )
+ (try $label$26
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try $label$25
+ (do
+ (rethrow $label$26)
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ )
+ (try $label$32
+ (do
+ (call $foo)
+ )
+ (catch_all
+ (try $label$31
+ (do
+ (rethrow $label$32)
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ )
+ )
)
diff --git a/test/exception-handling.wast.fromBinary.noDebugInfo b/test/exception-handling.wast.fromBinary.noDebugInfo
index cf7372b6e..47577065c 100644
--- a/test/exception-handling.wast.fromBinary.noDebugInfo
+++ b/test/exception-handling.wast.fromBinary.noDebugInfo
@@ -194,19 +194,6 @@
)
)
)
- (try $label$37
- (do
- (throw $event$0
- (i32.const 0)
- )
- )
- (catch $event$0
- (drop
- (pop i32)
- )
- (rethrow 0)
- )
- )
)
(func $3
(try $label$9
@@ -269,5 +256,111 @@
(delegate 0)
)
)
+ (func $4
+ (try $label$3
+ (do
+ (call $0)
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ (rethrow $label$3)
+ )
+ (catch_all
+ (rethrow $label$3)
+ )
+ )
+ (block $label$4
+ (try $label$7
+ (do
+ (call $0)
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ (rethrow $label$7)
+ )
+ (catch_all
+ (br $label$4)
+ )
+ )
+ )
+ (try $label$13
+ (do
+ (call $0)
+ )
+ (catch_all
+ (try $label$12
+ (do
+ (call $0)
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ (rethrow $label$13)
+ )
+ (catch_all
+ (rethrow $label$13)
+ )
+ )
+ )
+ )
+ (try $label$20
+ (do
+ (call $0)
+ )
+ (catch_all
+ (try $label$19
+ (do
+ (call $0)
+ )
+ (catch $event$0
+ (drop
+ (pop i32)
+ )
+ (block $label$18
+ (rethrow $label$20)
+ )
+ )
+ (catch_all
+ (rethrow $label$20)
+ )
+ )
+ )
+ )
+ (try $label$26
+ (do
+ (call $0)
+ )
+ (catch_all
+ (try $label$25
+ (do
+ (rethrow $label$26)
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ )
+ (try $label$32
+ (do
+ (call $0)
+ )
+ (catch_all
+ (try $label$31
+ (do
+ (rethrow $label$32)
+ )
+ (catch_all
+ (nop)
+ )
+ )
+ )
+ )
+ )
)
diff --git a/test/passes/code-pushing_all-features.txt b/test/passes/code-pushing_all-features.txt
index 5226a7b3c..19931399d 100644
--- a/test/passes/code-pushing_all-features.txt
+++ b/test/passes/code-pushing_all-features.txt
@@ -105,14 +105,14 @@
(local.set $x
(i32.const 1)
)
- (try $try
+ (try $l0
(do
(throw $e
(i32.const 0)
)
)
(catch_all
- (rethrow 0)
+ (rethrow $l0)
)
)
(drop
diff --git a/test/passes/code-pushing_all-features.wast b/test/passes/code-pushing_all-features.wast
index 0c17c0bab..b7f12bb0a 100644
--- a/test/passes/code-pushing_all-features.wast
+++ b/test/passes/code-pushing_all-features.wast
@@ -72,12 +72,12 @@
;; This local.set cannot be pushed down, because there is 'rethrow' within
;; the inner catch_all
(local.set $x (i32.const 1))
- (try
+ (try $l0
(do
(throw $e (i32.const 0))
)
(catch_all
- (rethrow 0)
+ (rethrow $l0)
)
)
(drop (i32.const 1))
diff --git a/test/passes/dce_all-features.txt b/test/passes/dce_all-features.txt
index 575d04065..a64f033f6 100644
--- a/test/passes/dce_all-features.txt
+++ b/test/passes/dce_all-features.txt
@@ -587,9 +587,15 @@
)
)
(func $rethrow
- (block $label$0
- (block $label$1
- (rethrow 0)
+ (try $l0
+ (do
+ (nop)
+ )
+ (catch $e
+ (drop
+ (i32.const 0)
+ )
+ (rethrow $l0)
)
)
)
diff --git a/test/passes/dce_all-features.wast b/test/passes/dce_all-features.wast
index fac6d7623..104093d08 100644
--- a/test/passes/dce_all-features.wast
+++ b/test/passes/dce_all-features.wast
@@ -774,6 +774,7 @@
)
(func $throw
+ ;; All these wrapping expressions before 'throw' will be dce'd
(drop
(block $label$0 (result externref)
(if
@@ -790,17 +791,16 @@
)
(func $rethrow
- (drop
- (block $label$0 (result externref)
- (if
- (i32.clz
- (block $label$1 (result i32)
- (rethrow 0)
- )
+ (try $l0
+ (do)
+ (catch $e
+ (drop
+ ;; This i32.add will be dce'd
+ (i32.add
+ (i32.const 0)
+ (rethrow $l0)
)
- (nop)
)
- (ref.null extern)
)
)
)
diff --git a/test/passes/dwarf_with_exceptions.bin.txt b/test/passes/dwarf_with_exceptions.bin.txt
index 5dd594461..9b853e179 100644
--- a/test/passes/dwarf_with_exceptions.bin.txt
+++ b/test/passes/dwarf_with_exceptions.bin.txt
@@ -93,7 +93,7 @@
)
)
;; code offset: 0x6c
- (rethrow 0)
+ (rethrow $label$8)
)
)
;; code offset: 0x6f
@@ -515,7 +515,7 @@ file_names[ 1]:
)
)
;; code offset: 0x3e
- (rethrow 0)
+ (rethrow $label$8)
)
)
;; code offset: 0x41
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 f8e7778c5..756b692c7 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,20 +3,20 @@
(type $i32_=>_none (func (param i32)))
(event $e0 (attr 0) (param i32))
(func $eh
- try $try
+ try $l0
i32.const 0
throw $e0
catch $e0
drop
catch_all
- rethrow 0
+ rethrow $l0
end
- try $l0
- try $try0
+ try $l00
+ try $try
i32.const 0
throw $e0
- delegate $l0
+ delegate $l00
unreachable
catch_all
nop
@@ -31,7 +31,7 @@
(type $i32_=>_none (func (param i32)))
(event $e0 (attr 0) (param i32))
(func $eh (; has Stack IR ;)
- (try $try
+ (try $l0
(do
(throw $e0
(i32.const 0)
@@ -43,18 +43,18 @@
)
)
(catch_all
- (rethrow 0)
+ (rethrow $l0)
)
)
- (try $l0
+ (try $l00
(do
- (try $try0
+ (try $try
(do
(throw $e0
(i32.const 0)
)
)
- (delegate $l0)
+ (delegate $l00)
)
)
(catch_all
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 f82f7e19a..298cb3a3c 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
@@ -2,7 +2,7 @@
(event $e0 (attr 0) (param i32))
(func $eh
- (try
+ (try $l0
(do
(throw $e0 (i32.const 0))
)
@@ -10,7 +10,7 @@
(drop (pop i32))
)
(catch_all
- (rethrow 0)
+ (rethrow $l0)
)
)
diff --git a/test/passes/rse_all-features.txt b/test/passes/rse_all-features.txt
index eaef14455..6c9d52585 100644
--- a/test/passes/rse_all-features.txt
+++ b/test/passes/rse_all-features.txt
@@ -569,14 +569,14 @@
(local $x i32)
(try $try
(do
- (try $try6
+ (try $l0
(do
(throw $e
(i32.const 0)
)
)
(catch_all
- (rethrow 0)
+ (rethrow $l0)
)
)
)
@@ -594,7 +594,7 @@
(local $x i32)
(try $try
(do
- (try $try7
+ (try $l0
(do
(throw $e
(i32.const 0)
@@ -604,7 +604,7 @@
(local.set $x
(i32.const 1)
)
- (rethrow 0)
+ (rethrow $l0)
)
)
)
@@ -620,7 +620,7 @@
(local $x i32)
(try $try
(do
- (try $try8
+ (try $l0
(do
(throw $e
(i32.const 0)
@@ -633,7 +633,7 @@
(local.set $x
(i32.const 1)
)
- (rethrow 0)
+ (rethrow $l0)
)
)
)
diff --git a/test/passes/rse_all-features.wast b/test/passes/rse_all-features.wast
index 2a8b81874..b3c684fbd 100644
--- a/test/passes/rse_all-features.wast
+++ b/test/passes/rse_all-features.wast
@@ -357,12 +357,12 @@
(local $x i32)
(try
(do
- (try
+ (try $l0
(do
(throw $e (i32.const 0))
)
(catch_all
- (rethrow 0)
+ (rethrow $l0)
)
)
)
@@ -379,13 +379,13 @@
(local $x i32)
(try
(do
- (try
+ (try $l0
(do
(throw $e (i32.const 0))
)
(catch_all
(local.set $x (i32.const 1))
- (rethrow 0)
+ (rethrow $l0)
)
)
)
@@ -399,14 +399,14 @@
(local $x i32)
(try
(do
- (try
+ (try $l0
(do
(throw $e (i32.const 0))
)
(catch $e
(drop (pop i32))
(local.set $x (i32.const 1))
- (rethrow 0)
+ (rethrow $l0)
)
)
)
diff --git a/test/spec/exception-handling.wast b/test/spec/exception-handling.wast
index 807ee0a52..21dc98bd4 100644
--- a/test/spec/exception-handling.wast
+++ b/test/spec/exception-handling.wast
@@ -92,29 +92,29 @@
)
(func (export "try_throw_rethrow")
- (try
+ (try $l0
(do
(throw $e-i32 (i32.const 5))
)
(catch $e-i32
(drop (pop i32))
- (rethrow 0)
+ (rethrow $l0)
)
)
)
(func (export "try_call_rethrow")
- (try
+ (try $l0
(do
(call $throw_single_value)
)
(catch_all
- (rethrow 0)
+ (rethrow $l0)
)
)
)
- (func (export "rethrow_depth_test1") (result i32)
+ (func (export "rethrow_target_test1") (result i32)
(try (result i32)
(do
(try
@@ -122,13 +122,13 @@
(throw $e-i32 (i32.const 1))
)
(catch_all
- (try
+ (try $l0
(do
(throw $e-i32 (i32.const 2))
)
(catch $e-i32
(drop (pop i32))
- (rethrow 0) ;; rethrow (i32.const 2)
+ (rethrow $l0) ;; rethrow (i32.const 2)
)
)
)
@@ -141,10 +141,10 @@
)
;; Can we handle rethrows with the depth > 0?
- (func (export "rethrow_depth_test2") (result i32)
+ (func (export "rethrow_target_test2") (result i32)
(try (result i32)
(do
- (try
+ (try $l0
(do
(throw $e-i32 (i32.const 1))
)
@@ -168,12 +168,12 @@
)
;; Tests whether the exception stack is managed correctly after rethrows
- (func (export "rethrow_depth_test3") (result i32)
+ (func (export "rethrow_target_test3") (result i32)
(try (result i32)
(do
- (try
+ (try $l0
(do
- (try
+ (try $l1
(do
(throw $e-i32 (i32.const 1))
)
@@ -184,14 +184,14 @@
)
(catch $e-i32
(drop (pop i32))
- (rethrow 1) ;; rethrow (i32.const 1)
+ (rethrow $l1) ;; rethrow (i32.const 1)
)
)
)
)
)
(catch $e-i32
- (rethrow 0) ;; rethrow (i32.const 1) again
+ (rethrow $l0) ;; rethrow (i32.const 1) again
)
)
)
@@ -212,9 +212,9 @@
(assert_return (invoke "try_throw_multivalue_catch") (i32.const 5))
(assert_trap (invoke "try_throw_rethrow"))
(assert_trap (invoke "try_call_rethrow"))
-(assert_return (invoke "rethrow_depth_test1") (i32.const 2))
-(assert_return (invoke "rethrow_depth_test2") (i32.const 1))
-(assert_return (invoke "rethrow_depth_test3") (i32.const 1))
+(assert_return (invoke "rethrow_target_test1") (i32.const 2))
+(assert_return (invoke "rethrow_target_test2") (i32.const 1))
+(assert_return (invoke "rethrow_target_test3") (i32.const 1))
(assert_invalid
(module
@@ -299,3 +299,33 @@
)
"all delegate targets must be valid"
)
+
+(assert_invalid
+ (module
+ (func $f0
+ (block $l0
+ (try
+ (do)
+ (catch_all
+ (rethrow $l0) ;; target is a block
+ )
+ )
+ )
+ )
+ )
+ "all rethrow targets must be valid"
+)
+
+(assert_invalid
+ (module
+ (func $f0
+ (try $l0
+ (do
+ (rethrow $l0) ;; Not within the target try's catch
+ )
+ (catch_all)
+ )
+ )
+ )
+ "all rethrow targets must be valid"
+)