Motivation
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- wasm
- Domain
- compilers
Research direction
Start with the issue's Motivation section and the linked LLVM Coroutines documentation. Review how the proposal distinguishes compiler transformations for async/await and generators from stack switching for green threads. Done means the proposal's motivation and scope clearly reflect the intended use case.
Written by the indexing model from the issue text.
Description
At the moment, the overview gives these goals:
Motivation
- Support for Asynch/await programming pattern.
- Support for green threads.
- Support for yield-style generators.
Of these, only green threads require any changes to WebAssembly:
- Async/await programming can relatively easily be implemented in the compiler. In particular, LLVM has implemented it as a series of passes, which you can read about here. In my experience, this works really well even in WebAssembly because after the passes have done their work, the code is converted to a form that looks like hand-written async code. No special features from the instruction set are required for this to work: the only requirement is the ability to call a function pointer.
- Yield-style generators are actually very similar to async/await and can also be implemented as a compiler pass. LLVM supports them using the same coroutine passes. Again, no special features are required from the instruction set.
While I've only mentioned LLVM above, other compilers do something similar. I believe Rust has a separate implementation of async/await (it doesn't appear to use LLVM coroutines). But an easier way to understand why async/await and yield-style generators do not need WebAssembly support is by realizing that they can all be implemented manually, by hand. And if it can be written by hand, a compiler can perform that transformation for you as a compiler pass.
What cannot be written by hand is stack switching. In particular, this is a problem in Go which uses stack switching extensively for goroutines (every blocking operation potentially results in a stack switch).
Therefore, I would propose that this proposal only focuses on the green threads use case, that requires stack switching (as evident from the name: stack-switching). Of course you could potentially use stack switching for async/await and yield-style generators, but I do not think we should focus on them as there are already ways to efficiently support them in WebAssembly.
- Dominant language
- WebAssembly
- Stars
- 216
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WebAssembly/stack-switching
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WebAssembly/stack-switching#156 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WebAssembly/stack-switching#145 · 4 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WebAssembly/stack-switching#144 · 4 comments ·
-
JSPI integration Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
WebAssembly/stack-switching#131 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
WebAssembly/stack-switching#128 · 6 comments ·
All issues in WebAssembly/stack-switching
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
oxc-project/oxc#26944 ·
-
todo:perf
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
bug
Difficulty 2/5 Half a day Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tenstorrent/tt-metal#57393 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
objectionary/eo#8894 ·