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.
This commit is contained in:
Ayke van Laethem
2019-08-15 15:52:26 +02:00
committed by Ron Evans
parent e4fc3bb66a
commit bbc3046687
6 changed files with 238 additions and 131 deletions
+7 -2
View File
@@ -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")
}
}