@@ -22,6 +22,9 @@ test(() => {
22
22
let wasmTagExnSamePayload = null ;
23
23
let wasmTagExnDiffPayload = null ;
24
24
25
+ const kSig_ie_v = makeSig ( [ ] , [ kWasmI32 , kExnRefCode ] ) ;
26
+ const sig_ie_v = builder . addType ( kSig_ie_v ) ;
27
+
25
28
const imports = {
26
29
module : {
27
30
throwJSTagExn : function ( ) { throw jsTagExn ; } ,
@@ -31,55 +34,73 @@ test(() => {
31
34
} ;
32
35
33
36
// Call a JS function that throws an exception using a JS-defined tag, catches
34
- // it with a 'catch ' instruction, and rethrows it.
37
+ // it with a 'catch_ref ' instruction, and rethrows it.
35
38
builder
36
- . addFunction ( "catch_js_tag_rethrow " , kSig_v_v )
39
+ . addFunction ( "catch_ref_js_tag_throw_ref " , kSig_v_v )
37
40
. addBody ( [
38
- kExprTry , kWasmVoid ,
39
- kExprCallFunction , throwJSTagExnIndex ,
40
- kExprCatch , jsTagIndex ,
41
- kExprDrop ,
42
- kExprRethrow , 0x00 ,
41
+ kExprBlock , kWasmVoid ,
42
+ kExprBlock , sig_ie_v ,
43
+ kExprTryTable , kWasmVoid , 1 ,
44
+ kCatchRef , jsTagIndex , 0 ,
45
+ kExprCallFunction , throwJSTagExnIndex ,
46
+ kExprEnd ,
47
+ kExprBr , 1 ,
48
+ kExprEnd ,
49
+ kExprThrowRef ,
43
50
kExprEnd
44
51
] )
45
52
. exportFunc ( ) ;
46
53
47
54
// Call a JS function that throws an exception using a Wasm-defined tag,
48
- // catches it with a 'catch ' instruction, and rethrows it.
55
+ // catches it with a 'catch_ref ' instruction, and rethrows it.
49
56
builder
50
- . addFunction ( "catch_wasm_tag_rethrow " , kSig_v_v )
57
+ . addFunction ( "catch_ref_wasm_tag_throw_ref " , kSig_v_v )
51
58
. addBody ( [
52
- kExprTry , kWasmVoid ,
53
- kExprCallFunction , throwWasmTagExnIndex ,
54
- kExprCatch , wasmTagIndex ,
55
- kExprDrop ,
56
- kExprRethrow , 0x00 ,
59
+ kExprBlock , kWasmVoid ,
60
+ kExprBlock , sig_ie_v ,
61
+ kExprTryTable , kWasmVoid , 1 ,
62
+ kCatchRef , wasmTagIndex , 0 ,
63
+ kExprCallFunction , throwWasmTagExnIndex ,
64
+ kExprEnd ,
65
+ kExprBr , 1 ,
66
+ kExprEnd ,
67
+ kExprThrowRef ,
57
68
kExprEnd
58
69
] )
59
70
. exportFunc ( ) ;
60
71
61
72
// Call a JS function that throws an exception using a JS-defined tag, catches
62
- // it with a 'catch_all ' instruction, and rethrows it.
73
+ // it with a 'catch_all_ref ' instruction, and rethrows it.
63
74
builder
64
- . addFunction ( "catch_all_js_tag_rethrow " , kSig_v_v )
75
+ . addFunction ( "catch_all_ref_js_tag_throw_ref " , kSig_v_v )
65
76
. addBody ( [
66
- kExprTry , kWasmVoid ,
67
- kExprCallFunction , throwJSTagExnIndex ,
68
- kExprCatchAll ,
69
- kExprRethrow , 0x00 ,
77
+ kExprBlock , kWasmVoid ,
78
+ kExprBlock , kExnRefCode ,
79
+ kExprTryTable , kWasmVoid , 1 ,
80
+ kCatchAllRef , 0 ,
81
+ kExprCallFunction , throwJSTagExnIndex ,
82
+ kExprEnd ,
83
+ kExprBr , 1 ,
84
+ kExprEnd ,
85
+ kExprThrowRef ,
70
86
kExprEnd
71
87
] )
72
88
. exportFunc ( ) ;
73
89
74
90
// Call a JS function that throws an exception using a Wasm-defined tag,
75
- // catches it with a 'catch_all ' instruction, and rethrows it.
91
+ // catches it with a 'catch_all_ref ' instruction, and rethrows it.
76
92
builder
77
- . addFunction ( "catch_all_wasm_tag_rethrow " , kSig_v_v )
93
+ . addFunction ( "catch_all_ref_wasm_tag_throw_ref " , kSig_v_v )
78
94
. addBody ( [
79
- kExprTry , kWasmVoid ,
80
- kExprCallFunction , throwWasmTagExnIndex ,
81
- kExprCatchAll ,
82
- kExprRethrow , 0x00 ,
95
+ kExprBlock , kWasmVoid ,
96
+ kExprBlock , kExnRefCode ,
97
+ kExprTryTable , kWasmVoid , 1 ,
98
+ kCatchAllRef , 0 ,
99
+ kExprCallFunction , throwWasmTagExnIndex ,
100
+ kExprEnd ,
101
+ kExprBr , 1 ,
102
+ kExprEnd ,
103
+ kExprThrowRef ,
83
104
kExprEnd
84
105
] )
85
106
. exportFunc ( ) ;
@@ -89,12 +110,17 @@ test(() => {
89
110
builder
90
111
. addFunction ( "catch_js_tag_return_payload" , kSig_i_v )
91
112
. addBody ( [
92
- kExprTry , kWasmI32 ,
93
- kExprCallFunction , throwJSTagExnIndex ,
94
- kExprI32Const , 0x00 ,
95
- kExprCatch , jsTagIndex ,
113
+ kExprBlock , kWasmVoid ,
114
+ kExprBlock , kWasmI32 ,
115
+ kExprTryTable , kWasmVoid , 1 ,
116
+ kCatchNoRef , jsTagIndex , 0 ,
117
+ kExprCallFunction , throwJSTagExnIndex ,
118
+ kExprEnd ,
119
+ kExprBr , 1 ,
120
+ kExprEnd ,
96
121
kExprReturn ,
97
- kExprEnd
122
+ kExprEnd ,
123
+ kExprI32Const , 0
98
124
] )
99
125
. exportFunc ( ) ;
100
126
@@ -103,9 +129,14 @@ test(() => {
103
129
builder
104
130
. addFunction ( "catch_js_tag_throw_payload" , kSig_v_v )
105
131
. addBody ( [
106
- kExprTry , kWasmVoid ,
107
- kExprCallFunction , throwJSTagExnIndex ,
108
- kExprCatch , jsTagIndex ,
132
+ kExprBlock , kWasmVoid ,
133
+ kExprBlock , kWasmI32 ,
134
+ kExprTryTable , kWasmVoid , 1 ,
135
+ kCatchNoRef , jsTagIndex , 0 ,
136
+ kExprCallFunction , throwJSTagExnIndex ,
137
+ kExprEnd ,
138
+ kExprBr , 1 ,
139
+ kExprEnd ,
109
140
kExprThrow , jsTagIndex ,
110
141
kExprEnd
111
142
] )
@@ -117,7 +148,7 @@ test(() => {
117
148
// The exception object's identity should be preserved across 'rethrow's in
118
149
// Wasm code. Do tests with a tag defined in JS.
119
150
try {
120
- result . instance . exports . catch_js_tag_rethrow ( ) ;
151
+ result . instance . exports . catch_ref_js_tag_throw_ref ( ) ;
121
152
} catch ( e ) {
122
153
assert_equals ( e , jsTagExn ) ;
123
154
// Even if they have the same payload, they are different objects, so they
@@ -126,7 +157,7 @@ test(() => {
126
157
assert_not_equals ( e , jsTagExnDiffPayload ) ;
127
158
}
128
159
try {
129
- result . instance . exports . catch_all_js_tag_rethrow ( ) ;
160
+ result . instance . exports . catch_all_ref_js_tag_throw_ref ( ) ;
130
161
} catch ( e ) {
131
162
assert_equals ( e , jsTagExn ) ;
132
163
assert_not_equals ( e , jsTagExnSamePayload ) ;
@@ -139,14 +170,14 @@ test(() => {
139
170
wasmTagExnSamePayload = new WebAssembly . Exception ( wasmTag , [ 42 ] ) ;
140
171
wasmTagExnDiffPayload = new WebAssembly . Exception ( wasmTag , [ 53 ] ) ;
141
172
try {
142
- result . instance . exports . catch_wasm_tag_rethrow ( ) ;
173
+ result . instance . exports . catch_ref_wasm_tag_throw_ref ( ) ;
143
174
} catch ( e ) {
144
175
assert_equals ( e , wasmTagExn ) ;
145
176
assert_not_equals ( e , wasmTagExnSamePayload ) ;
146
177
assert_not_equals ( e , wasmTagExnDiffPayload ) ;
147
178
}
148
179
try {
149
- result . instance . exports . catch_all_wasm_tag_rethrow ( ) ;
180
+ result . instance . exports . catch_all_ref_wasm_tag_throw_ref ( ) ;
150
181
} catch ( e ) {
151
182
assert_equals ( e , wasmTagExn ) ;
152
183
assert_not_equals ( e , wasmTagExnSamePayload ) ;
0 commit comments