Skip to content

Commit d1f4731

Browse files
flagxorbinji
authored andcommitted
Adding strawman threads.
1 parent 0427c69 commit d1f4731

File tree

2 files changed

+221
-33
lines changed

2 files changed

+221
-33
lines changed

BinaryEncoding.md

Lines changed: 209 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,20 @@ opcodes.
6464

6565
## Language Types
6666

67-
All types are distinguished by a negative `varint7` values that is the first byte of their encoding (representing a type constructor):
67+
All types are distinguished by a negative `varint7` values that is the first
68+
byte of their encoding (representing a type constructor).
69+
Some types have an additional operand indicating table number, encoded as a
70+
varuint32:
6871

69-
| Opcode | Type constructor |
72+
| Encoding | Type constructor |
7073
|--------|------------------|
7174
| `-0x01` (i.e., the byte `0x7f`) | `i32` |
7275
| `-0x02` (i.e., the byte `0x7e`) | `i64` |
7376
| `-0x03` (i.e., the byte `0x7d`) | `f32` |
7477
| `-0x04` (i.e., the byte `0x7c`) | `f64` |
7578
| `-0x10` (i.e., the byte `0x70`) | `anyfunc` |
7679
| `-0x20` (i.e., the byte `0x60`) | `func` |
80+
| `-0x30` (i.e., the byte `0x50`) | `table` followed by varuint32 indicating a table number (currently only can be zero). This type is only allowed in import function signatures for parameter and return types. |
7781
| `-0x40` (i.e., the byte `0x40`) | pseudo type for representing an empty `block_type` |
7882

