Skip to content

Commit d13caa4

Browse files
committed
Add cooperative threads
1 parent e53dc73 commit d13caa4

File tree

9 files changed

+2427
-1614
lines changed

9 files changed

+2427
-1614
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ reference interpreter and test suite.
1515

1616
The Component Model is currently being incrementally developed and stabilized
1717
as part of [WASI Preview 2]. The subsequent [WASI Preview 3] milestone will be
18-
primarily concerned with the addition of [async support][Concurrency Model].
18+
primarily concerned with the addition of [async and thread support][Concurrency
19+
Model].
1920

2021
## Contributing
2122

@@ -32,11 +33,10 @@ To contribute to any of these repositories, see the Community Group's
3233
[IDL]: design/mvp/WIT.md
3334
[Text Format]: design/mvp/Explainer.md
3435
[Binary Format]: design/mvp/Binary.md
35-
[Concurrency Model]: design/mvp/Async.md
36+
[Concurrency Model]: design/mvp/Concurrency.md
3637
[Canonical ABI]: design/mvp/CanonicalABI.md
3738
[formal spec]: spec/
3839
[W3C WebAssembly Community Group]: https://www.w3.org/community/webassembly/
3940
[Contributing Guidelines]: https://webassembly.org/community/contributing/
4041
[WASI Preview 2]: https://github.com/WebAssembly/WASI/tree/main/wasip2#readme
4142
[WASI Preview 3]: https://github.com/WebAssembly/WASI/tree/main/wasip2#looking-forward-to-preview-3
42-
[Async Support]: https://docs.google.com/presentation/d/1MNVOZ8hdofO3tI0szg_i-Yoy0N2QPU2C--LzVuoGSlE/edit?usp=share_link

design/mvp/Binary.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ canon ::= 0x00 0x00 f:<core:funcidx> opts:<opts> ft:<typeidx> => (canon lift
297297
| 0x05 => (canon task.cancel (core func)) 🔀
298298
| 0x0a 0x7f i:<u32> => (canon context.get i32 i (core func)) 🔀
299299
| 0x0b 0x7f i:<u32> => (canon context.set i32 i (core func)) 🔀
300-
| 0x0c cancel?:<cancel?> => (canon yield cancel? (core func)) 🔀
300+
| 0x0c cancel?:<cancel?> => (canon thread.yield cancel? (core func)) 🔀
301301
| 0x06 async?:<async?> => (canon subtask.cancel async? (core func)) 🔀
302302
| 0x0d => (canon subtask.drop (core func)) 🔀
303303
| 0x0e t:<typeidx> => (canon stream.new t (core func)) 🔀
@@ -322,13 +322,21 @@ canon ::= 0x00 0x00 f:<core:funcidx> opts:<opts> ft:<typeidx> => (canon lift
322322
| 0x21 cancel?:<cancel?> m:<core:memidx> => (canon waitable-set.poll cancel? (memory m) (core func)) 🔀
323323
| 0x22 => (canon waitable-set.drop (core func)) 🔀
324324
| 0x23 => (canon waitable.join (core func)) 🔀
325-
| 0x40 ft:<typeidx> => (canon thread.spawn_ref ft (core func)) 🧵
326-
| 0x41 ft:<typeidx> tbl:<core:tableidx> => (canon thread.spawn_indirect ft tbl (core func)) 🧵
327-
| 0x42 => (canon thread.available_parallelism (core func)) 🧵
325+
| 0x26 => (canon thread.index (core func)) 🧵
326+
| 0x27 ft:<typeidx> tbl:<core:tableidx> => (canon thread.new_indirect ft tbl (core func)) 🧵
327+
| 0x28 cancel?:<cancel?> => (canon thread.switch-to cancel? (core func)) 🧵
328+
| 0x29 cancel?:<cancel?> => (canon thread.suspend cancel? (core func)) 🧵
329+
| 0x2a => (canon thread.resume-later (core func)) 🧵
330+
| 0x2b cancel?:<cancel?> => (canon thread.yield-to cancel? (core func)) 🧵
331+
| 0x40 shared?:<sh?> ft:<typeidx> => (canon thread.spawn_ref shared? ft (core func)) 🧵②
332+
| 0x41 shared?:<sh?> ft:<typeidx> tbl:<core:tableidx> => (canon thread.spawn_indirect shared? ft tbl (core func)) 🧵②
333+
| 0x42 shared?:<sh?> => (canon thread.available-parallelism shared? (core func)) 🧵②
328334
async? ::= 0x00 =>
329335
| 0x01 => async
330336
cancel? ::= 0x00 =>
331337
| 0x01 => cancellable 🚟
338+
sh? ::= 0x00 =>
339+
| 0x01 => shared 🧵②
332340
opts ::= opt*:vec(<canonopt>) => opt*
333341
canonopt ::= 0x00 => string-encoding=utf8
334342
| 0x01 => string-encoding=utf16
@@ -512,6 +520,8 @@ named once.
512520
repurposed.
513521
* Most built-ins should have a `<canonopt>*` immediate instead of an ad hoc
514522
subset of `canonopt`s.
523+
* Add optional `shared` immediate to all canonical definitions (explicitly or
524+
via `<canonopt>`) when shared-everything-threads (🧵②) is added.
515525

516526

517527
[`core:byte`]: https://webassembly.github.io/spec/core/binary/values.html#binary-byte

0 commit comments

Comments
 (0)