WebAssembly / WebAssembly/threads
Why should it be implemented this way?
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 767
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
Looking at the proposal for threading support in wasm, I'm a bit confused. It seems to me like, since it's been decided for some reason to have threads be separate instances of the same module, that much of the proposal is patching over that. For example, conditional initialization is just a fix for something inherently broken in design.
Why not have threads in webassembly be similar to threads in a more familiar setting. Add a few instructions:
thread.createwhich takes a table index, an index into that table, and ani32argument and returns a thread id (ani32).thread.joinwhich takes a thread id as an argument and blocks until the specified thread finishes.thread.exitwhich exits the current thread.
An example of using this api would be like this:
(module
(func $make_thread
(thread.join
(thread.create
(i32.const 0) // table index
(i32.const 0) // index into that table
(i32.const 42) // arg to pass to thread
)
)
)
(func $thread_entry (param $arg i32))
(table 1 anyfunc)
(elem (i32.const 0) $thread_entry)
(start $make_thread)
)
This proposed api would not need conditional initialization or shared memories. It would be easy to understand and simple to implement.
There could be more thread. instructions, these are just examples of the most basic way it could work.
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.
Research direction
Start by reading the WebAssembly threads proposal and the issue discussion, focusing on the separate-instance model, conditional initialization, and shared memories. Compare those design choices with the proposed thread.create, thread.join, and thread.exit instructions; done would require a decided architectural direction, not a localized code change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100