diff options
author | Nia Waldvogel <[email protected]> | 2021-07-21 14:30:01 -0400 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-11-14 10:49:28 +0100 |
commit | 641dcd7c16d60a53faf8b61b509057830441a765 (patch) | |
tree | 2db29ae018645871178727e8c355bc69b24db796 /transform/optimizer.go | |
parent | 523d1f28cf31ebd398093636b915bbcb3dcd93d5 (diff) | |
download | tinygo-641dcd7c16d60a53faf8b61b509057830441a765.tar.gz tinygo-641dcd7c16d60a53faf8b61b509057830441a765.zip |
internal/task: use asyncify on webassembly
This change implements a new "scheduler" for WebAssembly using binaryen's asyncify transform.
This is more reliable than the current "coroutines" transform, and works with non-Go code in the call stack.
runtime (js/wasm): handle scheduler nesting
If WASM calls into JS which calls back into WASM, it is possible for the scheduler to nest.
The event from the callback must be handled immediately, so the task cannot simply be deferred to the outer scheduler.
This creates a minimal scheduler loop which is used to handle such nesting.
Diffstat (limited to 'transform/optimizer.go')
-rw-r--r-- | transform/optimizer.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/transform/optimizer.go b/transform/optimizer.go index bd6d21687..64c3d0b54 100644 --- a/transform/optimizer.go +++ b/transform/optimizer.go @@ -125,7 +125,7 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i if err != nil { return []error{err} } - case "tasks": + case "tasks", "asyncify": // No transformations necessary. case "none": // Check for any goroutine starts. @@ -219,7 +219,7 @@ func getFunctionsUsedInTransforms(config *compileopts.Config) []string { case "none": case "coroutines": fnused = append(append([]string{}, fnused...), coroFunctionsUsedInTransforms...) - case "tasks": + case "tasks", "asyncify": fnused = append(append([]string{}, fnused...), taskFunctionsUsedInTransforms...) default: panic(fmt.Errorf("invalid scheduler %q", config.Scheduler())) |