Repository navigation
Conversation
Add an option that makes async exports stackful. The generated code uses the [async-lift-stackful] name, does not export a [callback] function and returns nothing from the wrapper, since the result goes through task.return. This is for runtimes that can block a thread, such as TinyGo with cooperative threads. In the core ABI, lower a result to memory for stackful exports the same way as for the other export variants. This replaces a todo.
This branch has not been deployed
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
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.
Adds
--stackful-exportsto the Go generator. With it, async exports use the[async-lift-stackful]ABI instead of callback-based[async-lift]:[async-lift-stackful]<name>and no[callback]function is exported,witAsync.Run(func() { ... })and returns nothing, since the result is delivered viatask.return.This is for runtimes that can block a thread inside an export, such as TinyGo's wasip3 target with cooperative threads. The default output is unchanged.
In
crates/core/src/abi.rs,AbiVariant::GuestExportAsyncStackfulnow lowers a result to memory like the other guest-export variants, replacing atodo!("stackful exports are not yet supported").Dependencies
Needs the TinyGo implementation of
wit/asyncfrom bytecodealliance/go-pkg#19 at runtime. This PR doesn't bump thecrates/go/src/pkgsubmodule; that should follow once go-pkg#19 lands.Testing
Generated bindings for a
wasi:http/handlerworld with--stackful-exports --generate-stubs, built with TinyGo's wasip3 target, and ran the component under wasmtime (async import, streamed bodies, overlapping requests).I haven't added a codegen test in
tests/yet. Happy to add one if you can point me at the preferred place for an option-specific Go test.