Skip to content

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