7983
Some of these will be followed by additional fields, see below.
@@ -90,6 +94,20 @@ A `varint7` indicating a [value type](Semantics.md#types). One of:
9094

9195
as encoded above.
9296

97+
### `table` types
98+
`table` types are indexed references into a statically specified type table
99+
(currently only table 0).
100+
Functions including these types in their signatures expect an i32 for inputs
101+
(for the table index). They expect an i32 operand, for the index of the return
102+
value destination.
103+
In general the behavior of functions including these table types as parameters
104+
is left to the embedder. For a JavaScript embedding, these will typically by
105+
JS Objects.
106+
Calls to imported JS Functions will fail when called outside the original
107+
Wasm thread, unless the function has been specifically designed to be called
108+
off the main thread. In a context without exceptions, such failures will
109+
exit the thread, or throw otherwise.
110+
93111
### `block_type`
94112
A `varint7` indicating a block signature. These types are encoded as:
95113

@@ -589,47 +607,193 @@ operand the index into the table. Its `reserved` immediate is for
589607

590608
## Memory-related operators ([described here](Semantics.md#linear-memory-accesses))
591609

592-
| Name | Opcode | Immediate | Description |
610+
| Name | Opcode | Immediates | Description |
593611
| ---- | ---- | ---- | ---- |
594-
| `i32.load` | `0x28` | `memory_immediate` | load from memory |
595-
| `i64.load` | `0x29` | `memory_immediate` | load from memory |
596-
| `f32.load` | `0x2a` | `memory_immediate` | load from memory |
597-
| `f64.load` | `0x2b` | `memory_immediate` | load from memory |
598-
| `i32.load8_s` | `0x2c` | `memory_immediate` | load from memory |
599-
| `i32.load8_u` | `0x2d` | `memory_immediate` | load from memory |
600-
| `i32.load16_s` | `0x2e` | `memory_immediate` | load from memory |
601-
| `i32.load16_u` | `0x2f` | `memory_immediate` | load from memory |
602-
| `i64.load8_s` | `0x30` | `memory_immediate` | load from memory |
603-
| `i64.load8_u` | `0x31` | `memory_immediate` | load from memory |
604-
| `i64.load16_s` | `0x32` | `memory_immediate` | load from memory |
605-
| `i64.load16_u` | `0x33` | `memory_immediate` | load from memory |
606-
| `i64.load32_s` | `0x34` | `memory_immediate` | load from memory |
607-
| `i64.load32_u` | `0x35` | `memory_immediate` | load from memory |
608-
| `i32.store` | `0x36` | `memory_immediate` | store to memory |
609-
| `i64.store` | `0x37` | `memory_immediate` | store to memory |
610-
| `f32.store` | `0x38` | `memory_immediate` | store to memory |
611-
| `f64.store` | `0x39` | `memory_immediate` | store to memory |
612-
| `i32.store8` | `0x3a` | `memory_immediate` | store to memory |
613-
| `i32.store16` | `0x3b` | `memory_immediate` | store to memory |
614-
| `i64.store8` | `0x3c` | `memory_immediate` | store to memory |
615-
| `i64.store16` | `0x3d` | `memory_immediate` | store to memory |
616-
| `i64.store32` | `0x3e` | `memory_immediate` | store to memory |
612+
| `i32.load` | `0x28` | 0x00 + `memory_flags` `offset` | load from memory |
613+
| `i64.load` | `0x29` | 0x00 + `memory_flags` `offset` | load from memory |
614+
| `f32.load` | `0x2a` | 0x00 + `memory_flags` `offset` | load from memory |
615+
| `f64.load` | `0x2b` | 0x00 + `memory_flags` `offset` | load from memory |
616+
| `i32.load8_s` | `0x2c` | 0x00 + `memory_flags` `offset` | load from memory |
617+
| `i32.load8_u` | `0x2d` | 0x00 + `memory_flags` `offset` | load from memory |
618+
| `i32.load16_s` | `0x2e` | 0x00 + `memory_flags` `offset` | load from memory |
619+
| `i32.load16_u` | `0x2f` | 0x00 + `memory_flags` `offset` | load from memory |
620+
| `i64.load8_s` | `0x30` | 0x00 + `memory_flags` `offset` | load from memory |
621+
| `i64.load8_u` | `0x31` | 0x00 + `memory_flags` `offset` | load from memory |
622+
| `i64.load16_s` | `0x32` | 0x00 + `memory_flags` `offset` | load from memory |
623+
| `i64.load16_u` | `0x33` | 0x00 + `memory_flags` `offset` | load from memory |
624+
| `i64.load32_s` | `0x34` | 0x00 + `memory_flags` `offset` | load from memory |
625+
| `i64.load32_u` | `0x35` | 0x00 + `memory_flags` `offset` | load from memory |
626+
| `i32.store` | `0x36` | 0x00 + `memory_flags` `offset` | store to memory |
627+
| `i64.store` | `0x37` | 0x00 + `memory_flags` `offset` | store to memory |
628+
| `f32.store` | `0x38` | 0x00 + `memory_flags` `offset` | store to memory |
629+
| `f64.store` | `0x39` | 0x00 + `memory_flags` `offset` | store to memory |
630+
| `i32.store8` | `0x3a` | 0x00 + `memory_flags` `offset` | store to memory |
631+
| `i32.store16` | `0x3b` | 0x00 + `memory_flags` `offset` | store to memory |
632+
| `i64.store8` | `0x3c` | 0x00 + `memory_flags` `offset` | store to memory |
633+
| `i64.store16` | `0x3d` | 0x00 + `memory_flags` `offset` | store to memory |
634+
| `i64.store32` | `0x3e` | 0x00 + `memory_flags` `offset` | store to memory |
617635
| `current_memory` | `0x3f` | reserved : `varuint1` | query the size of memory |
618636
| `grow_memory` | `0x40` | reserved : `varuint1` | grow the size of memory |
619637

620-
The `memory_immediate` type is encoded as follows:
638+
## Atomics
621639

622-
| Name | Type | Description |
623-
| ---- | ---- | ---- |
624-
| flags | `varuint32` | a bitfield which currently contains the alignment in the least significant bits, encoded as `log2(alignment)` |
625-
| offset | `varuint32` | the value of the offset |
640+
| Name | Opcode | Immediate | Description |
641+
| ---- | ---- | ---- | ---- |
642+
| `i32.sc_load` | `0x28` | 0x08 + `memory_flags` `offset` | atomic load from memory |
643+
| `i64.sc_load` | `0x29` | 0x08 + `memory_flags` `offset` | atomic load from memory |
644+
| `f32.sc_load` | `0x2a` | 0x08 + `memory_flags` `offset` | atomic load from memory |
645+
| `f64.sc_load` | `0x2b` | 0x08 + `memory_flags` `offset` | atomic load from memory |
646+
| `i32.sc_load8_s` | `0x2c` | 0x08 + `memory_flags` `offset` | atomic load from memory |
647+
| `i32.sc_load8_u` | `0x2d` | 0x08 + `memory_flags` `offset` | atomic load from memory |
648+
| `i32.sc_load16_s` | `0x2e` | 0x08 + `memory_flags` `offset` | atomic load from memory |
649+
| `i32.sc_load16_u` | `0x2f` | 0x08 + `memory_flags` `offset` | atomic load from memory |
650+
| `i64.sc_load8_s` | `0x30` | 0x08 + `memory_flags` `offset` | atomic load from memory |
651+
| `i64.sc_load8_u` | `0x31` | 0x08 + `memory_flags` `offset` | atomic load from memory |
652+
| `i64.sc_load16_s` | `0x32` | 0x08 + `memory_flags` `offset` | atomic load from memory |
653+
| `i64.sc_load16_u` | `0x33` | 0x08 + `memory_flags` `offset` | atomic load from memory |
654+
| `i64.sc_load32_s` | `0x34` | 0x08 + `memory_flags` `offset` | atomic load from memory |
655+
| `i64.sc_load32_u` | `0x35` | 0x08 + `memory_flags` `offset` | atomic load from memory |
656+
| `i32.sc_store` | `0x36` | 0x08 + `memory_flags` `offset` | store to memory |
657+
| `i64.sc_store` | `0x37` | 0x08 + `memory_flags` `offset` | store to memory |
658+
| `f32.sc_store` | `0x38` | 0x08 + `memory_flags` `offset` | store to memory |
659+
| `f64.sc_store` | `0x39` | 0x08 + `memory_flags` `offset` | store to memory |
660+
| `i32.sc_store8` | `0x3a` | 0x08 + `memory_flags` `offset` | store to memory |
661+
| `i32.sc_store16` | `0x3b` | 0x08 + `memory_flags` `offset` | store to memory |
662+
| `i64.sc_store8` | `0x3c` | 0x08 + `memory_flags` `offset` | store to memory |
663+
| `i64.sc_store16` | `0x3d` | 0x08 + `memory_flags` `offset` | store to memory |
664+
| `i64.sc_store32` | `0x3e` | 0x08 + `memory_flags` `offset` | store to memory |
665+
| `i32.sc_add` | `0x28` | 0x18 + `memory_flags` `offset` | atomic add to memory |
666+
| `i64.sc_add` | `0x29` | 0x18 + `memory_flags` `offset` | atomic add to memory |
667+
| `f32.sc_add` | `0x2a` | 0x18 + `memory_flags` `offset` | atomic add to memory |
668+
| `f64.sc_add` | `0x2b` | 0x18 + `memory_flags` `offset` | atomic add to memory |
669+
| `i32.sc_add8_s` | `0x2c` | 0x18 + `memory_flags` `offset` | atomic add to memory |
670+
| `i32.sc_add8_u` | `0x2d` | 0x18 + `memory_flags` `offset` | atomic add to memory |
671+
| `i32.sc_add16_s` | `0x2e` | 0x18 + `memory_flags` `offset` | atomic add to memory |
672+
| `i32.sc_add16_u` | `0x2f` | 0x18 + `memory_flags` `offset` | atomic add to memory |
673+
| `i64.sc_add8_s` | `0x30` | 0x18 + `memory_flags` `offset` | atomic add to memory |
674+
| `i64.sc_add8_u` | `0x31` | 0x18 + `memory_flags` `offset` | atomic add to memory |
675+
| `i64.sc_add16_s` | `0x32` | 0x18 + `memory_flags` `offset` | atomic add to memory |
676+
| `i64.sc_add16_u` | `0x33` | 0x18 + `memory_flags` `offset` | atomic add to memory |
677+
| `i64.sc_add32_s` | `0x34` | 0x18 + `memory_flags` `offset` | atomic add to memory |
678+
| `i64.sc_add32_u` | `0x35` | 0x18 + `memory_flags` `offset` | atomic add to memory |
679+
| `i32.sc_sub` | `0x28` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
680+
| `i64.sc_sub` | `0x29` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
681+
| `f32.sc_sub` | `0x2a` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
682+
| `f64.sc_sub` | `0x2b` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
683+
| `i32.sc_sub8_s` | `0x2c` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
684+
| `i32.sc_sub8_u` | `0x2d` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
685+
| `i32.sc_sub16_s` | `0x2e` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
686+
| `i32.sc_sub16_u` | `0x2f` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
687+
| `i64.sc_sub8_s` | `0x30` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
688+
| `i64.sc_sub8_u` | `0x31` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
689+
| `i64.sc_sub16_s` | `0x32` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
690+
| `i64.sc_sub16_u` | `0x33` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
691+
| `i64.sc_sub32_s` | `0x34` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
692+
| `i64.sc_sub32_u` | `0x35` | 0x28 + `memory_flags` `offset` | atomic sub to memory |
693+
| `i32.sc_and` | `0x28` | 0x28 + `memory_flags` `offset` | atomic and to memory |
694+
| `i64.sc_and` | `0x29` | 0x38 + `memory_flags` `offset` | atomic and to memory |
695+
| `f32.sc_and` | `0x2a` | 0x38 + `memory_flags` `offset` | atomic and to memory |
696+
| `f64.sc_and` | `0x2b` | 0x38 + `memory_flags` `offset` | atomic and to memory |
697+
| `i32.sc_and8_s` | `0x2c` | 0x38 + `memory_flags` `offset` | atomic and to memory |
698+
| `i32.sc_and8_u` | `0x2d` | 0x38 + `memory_flags` `offset` | atomic and to memory |
699+
| `i32.sc_and16_s` | `0x2e` | 0x38 + `memory_flags` `offset` | atomic and to memory |
700+
| `i32.sc_and16_u` | `0x2f` | 0x38 + `memory_flags` `offset` | atomic and to memory |
701+
| `i64.sc_and8_s` | `0x30` | 0x38 + `memory_flags` `offset` | atomic and to memory |
702+
| `i64.sc_and8_u` | `0x31` | 0x38 + `memory_flags` `offset` | atomic and to memory |
703+
| `i64.sc_and16_s` | `0x32` | 0x38 + `memory_flags` `offset` | atomic and to memory |
704+
| `i64.sc_and16_u` | `0x33` | 0x38 + `memory_flags` `offset` | atomic and to memory |
705+
| `i64.sc_and32_s` | `0x34` | 0x38 + `memory_flags` `offset` | atomic and to memory |
706+
| `i64.sc_and32_u` | `0x35` | 0x38 + `memory_flags` `offset` | atomic and to memory |
707+
| `i32.sc_or` | `0x28` | 0x48 + `memory_flags` `offset` | atomic or to memory |
708+
| `i64.sc_or` | `0x29` | 0x48 + `memory_flags` `offset` | atomic or to memory |
709+
| `f32.sc_or` | `0x2a` | 0x48 + `memory_flags` `offset` | atomic or to memory |
710+
| `f64.sc_or` | `0x2b` | 0x48 + `memory_flags` `offset` | atomic or to memory |
711+
| `i32.sc_or8_s` | `0x2c` | 0x48 + `memory_flags` `offset` | atomic or to memory |
712+
| `i32.sc_or8_u` | `0x2d` | 0x48 + `memory_flags` `offset` | atomic or to memory |
713+
| `i32.sc_or16_s` | `0x2e` | 0x48 + `memory_flags` `offset` | atomic or to memory |
714+
| `i32.sc_or16_u` | `0x2f` | 0x48 + `memory_flags` `offset` | atomic or to memory |
715+
| `i64.sc_or8_s` | `0x30` | 0x48 + `memory_flags` `offset` | atomic or to memory |
716+
| `i64.sc_or8_u` | `0x31` | 0x48 + `memory_flags` `offset` | atomic or to memory |
717+
| `i64.sc_or16_s` | `0x32` | 0x48 + `memory_flags` `offset` | atomic or to memory |
718+
| `i64.sc_or16_u` | `0x33` | 0x48 + `memory_flags` `offset` | atomic or to memory |
719+
| `i64.sc_or32_s` | `0x34` | 0x48 + `memory_flags` `offset` | atomic or to memory |
720+
| `i64.sc_or32_u` | `0x35` | 0x48 + `memory_flags` `offset` | atomic or to memory |
721+
| `i32.sc_xor` | `0x28` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
722+
| `i64.sc_xor` | `0x29` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
723+
| `f32.sc_xor` | `0x2a` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
724+
| `f64.sc_xor` | `0x2b` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
725+
| `i32.sc_xor8_s` | `0x2c` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
726+
| `i32.sc_xor8_u` | `0x2d` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
727+
| `i32.sc_xor16_s` | `0x2e` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
728+
| `i32.sc_xor16_u` | `0x2f` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
729+
| `i64.sc_xor8_s` | `0x30` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
730+
| `i64.sc_xor8_u` | `0x31` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
731+
| `i64.sc_xor16_s` | `0x32` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
732+
| `i64.sc_xor16_u` | `0x33` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
733+
| `i64.sc_xor32_s` | `0x34` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
734+
| `i64.sc_xor32_u` | `0x35` | 0x58 + `memory_flags` `offset` | atomic xor to memory |
735+
| `i32.sc_swap` | `0x28` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
736+
| `i64.sc_swap` | `0x29` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
737+
| `f32.sc_swap` | `0x2a` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
738+
| `f64.sc_swap` | `0x2b` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
739+
| `i32.sc_swap8_s` | `0x2c` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
740+
| `i32.sc_swap8_u` | `0x2d` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
741+
| `i32.sc_swap16_s` | `0x2e` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
742+
| `i32.sc_swap16_u` | `0x2f` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
743+
| `i64.sc_swap8_s` | `0x30` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
744+
| `i64.sc_swap8_u` | `0x31` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
745+
| `i64.sc_swap16_s` | `0x32` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
746+
| `i64.sc_swap16_u` | `0x33` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
747+
| `i64.sc_swap32_s` | `0x34` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
748+
| `i64.sc_swap32_u` | `0x35` | 0x68 + `memory_flags` `offset1` `offset2` | atomic swap to memory |
749+
| `i32.sc_cmp_swap` | `0x28` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
750+
| `i64.sc_cmp_swap` | `0x29` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
751+
| `f32.sc_cmp_swap` | `0x2a` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
752+
| `f64.sc_cmp_swap` | `0x2b` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
753+
| `i32.sc_cmp_swap8_s` | `0x2c` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
754+
| `i32.sc_cmp_swap8_u` | `0x2d` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
755+
| `i32.sc_cmp_swap16_s` | `0x2e` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
756+
| `i32.sc_cmp_swap16_u` | `0x2f` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
757+
| `i64.sc_cmp_swap8_s` | `0x30` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
758+
| `i64.sc_cmp_swap8_u` | `0x31` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
759+
| `i64.sc_cmp_swap16_s` | `0x32` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
760+
| `i64.sc_cmp_swap16_u` | `0x33` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
761+
| `i64.sc_cmp_swap32_s` | `0x34` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
762+
| `i64.sc_cmp_swap32_u` | `0x35` | 0x78 + `memory_flags` `offset1` `offset2` | atomic compare exchange to memory |
763+
764+
The `offset`, `offset1`, `offset2` values are encoded as varuint32 values
765+
and represent the offset of the one or two access locations involved in the
766+
load or atomic operation.
767+
768+
`memory_flags`, is summed with an additional value expressing which atomic op
769+
and its style of atomic constraint. This tables captures intent of the
770+
combined encoding, which is stored as a varuint32 (effectively one byte at this
771+
time as the values are 0x7f or less).
772+
773+
| Bit | Description |
774+
| ---- | ---- |
775+
| 1-0 | a bitfield which currently contains the alignment in the least significant bits, encoded as `log2(alignment)` For atomics this must match the operation size. |
776+
| 2 | Reserved for future use, always 0. |
777+
| 3 | Indicates a sequentially consistent atomic operation when 1, otherwise 0. |
778+
| 7-4 | Encodes the type of operation `atomic_op` (load family only). |
779+
| 31-7 | Reserved for future use, always 0. |
780+
781+
| 7-4 bit value | Description |
782+
| ---- | ---- |
783+
| 0 | load |
784+
| 1 | add |
785+
| 2 | sub |
786+
| 3 | and |
787+
| 4 | or |
788+
| 5 | xor |
789+
| 6 | swap |
790+
| 7 | cmp_swap |
626791

627792
As implied by the `log2(alignment)` encoding, the alignment must be a power of 2.
628793
As an additional validation criteria, the alignment must be less or equal to
629794
natural alignment. The bits after the
630795
`log(memory-access-size)` least-significant bits must be set to 0. These bits
631-
are reserved for [future :unicorn:][future threads] use
632-
(e.g., for shared memory ordering requirements).
796+
are reserved for use (e.g., for shared memory ordering requirements).
633797

634798
The `reserved` immediate to the `current_memory` and `grow_memory` operators is
635799
for [future :unicorn:][future multiple tables] use and must be 0 in the MVP.
@@ -786,6 +950,18 @@ for [future :unicorn:][future multiple tables] use and must be 0 in the MVP.
786950
| `f32.reinterpret/i32` | `0xbe` | | |
787951
| `f64.reinterpret/i64` | `0xbf` | | |
788952

953+
## Threads Operations
954+
955+
| Name | Opcode | Immediate | Description |
956+
| ---- | ---- | ---- | ---- |
957+
| `i32.wait` | `0xc0` | `offset` | SAB like wait, takes an index + `offset` and an f64 timeout |
958+
| `i64.wait` | `0xc1` | `offset` | SAB like wait, takes an index + `offset`and an f64 timeout |
959+
| `i32.wake` | `0xc2` | `offset` | SAB like wake, takes an index + `offset` |
960+
| `i64.wake` | `0xc3` | `offest` | SAB like wake, takes an index + `offset` |
961+
| `i32.thread_create` | `0xc4` | `table` | Creates a thread, stores thread in `table` at an i32 index. Returns 0 on success or non-zero otherwise. |
962+
| `i32.thread_join` | `0xc5` | `table` | Waits to join to thread stored at an i32 index in `table`. Returns 0 on success or non-zero otherwise. |
963+
| `thread_exit` | `0xc6` | | Halts current thread. |
964+
789965
[future general]: FutureFeatures.md
790966
[future multiple return]: FutureFeatures.md#multiple-return
791967
[future threads]: FutureFeatures.md#threads

0 commit comments

Comments
 (0)