aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler/func.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2019-08-15 15:52:26 +0200
committerRon Evans <[email protected]>2019-08-17 11:51:43 +0200
commitbbc3046687ffa5bc166cb15a2bc1149192f6f203 (patch)
treeeee541f76066c9b027fd5133ef06842959bb3ae9 /compiler/func.go
parente4fc3bb66a6185f33fce3fcc5128e2996209080b (diff)
downloadtinygo-bbc3046687ffa5bc166cb15a2bc1149192f6f203.tar.gz
tinygo-bbc3046687ffa5bc166cb15a2bc1149192f6f203.zip
compiler: add support for 'go' on func values
This commit allows starting a new goroutine directly from a func value, not just when the static callee is known. This is necessary to support the whole time package, not just the commonly used subset that was compiled with the SimpleDCE pass enabled.
Diffstat (limited to 'compiler/func.go')
-rw-r--r--compiler/func.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/func.go b/compiler/func.go
index d9879d748..df364b130 100644
--- a/compiler/func.go
+++ b/compiler/func.go
@@ -32,10 +32,15 @@ const (
// funcImplementation picks an appropriate func value implementation for the
// target.
func (c *Compiler) funcImplementation() funcValueImplementation {
- if c.GOARCH == "wasm" {
+ // Always pick the switch implementation, as it allows the use of blocking
+ // inside a function that is used as a func value.
+ switch c.selectScheduler() {
+ case "coroutines":
return funcValueSwitch
- } else {
+ case "tasks":
return funcValueDoubleword
+ default:
+ panic("unknown scheduler type")
}
}