You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In particular:
- The labels surrounding try-catch and try-delegate now get a standard
label in the first step, which is then refined to catch-labels and/or
try-labels per subblock.
+ For that I allowed the new administrative instructions to appear
nested directly inside a label_n{} in block contexts.
+ Also added a validation rule to the administrative label_n{}.
+ Due to this, all block contexts appear now without a successor
exponent.
- Updated to latest try-catch syntax described in issue WebAssembly#157.
- Corrected some previously wrong syntax.
- Removed try-unwind (...) as per issue WebAssembly#156
- Updated Exceptions-formal-examples.md similarly.
@@ -12,21 +12,22 @@ If anyone would like that I add another reduction trace, or other examples, plea
12
12
13
13
### notation
14
14
15
-
If `x` is an exception index, then `a_x` denotes its exception tag, i.e., `F_exn(x) = a_x`, where `F` is the current frame.
15
+
If `x` is an exception index, then `a_x` denotes its exception tag, i.e., `F.exception[x] = a_x`, where `F` is the current frame.
16
16
17
17
## example 0
18
18
19
-
The only example with an almost full reduction trace, and all new instructions (`rethrow` and `catch_all` are hidden in `unwind`'s reduct). The first 3 steps, reducing the several `try`s to their respective administrative instructions, are not shown.
19
+
The only example with an almost full reduction trace, and all new instructions. The first 3 steps, reducing the several `try`s to their respective administrative instructions, are not shown.
20
20
21
21
```
22
22
(func (result i32) (local i32)
23
23
try
24
24
try
25
25
try
26
26
throw x
27
-
unwind
27
+
catch_all
28
28
i32.const 27
29
29
local.set 0
30
+
rethrow 0
30
31
end
31
32
delegate 0
32
33
catch x
@@ -37,48 +38,59 @@ The only example with an almost full reduction trace, and all new instructions (
37
38
Take the frame `F = (locals i32.const 0, module m)`. We have:
38
39
39
40
```
40
-
↪ ↪ ↪ F; catch_1{a_x local.get 0} (label_1{}
41
-
(delegate{0} (label_0{}
42
-
(catch_0{i32.const 27 local.set 0 rethrow 0} (label_0{} ;; the try-unwind
Interaction of `rethrow` with `unwind`. Taken from [this comment](https://github.com/WebAssembly/exception-handling/issues/87#issuecomment-705586912) by @rossberg.
102
+
Location of a rethrown exception.
91
103
92
104
```
93
105
try
106
+
val1
94
107
throw x
95
108
catch x
96
109
try
97
-
instr1*
98
-
rethrow 0
99
-
unwind
100
-
instr2*
110
+
val2
111
+
throw y
112
+
catch_all
113
+
try
114
+
val3
115
+
throw z
116
+
catch z
117
+
rethrow 2
118
+
end
101
119
end
102
120
end
103
121
```
104
122
105
-
Assuming `instr1*`and `instr2*` don't throw another exception, this example reduces to
123
+
In the above example, all thrown exceptions get caught and the first one gets rethrown from the catching block of the last one. So the above reduces to
106
124
107
125
```
108
-
caught_0{a_x} (label_0 {}
109
-
(caught_0{a_x} (label_0 {}
110
-
instr2* throw a_x end) end) end) end
126
+
label_0{} caught{a_x val1}
127
+
val1 (label_0{} caught{a_y val2}
128
+
(label_0{} caught{a_z val3}
129
+
val3 val1 (throw a_x) end end)
130
+
end end) end end)
111
131
```
112
132
113
-
which in turn reduces to `throw a_x`.
114
-
115
-
Note that any global state changes due to `instr1*` or `instr2*` will take place.
133
+
which in this case is the same as `val1 (throw a_x)`.
116
134
117
135
### example 2
118
136
@@ -137,7 +155,7 @@ This is a validation error (no catch block at given rethrow depth).
137
155
138
156
### example 3
139
157
140
-
`delegate`targetting a catch is a validation error.
158
+
`delegate`targeting a catch is a validation error.
141
159
142
160
```
143
161
try $label0
@@ -152,93 +170,23 @@ This is a validation error because `delegate`'s `$label0` refers to the catch-la
152
170
153
171
### example 4
154
172
155
-
`delegate` correctly targetting a `try-delegate` and a `try-catch`.
173
+
`delegate` correctly targeting a `try-delegate` and a `try-catch`.
156
174
157
175
```
158
176
try $label1
159
177
try $label0
160
178
try
161
179
throw x
162
-
delegate $label0
163
-
delegate $label1
180
+
delegate $label0 ;; delegate 0
181
+
delegate $label1 ;; delegate 1
164
182
catch x
165
183
instr*
166
184
end
167
185
```
168
186
169
-
The thrown exception is (eventually) caught by the outer try's `catch x`, so the above reduces to
187
+
The thrown exception is (eventually) caught by the outer try's `catch x`, so the above reduces to the following.
170
188
171
189
```
172
-
caught_0{a_x} (label_0 {} instr* end) end
173
-
```
174
-
175
-
176
-
## interaction of `delegate` and `unwind`
177
-
178
-
Two examples from issue #130.
179
-
180
-
### example 5
181
-
182
-
The [opening example](https://github.com/WebAssembly/exception-handling/issues/130#issue-713113953)
183
-
of issue #130.
184
-
185
-
```
186
-
i32.const 11
187
-
global.set 0
188
-
try $l
189
-
try
190
-
try
191
-
throw x
192
-
delegate 1
193
-
unwind
194
-
i32.const 27
195
-
global.set 0
196
-
end
197
-
catch_all
198
-
end
199
-
global.get 0
190
+
label_0 {} (caught_0{a_x} (label_0 {} instr* end) end
200
191
```
201
192
202
-
Here, `delegate 1` targets the label `$l` (so it would be the same if we wrote `delegate $l` instead).
203
-
204
-
This example returns `11`, because `delegate` skips everything up to and not including `try $l`.
205
-
206
-
### example 6
207
-
208
-
This example
209
-
[appears to keep](https://github.com/WebAssembly/exception-handling/issues/130#issuecomment-704249682)
210
-
the issue #130 open.
211
-
212
-
@RossTate expressed concerns with respect to an example possibly equivalent to
213
-
the one below. "Possibly", because the original example in the comment refers to
214
-
an `unwinding` branch, first presented in issue #124, so I attempted to rewrite
215
-
the example to match the current syntax as best I could.
216
-
217
-
```
218
-
try $t
219
-
try $l
220
-
try $u
221
-
try
222
-
throw x
223
-
delegate $t
224
-
unwind
225
-
instr1*
226
-
end
227
-
catch x
228
-
instr2*
229
-
end
230
-
instr3*
231
-
catch_all
232
-
instr4*
233
-
end
234
-
```
235
-
236
-
The thrown exception tag `a_x` is delegated to the outer `try $l - catch_all`, ignoring the `try $u - unwind` and `try - catch x` in between. So this example reduces to
237
-
238
-
```
239
-
caught_0{a_x} (label_0{} instr4* end) end
240
-
```
241
-
242
-
During the above reduction, `instr1*`, `instr2*`, and `instr3*` are never executed.
0 commit comments