all: rewrite goroutine lowering

Before this commit, goroutine support was spread through the compiler.
This commit changes this support, so that the compiler itself only
generates simple intrinsics and leaves the real support to a compiler
pass that runs as one of the TinyGo-specific optimization passes.

The biggest change, that was done together with the rewrite, was support
for goroutines in WebAssembly for JavaScript. The challenge in
JavaScript is that in general no blocking operations are allowed, which
means that programs that call time.Sleep() but do not start goroutines
also have to be scheduled by the scheduler.
This commit is contained in:
Ayke van Laethem
2019-01-10 16:54:09 +01:00
parent 072ef603fe
commit 602c264749
24 changed files with 807 additions and 483 deletions
+5 -5
View File
@@ -10,8 +10,8 @@ const Compiler = "tgo"
// package.
func initAll()
// The compiler will insert the call to main.main() here, depending on whether
// the scheduler is necessary.
// A function call to this function is replaced withone of the following,
// depending on whether the scheduler is necessary:
//
// Without scheduler:
//
@@ -19,9 +19,9 @@ func initAll()
//
// With scheduler:
//
// coroutine := main.main(nil)
// scheduler(coroutine)
func mainWrapper()
// main.main()
// scheduler()
func callMain()
func GOMAXPROCS(n int) int {
// Note: setting GOMAXPROCS is ignored.