Skip to content

Commit ed97e7b

Browse files
committed
Switch _ to - in thread.{new-indirect,spawn-indirect,spawn-ref}
1 parent ba2619b commit ed97e7b

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

design/mvp/Binary.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,13 @@ canon ::= 0x00 0x00 f:<core:funcidx> opts:<opts> ft:<typeidx> => (canon lift
323323
| 0x22 => (canon waitable-set.drop (core func)) 🔀
324324
| 0x23 => (canon waitable.join (core func)) 🔀
325325
| 0x26 => (canon thread.index (core func)) 🧵
326-
| 0x27 ft:<typeidx> tbl:<core:tableidx> => (canon thread.new_indirect ft tbl (core func)) 🧵
326+
| 0x27 ft:<typeidx> tbl:<core:tableidx> => (canon thread.new-indirect ft tbl (core func)) 🧵
327327
| 0x28 cancel?:<cancel?> => (canon thread.switch-to cancel? (core func)) 🧵
328328
| 0x29 cancel?:<cancel?> => (canon thread.suspend cancel? (core func)) 🧵
329329
| 0x2a => (canon thread.resume-later (core func)) 🧵
330330
| 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)) 🧵②
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)) 🧵②
333333
| 0x42 shared?:<sh?> => (canon thread.available-parallelism shared? (core func)) 🧵②
334334
async? ::= 0x00 =>
335335
| 0x01 => async

