-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduction semantics #109
base: main
Are you sure you want to change the base?
Reduction semantics #109
Conversation
This patch populates the "Execution" section of the Explainer document with the reduction rules for stack switching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would also make sense to have Maxime take a look, since he's mechanising this right now.
@@ -833,6 +833,126 @@ events and only `(on $e switch)` handlers can handle `switch` | |||
events. The handler search continues past handlers for the wrong kind | |||
of event, even if they use the correct tag. | |||
|
|||
#### Store extensions | |||
|
|||
* A store component `tags` for allocated tags (from the exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the exception handling proposal is already merged, I think we can consider taginsts and their store component given.
- `ref.cont a : [] -> [(ref $ct)]` | ||
- iff `S.conts[a] = epsilon \/ S.conts[a] = (E : n)` | ||
- and `$ct ~~ cont $ft` | ||
- and `$ft ~~ [t1^n] -> [t2*]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would also need to require that E
returns t2*. I think we want to factor both out into a separate typing rule for continuations, which is just invoked here. That rule would be something like
(E : n) : t1^n → t2*
- iff s ⊢ E[val^n] : t2*
- and (s ⊢ val : t1)^n
- and `$ft ~~ [t1^n] -> [t2*]` | ||
|
||
* `(prompt{<hdl>*} <instr>* end)` represents an active handler | ||
- `(prompt{((a $l) | (b switch))*}? instr* end) : [t1*] -> [t2*]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit too cute. A disjunction under an iteration does not really work, since the dimensions of a*
and b*
wouldn't really make sense then. So I'd suggest
- `(prompt{((a $l) | (b switch))*}? instr* end) : [t1*] -> [t2*]` | |
- `(prompt{hdl*} instr* end) : [t1*] -> [t2*]` |
and then have auxiliary rules for typing hdl, like for syntactic handlers.
|
||
The administrative structure `hdl` is defined as. | ||
``` | ||
hdl ::= (<tagaddr> $l) hdl | (<tagaddr> switch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hdl ::= (<tagaddr> $l) hdl | (<tagaddr> switch) | |
hdl ::= (<tagaddr> $l) | (<tagaddr> switch) |
label_n{instr*} H^ea end | ||
frame_n{F} H^ea end | ||
catch{...} H^ea end | ||
prompt{hdl*} H^ea end (iff ea notin ea'*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prompt{hdl*} H^ea end (iff ea notin ea'*) | |
prompt{hdl*} H^ea end (iff ea notin tagaddr(hdl*)) |
|
||
* `S; F; v^m (ref.cont ca) (resume_throw $ct $e hdl*) --> S'; F; prompt{hdl*} E[v^m (throw $e)] end` | ||
- iff `S.conts[ca] = (E : n)` | ||
- and `(ea = F.tags[$t])*` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
- and `S.tags[F.tags[$e]].type ~~ [t1^m] -> [t2*]` | ||
- and `S' = S with conts[ca] = epsilon` | ||
|
||
* `S; F; (prompt{(e $l)*}? v* end) --> S; F; v*` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `S; F; (prompt{(e $l)*}? v* end) --> S; F; v*` | |
* `S; F; (prompt{hdl*} v* end) --> S; F; v*` |
|
||
* `S; F; (prompt{(e $l)*}? v* end) --> S; F; v*` | ||
|
||
* `S; F; (prompt H^ea[(suspend $e)] end) --> S; F; trap` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this rule was for barrier, so is obsolete?
- iff `ea = F.tags[$e]` | ||
|
||
* `S; F; (prompt{hdl1* (ea $l) hdl2*} H^ea[v^n (suspend $e)] end) --> S'; F; v^n (ref.cont |S.conts|) (br $l)` | ||
- iff `ea notin ea1*` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- iff `ea notin ea1*` | |
- iff `ea notin tagaddr(hdl1*)` |
* `S; F; (prompt{hdl1* (ea switch) hdl2*} H^ea[v^n (ref.cont ca) (switch $ct $e)] end) --> S''; F; prompt{hdl1* (ea switch) hdl2*} E[v^n (ref.cont |S.conts|)] end` | ||
- iff `S.conts[ca] = (E : n')` | ||
- and `n' = 1 + n` | ||
- and `ea notin ea1*` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- and `ea notin ea1*` | |
- and `ea notin tagaddr(hdl1*)` |
This patch populates the "Execution" section of the Explainer document with the reduction rules for stack switching.
Resolves #91.