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

Embedding API changes #77

Open
tlively opened this issue Aug 28, 2024 · 0 comments
Open

Embedding API changes #77

tlively opened this issue Aug 28, 2024 · 0 comments

Comments

@tlively
Copy link
Member

tlively commented Aug 28, 2024

It would be good to update the explainer with a sketch of how we expect the embedding API given in the appendix to be extended.

Taking inspiration from how the embedding API is extended for exception handling, we can add a new kind of result from func_invoke, SUSPEND a, where a is a continuation address. We can also add a new function cont_resume that behaves exactly like func_invoke, except that it takes a continuation address instead of a function address. Finally, we can allow host functions to result in suspensions, just like we allow them to result in throws. The suspensions need to be able to carry payloads and need to record the types of the parameters necessary to resume the suspending continuation.

This set of changes are sufficient to allow the JS API spec to specify that an error should be thrown when calling an export results in SUSPEND a. It is also sufficient to specify JSPI in terms of core stack switching by having JSPI suspending import wrappers return suspensions to Wasm carrying the suspending promises as payloads and having JSPI promising export wrappers call func_invoke, receive SUSPEND a, then schedule the future resumption of the continuation via cont_resume once the extracted suspending promise is resolved.

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

No branches or pull requests

1 participant