design/mvp/CanonicalABI.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ specified here.
5959
* [`canon {stream,future}.cancel-{read,write}`](#-canon-streamfuturecancel-readwrite) 🔀
6060
* [`canon {stream,future}.drop-{readable,writable}`](#-canon-streamfuturedrop-readablewritable) 🔀
6161
* [`canon thread.index`](#-canon-threadindex) 🧵
62-
* [`canon thread.new_indirect`](#-canon-threadnew_indirect) 🧵
62+
* [`canon thread.new-indirect`](#-canon-threadnew-indirect) 🧵
6363
* [`canon thread.switch-to`](#-canon-threadswitch-to) 🧵
6464
* [`canon thread.suspend`](#-canon-threadsuspend) 🧵
6565
* [`canon thread.resume-later`](#-canon-threadresume-later) 🧵
@@ -68,8 +68,8 @@ specified here.
6868
* [`canon error-context.new`](#-canon-error-contextnew) 📝
6969
* [`canon error-context.debug-message`](#-canon-error-contextdebug-message) 📝
7070
* [`canon error-context.drop`](#-canon-error-contextdrop) 📝
71-
* [`canon thread.spawn_ref`](#-canon-threadspawn_ref) 🧵②
72-
* [`canon thread.spawn_indirect`](#-canon-threadspawn_indirect) 🧵②
71+
* [`canon thread.spawn-ref`](#-canon-threadspawn-ref) 🧵②
72+
* [`canon thread.spawn-indirect`](#-canon-threadspawn-indirect) 🧵②
7373
* [`canon thread.available-parallelism`](#-canon-threadavailable-parallelism) 🧵②
7474

7575
## Introduction
@@ -422,7 +422,7 @@ class ResourceType(Type):
422422

423423
As described in the [concurrency explainer], threads are created both
424424
*implicitly*, when calling a component export (in `canon_lift` below), and
425-
*explicitly*, when core wasm code calls the `thread.new_indirect` built-in (in
425+
*explicitly*, when core wasm code calls the `thread.new-indirect` built-in (in
426426
`canon_thread_new_indirect` below). Threads are represented here by the
427427
`Thread` class and the [current thread] is represented by explicitly threading
428428
a reference to a `Thread` through all Core WebAssembly calls so that the
@@ -769,7 +769,7 @@ enforce the Canonical ABI rules associated with the callee as well as implement
769769
caller-requested cancellation. Each task contains 0..N threads that execute on
770770
behalf of the task, starting with the thread that is spawned to execute the
771771
exported function and transitively including additional threads spawned by that
772-
thread via `thread.new_indirect`.
772+
thread via `thread.new-indirect`.
773773

774774
Tasks are represented here by the `Task` class and the [current task] is
775775
represented by the `Thread.task` field of the [current thread]. `Task`
@@ -4332,11 +4332,11 @@ def canon_thread_index(thread):
43324332
```
43334333

43344334

4335-
### 🧵 `canon thread.new_indirect`
4335+
### 🧵 `canon thread.new-indirect`
43364336

43374337
For a canonical definition:
43384338
```wat
4339-
(canon thread.new_indirect $ft $ftbl (core func $new_indirect))
4339+
(canon thread.new-indirect $ft $ftbl (core func $new_indirect))
43404340
```
43414341
validation specifies
43424342
* `$ft` must refer to the type `(func (param $c i32))`
@@ -4623,11 +4623,11 @@ def canon_error_context_drop(thread, i):
46234623
```
46244624

46254625

4626-
### 🧵② `canon thread.spawn_ref`
4626+
### 🧵② `canon thread.spawn-ref`
46274627

46284628
For a canonical definition:
46294629
```wat
4630-
(canon thread.spawn_ref shared? $ft (core func $spawn_ref))
4630+
(canon thread.spawn-ref shared? $ft (core func $spawn_ref))
46314631
```
46324632
validation specifies:
46334633
* `$ft` must refer to the type `(shared? (func (param $c i32)))` (see explanation below)
@@ -4642,7 +4642,7 @@ parallel with all other threads.
46424642
> Note: ideally, a thread could be spawned with [arbitrary thread parameters].
46434643
> Currently, that would require additional work in the toolchain to support so,
46444644
> for simplicity, the current proposal simply fixes a single `i32` parameter
4645-
> type. However, `thread.spawn_ref` could be extended to allow arbitrary thread
4645+
> type. However, `thread.spawn-ref` could be extended to allow arbitrary thread
46464646
> parameters in the future, once it's concretely beneficial to the toolchain.
46474647
> The inclusion of `$ft` ensures backwards compatibility for when arbitrary
46484648
> parameters are allowed.
@@ -4664,15 +4664,15 @@ part of adding a [GC ABI option] to the Canonical ABI and would work
46644664
like `canon_thread_new_indirect` minus the table access and type check.
46654665

46664666

4667-
### 🧵② `canon thread.spawn_indirect`
4667+
### 🧵② `canon thread.spawn-indirect`
46684668

46694669
For a canonical definition:
46704670
```wat
4671-
(canon thread.spawn_indirect shared? $ft $tbl (core func $spawn_indirect))
4671+
(canon thread.spawn-indirect shared? $ft $tbl (core func $spawn_indirect))
46724672
```
46734673
validation specifies:
46744674
* `$ft` must refer to the type `(shared? (func (param $c i32)))` is allowed
4675-
(see explanation in `thread.spawn_ref` above)
4675+
(see explanation in `thread.spawn-ref` above)
46764676
* `$tbl` must refer to a shared table whose element type matches
46774677
`(ref null (shared? func))`
46784678
* `$spawn_indirect` is given type
@@ -4684,7 +4684,7 @@ immediate is present, the spawned thread is *preemptive* and able to execute in
46844684
parallel with all other threads.
46854685

46864686
Calling `$spawn_indirect` invokes the following function which simply fuses
4687-
the `thread.new_indirect` and `thread.resume-later` built-ins, allowing
4687+
the `thread.new-indirect` and `thread.resume-later` built-ins, allowing
46884688
thread-creation to skip the intermediate "suspended" state transition.
46894689
```python
46904690
def canon_thread_spawn_indirect(shared, ft, ftbl: Table[CoreFuncRef], thread, fi, c):

design/mvp/Concurrency.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ the stack.
116116

117117
In addition to the *implicit* threads logically created for export calls, Core
118118
WebAssembly code can also *explicitly* create new green threads by calling the
119-
[`thread.new_indirect`] built-in. Regardless of how they were created, all
119+
[`thread.new-indirect`] built-in. Regardless of how they were created, all
120120
threads can call a set of Component Model-defined `thread.*` built-in functions
121121
(listed [below](#waiting)) to suspend themselves and/or resume other threads.
122122
These built-ins provide sufficient functionality to implement both the
123123
internally-scheduled "green thread" and the externally-scheduled "host thread"
124124
use cases mentioned in the [goals](#goals).
125125

126126
Until the Core WebAssembly [shared-everything-threads] proposal allows Core
127-
WebAssembly function types to be annotated with `shared`, `thread.new_indirect`
127+
WebAssembly function types to be annotated with `shared`, `thread.new-indirect`
128128
can only call non-`shared` functions (via `i32` `(table funcref)` index, just
129129
like `call_indirect`) and thus currently all threads must execute
130130
[cooperatively] in a sequentially-interleaved fashion, switching between
@@ -237,7 +237,7 @@ where a **component store** is the top-level "thing" and analogous to a Core
237237
WebAssembly [store].
238238

239239
The reason for the thread/task split is so that, when one thread creates a new
240-
thread by calling [`thread.new_indirect`], the new thread is contained by the
240+
thread by calling [`thread.new-indirect`], the new thread is contained by the
241241
task of the original thread. Thus there is an N:1 relationship between threads
242242
and tasks that ties N threads to the original export call (= "task") that
243243
transitively spawned those N threads. This relationship serves several purposes
@@ -275,9 +275,9 @@ natural place to store:
275275
2. a pointer to a struct used by the runtime to implement the language's
276276
thread-local features
277277

278-
When threads are created explicitly by `thread.new_indirect`, the lifetime of
278+
When threads are created explicitly by `thread.new-indirect`, the lifetime of
279279
the thread-local storage array ends when the function passed to
280-
`thread.new_indirect` returns and thus any linear-memory allocations associated
280+
`thread.new-indirect` returns and thus any linear-memory allocations associated
281281
with the thread-local storage array should be eagerly freed by guest code right
282282
before returning. Similarly, since each call to an export logically creates a
283283
fresh thread, thread-local allocations can be eagerly released when this
@@ -502,7 +502,7 @@ will run out of other things to do and will need to wait for something else to
502502
happen by **suspending** itself until something else happens.
503503

504504
The following three built-ins put threads into a suspended state:
505-
* [`thread.new_indirect`]: create a new thread that is initially suspended
505+
* [`thread.new-indirect`]: create a new thread that is initially suspended
506506
and continue executing the current thread
507507
* [`thread.switch-to`]: suspend the current thread and immediately resume a
508508
given thread
@@ -527,7 +527,7 @@ priority):
527527

528528
These built-ins enable the "host thread" [use cases](#goals), allowing the
529529
embedder to nondeterministically control which thread is resumed when. In
530-
particular, [`pthread_create`] can be implemented using `thread.new_indirect`
530+
particular, [`pthread_create`] can be implemented using `thread.new-indirect`
531531
and either `thread.resume-later` or `thread.yield-to` (thereby allowing the
532532
pthreads implementation to choose whether to execute a new pthread eagerly or
533533
not).
@@ -549,7 +549,7 @@ In particular, the following built-ins allow building and using waitable sets:
549549
waitables in the given set has a pending event, return that event; otherwise
550550
return a sentinel "none" value
551551

552-
Threads that are explicitly suspended (via `thread.new_indirect`,
552+
Threads that are explicitly suspended (via `thread.new-indirect`,
553553
`thread.switch-to` or `thread.suspend`) will stay suspended indefinitely until
554554
explicitly resumed (via `thread.switch-to`, `thread.resume-later`,
555555
`thread.yield-to`). Attempting to explicitly resume a thread that was *not*
@@ -1249,7 +1249,7 @@ comes after:
12491249
[`waitable-set.wait`]: Explainer.md#-waitable-setwait
12501250
[`waitable-set.poll`]: Explainer.md#-waitable-setpoll
12511251
[`waitable.join`]: Explainer.md#-waitablejoin
1252-
[`thread.new_indirect`]: Explainer.md#-threadnew_indirect
1252+
[`thread.new-indirect`]: Explainer.md#-threadnew-indirect
12531253
[`thread.index`]: Explainer.md#-threadindex
12541254
[`thread.suspend`]: Explainer.md#-threadsuspend
12551255
[`thread.switch-to`]: Explainer.md#-threadswitch-to

design/mvp/Explainer.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ canon ::= ...
14451445
| (canon future.drop-readable <typeidx> (core func <id>?)) 🔀
14461446
| (canon future.drop-writable <typeidx> (core func <id>?)) 🔀
14471447
| (canon thread.index (core func <id>?)) 🧵
1448-
| (canon thread.new_indirect <typeidx> <core:tableidx> (core func <id>?)) 🧵
1448+
| (canon thread.new-indirect <typeidx> <core:tableidx> (core func <id>?)) 🧵
14491449
| (canon thread.switch-to cancellable? (core func <id>?)) 🧵
14501450
| (canon thread.suspend cancellable? (core func <id>?)) 🧵
14511451
| (canon thread.resume-later (core func <id>?) 🧵
@@ -1454,8 +1454,8 @@ canon ::= ...
14541454
| (canon error-context.new <canonopt>* (core func <id>?)) 📝
14551455
| (canon error-context.debug-message <canonopt>* (core func <id>?)) 📝
14561456
| (canon error-context.drop (core func <id>?)) 📝
1457-
| (canon thread.spawn_ref shared? <typeidx> (core func <id>?)) 🧵②
1458-
| (canon thread.spawn_indirect shared? <typeidx> <core:tableidx> (core func <id>?)) 🧵②
1457+
| (canon thread.spawn-ref shared? <typeidx> (core func <id>?)) 🧵②
1458+
| (canon thread.spawn-indirect shared? <typeidx> <core:tableidx> (core func <id>?)) 🧵②
14591459
| (canon thread.available-parallelism (core func <id>?)) 🧵②
14601460
```
14611461

@@ -2055,20 +2055,20 @@ For details, see [`canon_stream_drop_readable`] in the Canonical ABI explainer.
20552055
| Canonical ABI signature | `[] -> [i32]` |
20562056

20572057
The `thread.index` built-in returns the index of the [current thread] in the
2058-
component instance's table. While `thread.new_indirect` also returns the index
2058+
component instance's table. While `thread.new-indirect` also returns the index
20592059
of newly-created threads, threads created implicitly for export calls can only
20602060
learn their index via `thread.index`.
20612061

20622062
For details, see [`canon_thread_index`] in the Canonical ABI explainer.
20632063

2064-
###### 🧵 `thread.new_indirect`
2064+
###### 🧵 `thread.new-indirect`
20652065

20662066
| Synopsis | |
20672067
| -------------------------- | ------------------------------------------------------------- |
20682068
| Approximate WIT signature | `func<FuncT,tableidx>(fi: u32, c: FuncT.params[0]) -> thread` |
20692069
| Canonical ABI signature | `[fi:i32 c:i32] -> [i32]` |
20702070

2071-
The `thread.new_indirect` built-in adds a new thread to the current component
2071+
The `thread.new-indirect` built-in adds a new thread to the current component
20722072
instance's table, returning the index of the new thread. The function table
20732073
supplied via [`core:tableidx`] is indexed by the `fi` operand and then
20742074
dynamically checked to match the type `FuncT` (in the same manner as
@@ -2080,7 +2080,7 @@ Currently, `FuncT` must be `(func (param i32))` and thus `c` must always be an
20802080
ABI is extended for [memory64] and [GC].
20812081

20822082
As explained in the [concurrency explainer][waiting], a thread created by
2083-
`thread.new_indirect` is initially in a suspended state and must be resumed
2083+
`thread.new-indirect` is initially in a suspended state and must be resumed
20842084
eagerly or lazily by [`thread.yield-to`](#-threadyield-to) or
20852085
[`thread.resume-later`](#-threadresume-later), resp., to begin execution.
20862086

@@ -2202,30 +2202,30 @@ threads and threads implicitly created by non-`callback` `async`-lifted
22022202
For details, see [waiting] in the concurrency explainer and
22032203
[`canon_thread_yield`] in the Canonical ABI explainer.
22042204

2205-
###### 🧵② `thread.spawn_ref`
2205+
###### 🧵② `thread.spawn-ref`
22062206

22072207
| Synopsis | |
22082208
| -------------------------- | ------------------------------------------------------------------ |
22092209
| Approximate WIT signature | `func<shared?,FuncT>(f: FuncT, c: FuncT.params[0]) -> bool` |
22102210
| Canonical ABI signature | `shared? [f:(ref null (shared (func (param i32))) c:i32] -> [i32]` |
22112211

2212-
The `thread.spawn_ref` built-in is an optimization, fusing a call to
2212+
The `thread.spawn-ref` built-in is an optimization, fusing a call to
22132213
`thread.new_ref` (assuming `thread.new_ref` was added as part of adding a
22142214
[GC ABI option] to the Canonical ABI) with a call to
22152215
[`thread.resume-later`](#-threadresume-later). This optimization is more
22162216
impactful once given [shared-everything-threads] and thus gated on 🧵②.
22172217

22182218
For details, see [`canon_thread_spawn_ref`] in the Canonical ABI explainer.
22192219

2220-
###### 🧵② `thread.spawn_indirect`
2220+
###### 🧵② `thread.spawn-indirect`
22212221

22222222
| Synopsis | |
22232223
| -------------------------- | ------------------------------------------------------------------ |
22242224
| Approximate WIT signature | `func<shared?,FuncT,tableidx>(i: u32, c: FuncT.params[0]) -> bool` |
22252225
| Canonical ABI signature | `shared? [i:i32 c:i32] -> [i32]` |
22262226

2227-
The `thread.spawn_indirect` built-in is an optimization, fusing a call to
2228-
[`thread.new_indirect`](#-threadnew_indirect) with a call to
2227+
The `thread.spawn-indirect` built-in is an optimization, fusing a call to
2228+
[`thread.new-indirect`](#-threadnew-indirect) with a call to
22292229
[`thread.resume-later`](#-threadresume-later). This optimization is more
22302230
impactful once given [shared-everything-threads] and thus gated on 🧵②.
22312231

@@ -3251,14 +3251,14 @@ For some use-case-focused, worked examples, see:
32513251
[`canon_error_context_debug_message`]: CanonicalABI.md#-canon-error-contextdebug-message
32523252
[`canon_error_context_drop`]: CanonicalABI.md#-canon-error-contextdrop
32533253
[`canon_thread_index`]: CanonicalABI.md#-canon-threadindex
3254-
[`canon_thread_new_indirect`]: CanonicalABI.md#-canon-threadnew_indirect
3254+
[`canon_thread_new_indirect`]: CanonicalABI.md#-canon-threadnew-indirect
32553255
[`canon_thread_suspend`]: CanonicalABI.md#-canon-threadsuspend
32563256
[`canon_thread_switch_to`]: CanonicalABI.md#-canon-threadswitch-to
32573257
[`canon_thread_resume_later`]: CanonicalABI.md#-canon-threadresume-later
32583258
[`canon_thread_yield_to`]: CanonicalABI.md#-canon-threadyield-to
32593259
[`canon_thread_yield`]: CanonicalABI.md#-canon-threadyield
3260-
[`canon_thread_spawn_ref`]: CanonicalABI.md#-canon-threadspawn_ref
3261-
[`canon_thread_spawn_indirect`]: CanonicalABI.md#-canon-threadspawn_indirect
3260+
[`canon_thread_spawn_ref`]: CanonicalABI.md#-canon-threadspawn-ref
3261+
[`canon_thread_spawn_indirect`]: CanonicalABI.md#-canon-threadspawn-indirect
32623262
[`canon_thread_available_parallelism`]: CanonicalABI.md#-canon-threadavailable_parallelism
32633263
[Shared-Nothing]: ../high-level/Choices.md
32643264
[Use Cases]: ../high-level/UseCases.md

design/mvp/canonical-abi/definitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,7 @@ def canon_thread_index(thread):
24812481
assert(thread.index is not None)
24822482
return [thread.index]
24832483

2484-
### 🧵 `canon thread.new_indirect`
2484+
### 🧵 `canon thread.new-indirect`
24852485

24862486
@dataclass
24872487
class CoreFuncRef:

0 commit comments

Comments
 (0)