Skip to content

Commit 6082dc5

Browse files
authored
Added tag uses
1 parent b570d38 commit 6082dc5

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

proposals/stack-switching/Explainer.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,10 @@ We change the wellformedness condition for tag types to be more liberal, i.e.
748748

749749
In other words, the return type of tag types is allowed to be non-empty.
750750

751+
We also introduce tag uses, which can be either tag indices or tag addresses:
752+
753+
- `taguse ::= tagidx | tagaddr`
754+
751755
### Instructions
752756

753757
The new instructions and their validation rules are as follows. To simplify the presentation, we write this:
@@ -806,13 +810,16 @@ This abbreviation will be formalised with an auxiliary function or other means i
806810
- iff `C.tags[$e] = tag $ft`
807811
- and `C.types[$ft] ~~ func [] -> [t*]`
808812

809-
- `suspend <tagidx>`
813+
- `suspend <taguse>`
810814
- Use a control tag to suspend the current computation.
811815
- `suspend $e : [t1*] -> [t2*]`
812816
- iff `C.tags[$e] = tag $ft`
813817
- and `C.types[$ft] ~~ func [t1*] -> [t2*]`
818+
- `suspend ea : [t1*] -> [t2*]`
819+
- iff `S.tags[ea] = tag $ft`
820+
- and `C.types[$ft] ~~ func [t1*] -> [t2*]`
814821

815-
- `switch <typeidx> <tagidx>`
822+
- `switch <typeidx> <taguse>`
816823
- Switch to executing a given continuation directly, suspending the current execution.
817824
- The suspension and switch are performed from the perspective of a parent `(on $e switch)` handler, determined by the annotated control tag.
818825
- `switch $ct1 $e : [t1* (ref null $ct1)] -> [t2*]`
@@ -822,6 +829,13 @@ This abbreviation will be formalised with an auxiliary function or other means i
822829
- and `te1* <: t*`
823830
- and `C.types[$ct2] ~~ cont [t2*] -> [te2*]`
824831
- and `t* <: te2*`
832+
- `switch $ct1 ea : [t1* (ref null $ct1)] -> [t2*]`
833+
- iff `S.tags[ea] = tag $ft`
834+
- and `C.types[$ft] ~~ func [] -> [t*]`
835+
- and `C.types[$ct1] ~~ cont [t1* (ref null? $ct2)] -> [te1*]`
836+
- and `te1* <: t*`
837+
- and `C.types[$ct2] ~~ cont [t2*] -> [te2*]`
838+
- and `t* <: te2*`
825839

826840
### Execution
827841

@@ -852,18 +866,6 @@ of event, even if they use the correct tag.
852866
- and `$ct ~~ cont $ft`
853867
- and `$ft ~~ [t1^n] -> [t2*]`
854868

855-
* `(suspend.addr ea)` represents a `(suspend $e)` instruction where the tag index `$e` has been replaced with the physical address `ea` of the tag.
856-
- `suspend.addr ea : [t1*] -> [t2*]`
857-
- iff `S.tags[ea].type ~~ [t1*] -> [t2*]`
858-
859-
* `(switch.addr $ct ea)` represents a `(switch $ct $e)` instruction where the tag index `$e` has been replaced with the physical address `ea` of the tag.
860-
- `switch.addr $ct ea : [t1* (ref null $ct1)] -> [t2*]`
861-
- iff `S.tags[$e].type ~~ [] -> [t*]`
862-
- and `C.types[$ct] ~~ cont [t1* (ref null? $ct2)] -> [te1*]`
863-
- and `te1* <: t*`
864-
- and `C.types[$ct2] ~~ cont [t2*] -> [te2*]`
865-
- and `t* <: te2*`
866-
867869
* `(prompt{<hdl>*} <instr>* end)` represents an active handler
868870
- `(prompt{hdl*}? instr* end) : [] -> [t*]`
869871
- iff `instr* : [] -> [t*]` in the empty context
@@ -954,18 +956,18 @@ H^ea ::=
954956

955957
* `S; F; (prompt{hdl*} v* end) --> S; F; v*`
956958

957-
* `S; F; (suspend $e) --> S; F; (suspend.addr ea)`
959+
* `S; F; (suspend $e) --> S; F; (suspend ea)`
958960
- iff `ea = F.module.tags[$e]`
959961

960-
* `S; F; (prompt{hdl1* (ea $l) hdl2*} H^ea[v^n (suspend.addr ea)] end) --> S'; F; v^n (ref.cont |S.conts|) (br $l)`
962+
* `S; F; (prompt{hdl1* (ea $l) hdl2*} H^ea[v^n (suspend ea)] end) --> S'; F; v^n (ref.cont |S.conts|) (br $l)`
961963
- iff `forall $l', (ea $l') notin hdl1*`
962964
- and `S.tags[ea].type ~~ [t1^n] -> [t2^m]`
963965
- and `S' = S with conts += (H^ea : m)`
964966

965-
* `S; F; (switch $ct $e) --> S; F; (switch.addr $ct ea)`
967+
* `S; F; (switch $ct $e) --> S; F; (switch $ct ea)`
966968
- iff `ea = F.module.tags[$e]`
967969

968-
* `S; F; (prompt{hdl1* (ea switch) hdl2*} H^ea[v^n (ref.cont ca) (switch.addr $ct ea)] end) --> S''; F; prompt{hdl1* (ea switch) hdl2*} E[v^n (ref.cont |S.conts|)] end`
970+
* `S; F; (prompt{hdl1* (ea switch) hdl2*} H^ea[v^n (ref.cont ca) (switch $ct ea)] end) --> S''; F; prompt{hdl1* (ea switch) hdl2*} E[v^n (ref.cont |S.conts|)] end`
969971
- iff `S.conts[ca] = (E : n')`
970972
- and `n' = 1 + n`
971973
- and `(switch ea) notin hdl1*`

0 commit comments

Comments
 (0)