Skip to content

Commit 6ad3817

Browse files
committed
Add cooperative threads
1 parent 1bbf0e2 commit 6ad3817

File tree

9 files changed

+2464
-1672
lines changed

9 files changed

+2464
-1672
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 [native concurrency
19+
support][concurrency 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: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ label' ::= len:<u32> l:<label> => l (if len = |l|)
214214
valtype ::= i:<typeidx> => i
215215
| pvt:<primvaltype> => pvt
216216
resourcetype ::= 0x3f 0x7f f?:<funcidx>? => (resource (rep i32) (dtor f)?)
217-
| 0x3e 0x7f f:<funcidx> cb?:<funcidx>? => (resource (rep i32) (dtor async f (callback cb)?)) 🚝
217+
| 0x3e 0x7f f:<funcidx> cb?:<funcidx>? => (resource (rep i32) (dtor async f (callback cb)?)) 🧵
218218
functype ::= 0x40 ps:<paramlist> rs:<resultlist> => (func ps rs)
219219
paramlist ::= lt*:vec(<labelvaltype>) => (param lt)*
220220
resultlist ::= 0x00 t:<valtype> => (result t)
@@ -288,14 +288,13 @@ canon ::= 0x00 0x00 f:<core:funcidx> opts:<opts> ft:<typeidx> => (canon lift
288288
| 0x01 0x00 f:<funcidx> opts:<opts> => (canon lower f opts (core func))
289289
| 0x02 rt:<typeidx> => (canon resource.new rt (core func))
290290
| 0x03 rt:<typeidx> => (canon resource.drop rt (core func))
291-
| 0x07 rt:<typeidx> => (canon resource.drop rt async (core func)) 🚝
291+
| 0x07 rt:<typeidx> => (canon resource.drop rt async (core func)) 🧵
292292
| 0x04 rt:<typeidx> => (canon resource.rep rt (core func))
293293
| 0x08 => (canon backpressure.set (core func)) 🔀
294294
| 0x09 rs:<resultlist> opts:<opts> => (canon task.return rs opts (core func)) 🔀
295295
| 0x05 => (canon task.cancel (core func)) 🔀
296296
| 0x0a 0x7f i:<u32> => (canon context.get i32 i (core func)) 🔀
297297
| 0x0b 0x7f i:<u32> => (canon context.set i32 i (core func)) 🔀
298-
| 0x0c cancel?:<cancel?> => (canon yield cancel? (core func)) 🔀
299298
| 0x06 async?:<async?> => (canon subtask.cancel async? (core func)) 🔀
300299
| 0x0d => (canon subtask.drop (core func)) 🔀
301300
| 0x0e t:<typeidx> => (canon stream.new t (core func)) 🔀
@@ -320,13 +319,22 @@ canon ::= 0x00 0x00 f:<core:funcidx> opts:<opts> ft:<typeidx> => (canon lift
320319
| 0x21 cancel?:<cancel?> m:<core:memidx> => (canon waitable-set.poll cancel? (memory m) (core func)) 🔀
321320
| 0x22 => (canon waitable-set.drop (core func)) 🔀
322321
| 0x23 => (canon waitable.join (core func)) 🔀
323-
| 0x40 ft:<typeidx> => (canon thread.spawn_ref ft (core func)) 🧵
324-
| 0x41 ft:<typeidx> tbl:<core:tableidx> => (canon thread.spawn_indirect ft tbl (core func)) 🧵
325-
| 0x42 => (canon thread.available_parallelism (core func)) 🧵
322+
| 0x24 => (canon thread.index (core func)) 🧵
323+
| 0x25 ft:<typeidx> tbl:<core:tableidx> => (canon thread.new_indirect ft tbl (core func)) 🧵
324+
| 0x26 cancel?:<cancel?> => (canon thread.switch-to cancel? (core func)) 🧵
325+
| 0x27 cancel?:<cancel?> => (canon thread.suspend cancel? (core func)) 🧵
326+
| 0x28 => (canon thread.resume-later (core func)) 🧵
327+
| 0x29 cancel?:<cancel?> => (canon thread.yield-to cancel? (core func)) 🧵
328+
| 0x0c cancel?:<cancel?> => (canon thread.yield cancel? (core func)) 🔀
329+
| 0x40 shared?:<sh?> ft:<typeidx> => (canon thread.spawn_ref shared? ft (core func)) 🧵②
330+
| 0x41 shared?:<sh?> ft:<typeidx> tbl:<core:tableidx> => (canon thread.spawn_indirect shared? ft tbl (core func)) 🧵②
331+
| 0x42 shared?:<sh?> => (canon thread.available-parallelism shared? (core func)) 🧵②
326332
async? ::= 0x00 =>
327333
| 0x01 => async
328334
cancel? ::= 0x00 =>
329-
| 0x01 => cancellable 🚟
335+
| 0x01 => cancellable 🧵
336+
sh? ::= 0x00 =>
337+
| 0x01 => shared 🧵②
330338
opts ::= opt*:vec(<canonopt>) => opt*
331339
canonopt ::= 0x00 => string-encoding=utf8
332340
| 0x01 => string-encoding=utf16
@@ -509,6 +517,8 @@ named once.
509517
repurposed.
510518
* Most built-ins should have a `<canonopt>*` immediate instead of an ad hoc
511519
subset of `canonopt`s.
520+
* Add optional `shared` immediate to all canonical definitions (explicitly or
521+
via `<canonopt>`) when shared-everything-threads (🧵②) is added.
512522

513523

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

0 commit comments

Comments
 (0)