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

More refactoring/reshuffling of component async intrinsics #2064

Merged

Conversation

alexcrichton
Copy link
Member

As I continue to grapple with wit-component, task.return, and the addition of canonical options I've continued to find more locations which I'd like to refactor/improve related to how async intrinsics are handled. This is a series of a few minor refactorings leading up to a more major refactoring which changes the names of imported intrinsics. The end goal is to make all intrinsics "look more alike" to one another in terms of how they're detected/processed and avoid having two distinct paths for async and not-async.

The final commit here is the meat of this PR which shuffles around where intrinsics are validated and how they're processed and additionally renames the imports that generate intrinsics. I've attempted to otherwise split this by commit in terms of logical units and additionally document each commit itself.

Simplify some callers/accessors by plumbing around this whole structure
instead of having some intrinsics just have portions where others have more.
Refactor some internals of async stream/future read/write and
`task.return` to avoid passing `Function` and instead just pass then
name around.
Don't so heavily nest the variables here indentation-wise.
This commit refactors the integration of async intrinsics into
wit-component to support future changes to the `task.return` intrinsic.
The refactoring here moves detection of intrinsics to all be in the same
path rather than having one path which handles async intrinsics, another
patch which handles resource intrinsics, and another path which handles
`task.return` intrinsics. By handling everything in one location it's
easier to ensure that everything is handled uniformly and various bits
and pieces of contextual information are also easily available.

This refactoring additionally updates the names recognized for async
intrinsics. Previously for example async imports might use
`[import-payload]` which is now no longer required. Additionally async
imports might use `[export-payload]` too and that's changed to be
`[export]` to match how other exports are handled as well.
@alexcrichton alexcrichton added this pull request to the merge queue Feb 24, 2025
Merged via the queue into bytecodealliance:main with commit fc75d9b Feb 24, 2025
31 checks passed
@alexcrichton alexcrichton deleted the component-intrinsic-refactor branch February 24, 2025 18:31
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