-
Notifications
You must be signed in to change notification settings - Fork 312
wit-dylib: Initial skeleton of async support #2317
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
alexcrichton
merged 14 commits into
bytecodealliance:main
from
alexcrichton:wit-dylib-async
Sep 29, 2025
Merged
wit-dylib: Initial skeleton of async support #2317
alexcrichton
merged 14 commits into
bytecodealliance:main
from
alexcrichton:wit-dylib-async
Sep 29, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit starts to fill out the support for async in `wit-dylib`. In doing so this has filled out a number of pieces of functionality elsewhere and implemented more thorough testing. As a result of this some issues were discovered which are also fixed in this PR. Notable changes are: * Naming of the `task-return` intrinsic is now in a helper in `wit-parser` to avoid needing to duplicate that elsewhere. * A new `roundtrip` test was added to `wit-dylib` which generates arbitrary WITs and arbitrary values for the WIT and ensures that the values are communicated successfully. * Composition code shared between the `all` and `roundtrip` tests was moved to the `artifacts` crate as a shared dependency of the two. * In-memory data structures for `wit_func_t` are updated to reflect async support. * Deferred deallocation of bytes is pushed as a responsibility to the embedder. Storing values on the stack was getting too tricky and felt like a too-clever-by-half implementation. To simplify the generated code the responsibility is now on the `wit_dylib_*` implementor to deallocate bytes in a deferred fashion. * The `wit-bindgen` crate is a dependency of `wit-dylib-ffi`, the guest bindings of `wit_dylib.h`, for async support. * The `wasm-tools wit-dylib` subcommand now has configuration, in the same manner as `wit-bindgen` for which functions should be async and which should be sync. * The `with_temp_stack` helper was removed as that was also getting too tricky to manage and instead functions just always allocate some temporary space. * Existing bindings were updated for async functions when that ABI is selected, and new bindings were added for various intrinsics related to the lifecycle of async imports/exports. Perhaps the biggest feature in this commit is the addition of the `roundtrip` test which is hoped to provide a much more thorough implementation of testing this crate. Notably it generates an arbitrary WIT structure *and additionally* generates arbitrary values of this structure. This has weeded out a number of bugs in the bindings generator and necessitated various refactorings here. This is intended to be a crucial part of making this a solid dependency to build on.
Member
Author
|
Draft for now until bytecodealliance/wit-bindgen#1390 is merged |
dicej
approved these changes
Sep 29, 2025
Collaborator
dicej
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once again, I've only skimmed this, but looks reasonable to me.
Co-authored-by: Joel Dice <joel.dice@fermyon.com>
Co-authored-by: Joel Dice <joel.dice@fermyon.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit starts to fill out the support for async in
wit-dylib. In doing so this has filled out a number of pieces of functionality elsewhere and implemented more thorough testing. As a result of this some issues were discovered which are also fixed in this PR. Notable changes are:task-returnintrinsic is now in a helper inwit-parserto avoid needing to duplicate that elsewhere.roundtriptest was added towit-dylibwhich generates arbitrary WITs and arbitrary values for the WIT and ensures that the values are communicated successfully.allandroundtriptests was moved to theartifactscrate as a shared dependency of the two.wit_func_tare updated to reflect async support.wit_dylib_*implementor to deallocate bytes in a deferred fashion.wit-bindgencrate is a dependency ofwit-dylib-ffi, the guest bindings ofwit_dylib.h, for async support.wasm-tools wit-dylibsubcommand now has configuration, in the same manner aswit-bindgenfor which functions should be async and which should be sync.with_temp_stackhelper was removed as that was also getting too tricky to manage and instead functions just always allocate some temporary space.Perhaps the biggest feature in this commit is the addition of the
roundtriptest which is hoped to provide a much more thorough implementation of testing this crate. Notably it generates an arbitrary WIT structure and additionally generates arbitrary values of this structure. This has weeded out a number of bugs in the bindings generator and necessitated various refactorings here. This is intended to be a crucial part of making this a solid dependency to build on.