runtime, builder: WebAssembly reactor mode #4082
Closed
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 is an initial attempt at enabling reactor mode for WebAssembly programs, where the host can repeatedly call into the guest Wasm program via functions exported with
//go:wasmexport
.The entrypoint for a WebAssembly reactor module is
_initialize
instead of_start
.Assuming that the WebAssembly runtime is not reentrant (e.g. not threaded), then this works if the //go:wasmexport calls are detected and wrapped in a function that starts the Go scheduler.
When the exported function ends, all other goroutines are paused.
Goroutines started in a global init() function will run while the host has called into the guest. They are paused when the guest call returns and restarted on the next call.
TODO: figure out how to enable reactor mode:
TODO: figure out how and where best to wrap
//go:wasmexport
calls.TODO: figure out how this works with
-scheduler none
Fixes #2735.