Skip to content

Add resume_throw_ref to the explainer#132

Merged
tlively merged 4 commits into
mainfrom
resume-throw-ref
Oct 9, 2025
Merged

Add resume_throw_ref to the explainer#132
tlively merged 4 commits into
mainfrom
resume-throw-ref

Conversation

@tlively

@tlively tlively commented Oct 8, 2025

Copy link
Copy Markdown
Member

Give it opcode 0xe5 to be adjacent to resume_throw at 0xe4, and as a
result bump switch to 0xe6.

Redefine the execution semantics of resume_throw in terms of
resume_throw_ref.

As a drive-by, fix the nullability of reference operands in the initial
introduction of each other instruction.

Give it opcode 0xe5 to be adjacent to `resume_throw` at 0xe4, and as a
result bump `switch` to 0xe6.

Redefine the execution semantics of `resume_throw` in terms of
`resume_throw_ref`.

As a drive-by, fix the nullability of reference operands in the initial
introduction of each other instruction.
@tlively tlively requested a review from fgmccabe October 8, 2025 23:05

@rossberg rossberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo nits

Comment thread proposals/stack-switching/Explainer.md Outdated
aborted with `resume_throw`; directly switched to via `switch`; or
partially applied with `cont.bind`.
There are five different ways in which suspended continuations are
consumed (`resume,resume_throw,resume_throw_ref,switch,cont.bind`).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, while here:

Suggested change
consumed (`resume,resume_throw,resume_throw_ref,switch,cont.bind`).
consumed (`resume`, `resume_throw`, `resume_throw_ref`, `switch`, `cont.bind`).

- iff `S.conts[ca] = epsilon`

* `S; F; v^m (ref.cont ca) (resume_throw $ct $e hdl*) --> S''; F; prompt{hdl'*} E[(ref.exn |S'.exns|) throw_ref] end`
* `S; F; (ref.null t) (ref.cont ca) (resume_throw_ref $ct hdl*) --> S; F; trap`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the rules non-overlapping:

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

@titzer

titzer commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

Can you bump the opcode in the implementation in this PR, too?

The numbering will break in coordinating between tools that do use switch, but we should probably do that as early as possible.

@tlively tlively merged commit 9579cb9 into main Oct 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants