Types appear in the type, import, table, memory, global and tag sections, in local declarations and in instructions. This page lists every type code of the binary format, WebAssembly 3.0. Where a type index can stand in place of a type code, it is written as a non-negative signed 33-bit LEB128 number (s33).
Value types
| Byte | Type | Since |
|---|---|---|
7F | i32 | 1.0 |
7E | i64 | 1.0 |
7D | f32 | 1.0 |
7C | f64 | 1.0 |
7B | v128 | 2.0 |
78 | i8: packed, only in struct and array fields | 3.0 |
77 | i16: packed, only in fields | 3.0 |
64 ht | (ref ht): non-null reference | 3.0 |
63 ht | (ref null ht): nullable reference | 3.0 |
| heap type byte | shorthand for (ref null ht); 70 is funcref, 6F externref | 2.0 (as value types) |
Heap types
| Byte | Heap type |
|---|---|
74 | noexn (3.0) |
73 | nofunc (3.0) |
72 | noextern (3.0) |
71 | none (3.0) |
70 | func |
6F | extern |
6E | any (3.0) |
6D | eq (3.0) |
6C | i31 (3.0) |
6B | struct (3.0) |
6A | array (3.0) |
69 | exn (3.0) |
| s33 ≥ 0 | a defined type, by type index (3.0) |
Defined types
Each entry of the type section is a recursive type:
| Encoding | Meaning |
|---|---|
4E vec(subtype) | rec: a group of types that may refer to each other (3.0). |
| subtype | A single type, a group of one. |
| Encoding | Subtype |
|---|---|
50 vec(typeidx) comptype | sub: may be extended, with the given supertypes (3.0). |
4F vec(typeidx) comptype | sub final: cannot be extended (3.0). |
| comptype | Final, with no supertypes. |
| Encoding | Composite type |
|---|---|
60 vec(valtype) vec(valtype) | func: parameters, then results. |
5F vec(fieldtype) | struct (3.0). |
5E fieldtype | array (3.0). |
A field type is a storage type (a value type, or 78 i8 /
77 i16) followed by mutability: 00 immutable,
01 mutable. In 1.0 and 2.0 every entry is a bare 60 function
type.
Limits
| Flags | Address type | Then |
|---|---|---|
00 | i32 | min |
01 | i32 | min, max |
04 | i64 (3.0) | min |
05 | i64 (3.0) | min, max |
min and max are unsigned LEB128 numbers; only with i64 limits may they exceed 32
bits. Bit 0 means a maximum is present and bit 2
selects 64-bit addressing. Flags 02, 03, 06 and
07 are not defined in release 3.0.
Memory, table, global and tag types
| Type | Encoding | Meaning |
|---|---|---|
| memtype | limits | Size in pages. |
| tabletype | reftype, limits | Element type and size in elements. |
| globaltype | valtype, mutability | 00 constant, 01 mutable. |
| tagtype | 00, typeidx | An exception tag whose parameters are those of the function type (3.0). |
External kinds
| Byte | Kind | Followed by (imports) |
|---|---|---|
00 | function | typeidx |
01 | table | tabletype |
02 | memory | memtype |
03 | global | globaltype |
04 | tag (3.0) | tagtype |
Block types
| Encoding | Block type |
|---|---|
40 | no parameters, no results |
| valtype | no parameters, one result |
| s33 ≥ 0 | the function type with that index (parameters and several results, 2.0) |
Example
60 02 7F 7F 01 7F func (i32, i32) -> (i32)
5F 02 7F 01 78 00 struct with a mutable i32 field and an immutable i8 field
63 00 (ref null 0): nullable reference to type 0
01 01 10 limits: i32, min 1, max 16 (a memory of 1 to 16 pages)
Sources
The WebAssembly core specification, release 3.0, binary format chapter “Types” (every code in the tables), and appendix “Change History” for the release in which each feature appeared. The example bytes are built from those encodings.