Skip to content

Typed continuations: cont.bind instructions #6365

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

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

frank-emrich
Copy link
Contributor

This PR is part of a series that adds basic support for the typed continuations/wasmfx proposal.

This particular PR adds support for the cont.bind instruction for partially applying continuations, documented here.

In short, these instructions are of the form (cont.bind $ct_before $ct_after) where $ct_before and $ct_after are related continuation types. They must only differ in the number of arguments, where $ct_before has n additional parameters as compared to $ct_after, for some n ≥ 0.
The idea is that (cont.bind $ct_before $ct_after) then takes a reference to a continuation of type $ct_before as well as n operands and returns a (reference to a) continuation of type $ct_after.
Thus, the folded textual representation looks like (cont.bind $ct_before $ct_after arg1 ... argn c).

Support for the instruction is implemented in both the old and the new wat parser.

Note that this PR does not implement validation of the new instruction.

@tlively tlively self-requested a review March 1, 2024 05:31
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.

LGTM with those underflow checks 👍

curr->contTypeBefore.getContinuation().type.getSignature().params.size();
size_t paramsAfter =
curr->contTypeAfter.getContinuation().type.getSignature().params.size();
size_t numArgs = paramsBefore - paramsAfter;
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to ensure that this doesn't underflow.

curr->contTypeBefore.getContinuation().type.getSignature().params.size();
size_t paramsAfter =
curr->contTypeAfter.getContinuation().type.getSignature().params.size();
size_t numArgs = paramsBefore - paramsAfter;
Copy link
Member

Choose a reason for hiding this comment

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

Same here about the underflow.

@frank-emrich
Copy link
Contributor Author

Thanks! Should be all done now.

@tlively tlively merged commit 88108ef into WebAssembly:main Mar 4, 2024
@gkdn gkdn mentioned this pull request Aug 31, 2024
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.

2 participants