Skip to content

Commit d874fcd

Browse files
committed
Addressed latest review and added the missing +1 to the adm. delegate.
The latter matches the interpreter implementation in PR WebAssembly#175
1 parent 7d122dd commit d874fcd

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

proposals/exception-handling/Exceptions-formal-examples.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Take the frame `F = (locals i32.const 0, module m)`. We have:
3939

4040
```
4141
↪ ↪ ↪ F; label_1{} (catch_1{a_x local.get 0}
42-
(label_0{} (delegate{0}
42+
(label_0{} (delegate{1}
4343
(label_0{} (catch_0{i32.const 27 local.set 0 rethrow 0}
4444
throw a_x end) end) end) end) end) end
4545
```
@@ -48,12 +48,12 @@ For the empty throw context `T = [_]` the above is the same as
4848

4949
```
5050
F; label_1{} (catch_1{a_x local.get 0}
51-
label_0{} (delegate{0}
51+
label_0{} (delegate{1}
5252
label_0{} (catch_0{i32.const 27 local.set 0 rethrow 0}
5353
T[throw a_x] end) end) end) end) end
5454
5555
↪ F; label_1{} (catch_1{a_x local.get 0}
56-
(label_0{} (delegate{0}
56+
(label_0{} (delegate{1}
5757
(label_0{} (caught{a_x} i32.const 27 local.set 0 rethrow 0
5858
end) end) end) end) end) end
5959
```
@@ -62,33 +62,25 @@ Let `F'` be the frame `{locals i32.const 27, module m}`, and let `B^0 = [_]`.
6262

6363
```
6464
↪ F; label_1{} (catch_1{a_x local.get 0}
65-
(label_0{} (delegate{0}
65+
(label_0{} (delegate{1}
6666
(label_0{} (caught{a_x} B^0 [rethrow 0]
6767
end) end) end) end) end) end
6868
6969
↪ F; label_1{} (catch_1{a_x local.get 0}
70-
(label_0{} (delegate{0}
70+
(label_0{} (delegate{1}
7171
(label_0{} (caught{a_x} B^0 [throw a_x]
7272
end) end) end) end) end) end
7373
```
7474

75-
Let `T' = label_0{} (caught{a_x} B^0 [_] end) end`.
75+
Let `T' = label_0{} (caught{a_x} [_] end) end`, and `B^1 = label_0 [_] end`.
7676

7777
```
7878
↪ F; label_1{} (catch_1{a_x local.get 0}
79-
(label_0{} (delegate{0}
80-
T'[throw a_x] end) end) end) end
79+
(B^1 [delegate{1}
80+
T'[throw a_x] end] end) end
8181
8282
↪ F; label_1{} (catch_1{a_x local.get 0}
83-
(label_0{} (delegate{0}
84-
T'[throw a_x] end) end) end) end
85-
86-
↪ F; label_1{} (catch_1{a_x local.get 0}
87-
(label_0{} (delegate{0}
88-
T'[throw a_x] end) end) end) end
89-
90-
↪ F; label_1{} (catch_1{a_x local.get 0}
91-
T'[throw a_x] end) end
83+
(throw a_x) end) end
9284
9385
↪ F; label_1{} (caught_1{a_x} local.get 0 end) end
9486

proposals/exception-handling/Exceptions-formal-overview.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ S; F; catch_m T[val^n (throw a)] end
165165
166166
167167
val^n (try bt instr* delegate l)
168-
↪ label_m{} (delegate{l} val^n instr* end) end
168+
↪ label_m{} (delegate{l+1} val^n instr* end) end
169169
(if bt = [t^n]→[t^m])
170170
171171
delegate{l} val^n end ↪ val^n
@@ -190,7 +190,7 @@ S;C, labels [t*] ⊢ catch_n{a? instr'*}* instr* end : []→[t*]
190190
S;C, labels {result [t*], kind try} ⊢ instr* : []→[t*]
191191
C.labels[l].kind = try
192192
-----------------------------------------------------------------------
193-
S;C, labels [t*] ⊢ delegate{l} instr* end : []→[t*]
193+
S;C, labels [t*] ⊢ delegate{l+1} instr* end : []→[t*]
194194
195195
S.tags[a].type = [t'*]→[]
196196
(val:t')*
@@ -199,11 +199,3 @@ S;C, labels {result [t*], kind catch} ⊢ instr* : []→[t*]
199199
S;C, labels [t*] ⊢ caught_m{a val^n} instr* end : []→[t'*]
200200
```
201201

202-
By adding the attribute `kind` to labels, we are creating situations in the proof of type preservation, where we have a derivation of some `S;C, label [t*] ⊢ instr* : []→[t*]` but we need to have that `S;C, label {result [t*], kind <labelkind>} ⊢ instr* : []→[t*]` for some `<labelkind> ::= try | catch`. To resolve this we add the following typing rule for labels in the context, which ensures our newly introduced `try` and `catch` blocks can contain any instructions a regular block can.
203-
204-
```
205-
S;C, label [t*] ⊢ instr* : []→[t*]
206-
labelkind = try ∨ labelkind = catch
207-
-----------------------------------------------------------
208-
S;C, label {result [t*], kind labelkind} ⊢ instr* : []→[t*]
209-
```

0 commit comments

Comments
 (0)