Skip to content
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

Reference interpreter #84

Merged
merged 187 commits into from
Oct 16, 2024
Merged

Reference interpreter #84

merged 187 commits into from
Oct 16, 2024

Conversation

dhil
Copy link
Member

@dhil dhil commented Aug 30, 2024

This patch adds a reference interpreter for the stack switching proposal. It implements all of the proposed instructions.

The patch also includes many updates from WebAssembly/spec, WebAssembly/function-references, WebAssembly/exception-handling, and WebAssembly/gc.

The contents of this patch are comprised of multiple smaller patches which have already been reviewed by @rossberg -- though, if you are keen please take a look.

dhil and others added 30 commits February 15, 2021 15:56
This patch extends the interpreter with a minimal exception handling
facility. It is minimal in the sense that it supports only a single
exception which can be thrown and caught.
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
The opcodes for try/catch/throw are taken from the provisional
exception-handling proposal.
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Minimal exception handling extension
Add cont type and instructions
The evaluator erroneously rewrote `resume_throw $x $y (on ..)` into
`Plain (Throw $x)`; but `$x` is a type index, not a tag
index. However, rewriting it to `Throw $y` is not correct either, as
the throw may be injected into another instance, where `$y` may be
absent. Therefore, we rewrite it into an administrative instruction
`Throwing (tag_instance, args)` instead such that the tag is fully
resolved by before being injected into the continuation.
dhil added a commit that referenced this pull request Sep 24, 2024
There is a small inconsistency between the reference implementation in #84 and the explainer. In the explainer we write that the type index `$ft` on `cont $ft` should be encoded as an `u32` in the binary format. However, the reference interpreter actually encodes it as `s33`, similarly to how concrete heap types are encoded.

I do not have a strong preference for either encoding, but I suppose one can argue that the `s33` approach is more forward compatible in the sense that we can encode additional metadata.
@dhil
Copy link
Member Author

dhil commented Sep 25, 2024

Following on from the discussion we had Monday, I've removed the barrier instruction from the reference interpreter.

@dhil dhil mentioned this pull request Sep 25, 2024
@dhil
Copy link
Member Author

dhil commented Sep 25, 2024

This is ready for review / to be merged once #90 has been merged.

@slindley slindley removed the request for review from fgmccabe September 28, 2024 15:54
@dhil
Copy link
Member Author

dhil commented Sep 29, 2024

@tlively and @slindley this patch is ready for review now. PTAL. The patch includes some updates to the legacy proposal documents. I think these should be consolidated under stack-switching/ along side the legacy bag-o-stacks documents (if we decide to keep any of these documents around). But I think that is for another patch.

Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

🎉

(mostly rubberstamp)

Copy link
Collaborator

@slindley slindley left a comment

Choose a reason for hiding this comment

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

LGTM

@slindley slindley merged commit b86490c into main Oct 16, 2024
9 checks passed
dhil added a commit that referenced this pull request Oct 22, 2024
There is a small inconsistency between the reference implementation in #84 and the explainer. In the explainer we write that the type index `$ft` on `cont $ft` should be encoded as an `u32` in the binary format. However, the reference interpreter actually encodes it as `s33`, similarly to how concrete heap types are encoded.
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.

8 participants