Instructions¶
Instructions are encoded by opcodes. Each opcode is represented by a single byte, and is followed by the instruction’s immediate arguments, where present. The only exception are structured control instructions, which consist of several opcodes bracketing their nested instruction sequences.
Note
Gaps in the byte code ranges for encoding instructions are reserved for future extensions.
Control Instructions¶
Control instructions have varying encodings. For structured instructions, the instruction sequences forming nested blocks are terminated with explicit opcodes for
Block types are encoded in special compressed form, by either the byte
Note
The
Unlike any other occurrence, the type index in a block type is encoded as a positive signed integer, so that its signed LEB128 bit pattern cannot collide with the encoding of value types or the special code
Reference Instructions¶
Reference instructions are represented by single byte codes.
Parametric Instructions¶
Parametric instructions are represented by single byte codes, possibly followed by a type annotation.
Variable Instructions¶
Variable instructions are represented by byte codes followed by the encoding of the respective index.
Table Instructions¶
Table instructions are represented either by a single byte or a one byte prefix followed by a variable-length unsigned integer.
Memory Instructions¶
Each variant of memory instruction is encoded with a different byte code. Loads and stores are followed by the encoding of their
Note
In future versions of WebAssembly, the additional zero bytes occurring in the encoding of the
Atomic Memory Instructions¶
Each variant of atomic memory instruction is encoded with a different byte code. Loads, stores and RMW instructions are followed by the encoding of their
Numeric Instructions¶
All variants of numeric instructions are represented by separate byte codes.
The
All other numeric instructions are plain opcodes without any immediates.
The saturating truncation instructions all have a one byte prefix, whereas the actual opcode is encoded by a variable-length unsigned integer.
Vector Instructions¶
All variants of vector instructions are represented by separate byte codes. They all have a one byte prefix, whereas the actual opcode is encoded by a variable-length unsigned integer.
Vector loads and stores are followed by the encoding of their
The
The
All other vector instructions are plain opcodes without any immediates.
Expressions¶
Expressions are encoded by their instruction sequence terminated with an explicit