wit-dylib: Initial skeleton of async support by alexcrichton · Pull Request #2317 · bytecodealliance/wasm-tools
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.
changed the title
Initial skeleton of async support
wit-dylib: Initial skeleton of async support
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