Skip to content

Commit 026f723

Browse files
authored
Do not store continuation arities (#135)
Real implementations will determine continuation arities by inspecting the type immediates on the instructions that manipulate those continuations, not by reading the arities off the continuations at runtime. Update the semantics given in the explainer to compute arities from type immediates as well.
1 parent 9579cb9 commit 026f723

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

proposals/stack-switching/Explainer.md

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,15 +1050,15 @@ of event, even if they use the correct tag.
10501050
* New store component `conts` for allocated continuations
10511051
- `S ::= {..., conts <continst>?*}`
10521052

1053-
* A continuation is a context annotated with its hole's arity
1054-
- `continst ::= (E : n)`
1053+
* A continuation is a context
1054+
- `continst ::= E`
10551055

10561056

10571057
#### Administrative instructions
10581058

10591059
* `(ref.cont a)` represents a continuation value, where `a` is a *continuation address* indexing into the store's `conts` component
10601060
- `ref.cont a : [] -> [(ref $ct)]`
1061-
- iff `S.conts[a] = epsilon \/ S.conts[a] = (E : n)`
1061+
- iff `S.conts[a] = epsilon \/ S.conts[a] = E`
10621062
+ iff `E[val^n] : t2*`
10631063
+ and `(val : t1)^n`
10641064
- and `$ct ~~ cont $ft`
@@ -1087,22 +1087,20 @@ H^ea ::=
10871087
* `S; F; (ref.null t) (cont.new $ct) --> S; F; trap`
10881088

10891089
* `S; F; (ref.func fa) (cont.new $ct) --> S'; F; (ref.cont |S.conts|)`
1090-
- iff `S' = S with conts += (E : n)`
1090+
- iff `S' = S with conts += E`
10911091
- and `E = _ (invoke fa)`
1092-
- and `$ct ~~ cont $ft`
1093-
- and `$ft ~~ [t1^n] -> [t2*]`
10941092

10951093
* `S; F; (ref.null t) (cont.bind $ct $ct') --> S; F; trap`
10961094

10971095
* `S; F; (ref.cont ca) (cont.bind $ct $ct') --> S; F; trap`
10981096
- iff `S.conts[ca] = epsilon`
10991097

11001098
* `S; F; v^n (ref.cont ca) (cont.bind $ct $ct') --> S'; F; (ref.cont |S.conts|)`
1101-
- iff `S.conts[ca] = (E' : n')`
1102-
- and `$ct' ~~ cont $ft'`
1103-
- and `$ft' ~~ [t1'*] -> [t2'*]`
1104-
- and `n = n' - |t1'*|`
1105-
- and `S' = S with conts[ca] = epsilon with conts += (E : |t1'*|)`
1099+
- iff `S.conts[ca] = E'`
1100+
- and `$ct ~~ cont [t1*] -> [t2*]`
1101+
- and `$ct' ~~ cont [t1'*] -> [t2'*]`
1102+
- and `n = |t1*| - |t1'*|`
1103+
- and `S' = S with conts[ca] = epsilon with conts += E`
11061104
- and `E = E'[v^n _]`
11071105

11081106
* `S; F; (ref.null t) (resume $ct hdl*) --> S; F; trap`
@@ -1111,8 +1109,9 @@ H^ea ::=
11111109
- iff `S.conts[ca] = epsilon`
11121110

11131111
* `S; F; v^n (ref.cont ca) (resume $ct hdl*) --> S'; F; prompt{hdl'*} E[v^n] end`
1114-
- iff `S.conts[ca] = (E : n)`
1112+
- iff `S.conts[ca] = E`
11151113
- and `S' = S with conts[ca] = epsilon`
1114+
- and `$ct ~~ cont [t1^n] -> [t2*]`
11161115
- and `hdl'* = hdl*[F.module.tags / 0..|F.module.tags|-1]`
11171116

11181117
* `S; F; (ref.null t) (resume_throw $ct $e hdl*) --> S; F; trap`
@@ -1128,10 +1127,10 @@ H^ea ::=
11281127
- iff `S.conts[ca] = epsilon`
11291128

11301129
* `S; F; (ref.null t) (ref.cont ca) (resume_throw_ref $ct hdl*) --> S; F; trap`
1131-
- iff `S.conts[ca] = (E : n)`
1130+
- iff `S.conts[ca] = E`
11321131

11331132
* `S; F; (ref.exn ea) (ref.cont ca) (resume_throw_ref $ct hdl*) --> S'; F; prompt{hdl'*} E[(ref.exn ea) throw_ref] end`
1134-
- iff `S.conts[ca] = (E : n)`
1133+
- iff `S.conts[ca] = E`
11351134
- and `S' = S with conts[ca] = epsilon`
11361135
- and `hdl'* = hdl*[F.module.tags / 0..|F.module.tags|-1]`
11371136

@@ -1154,15 +1153,11 @@ H^ea ::=
11541153
- iff `S.conts[ca] = epsilon`
11551154

11561155
* `S; F; (prompt{hdl1* (on ea switch) hdl2*} H^ea[v^n (ref.cont ca) (switch $ct ea)] end) --> S''; F; prompt{hdl1* (on ea switch) hdl2*} E[v^n (ref.cont |S.conts|)] end`
1157-
- iff `S.conts[ca] = (E : n')`
1158-
- and `n' = 1 + n`
1156+
- iff `S.conts[ca] = E`
11591157
- and `(on switch ea) notin hdl1*`
1160-
- and `$ct ~~ cont $ft`
1161-
- and `$ft ~~ [t1* (ref $ct2)] -> [t2*]`
1162-
- and `$ct2 ~~ cont $ft2`
1163-
- and `$ft2 ~~ [t1'^m] -> [t2'*]`
1158+
- and `$ct ~~ cont [t1^n (ref $ct2)] -> [t2*]`
11641159
- and `S' = S with conts[ca] = epsilon`
1165-
- and `S'' = S' with conts += (H^ea : m)`
1160+
- and `S'' = S' with conts += H^ea`
11661161

11671162
### Binary format
11681163

0 commit comments

Comments
 (0)