-
Notifications
You must be signed in to change notification settings - Fork 857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite goroutines, add support for channels #130
Conversation
eec5740
to
61b376e
Compare
Note: I've found at least one bug, so this PR is not ready yet. |
750cab8
to
a8acd59
Compare
d0f2648
to
9a231cf
Compare
I think it is now ready for merging. The bug I mentioned should be fixed, and wasm output that doesn't need a scheduler is the same size as before. |
9a231cf
to
ab25a1f
Compare
The bug wasn't entirely fixed :( need to work on that a bit more. I measured the channel implementation with a quick benchmark and it's only 1.5x slower than with the main Go compiler. I think that's great. It may be possible to improve it even more if needed. |
Please let me know when this feature is ready for testing after whatever further changes are needed. |
b6ff24b
to
b00009f
Compare
I think I finally figured out the bug and fixed it, so this PR is ready for review. |
@deadprogram can you maybe take a look? |
I was unable to build this version:
Is there some updated dependency I am missing? |
Yes, go-llvm has been updated to add this function. |
Tested with the Tested on the SAMD21 and it locks each Go routine on the |
Apparently the given code path was never properly tested.
This was an oversight in commit 107fccb.
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.
Support for channels is not complete. The following pieces are missing: * Channels with values bigger than int. An int in TinyGo can always contain at least a pointer, so pointers are okay to send. * Buffered channels. * The select statement.
b00009f
to
2e4dd09
Compare
I needed to apply a small change to runtime_atsamd21.go that may have been the cause. Let's see what Travis CI thinks now. |
I guess that means it can be merged? |
This PR increases the amount of code, but makes goroutine lowering more independent of the compiler which makes it somewhat easier to maintain.