Module instruction

Module instruction 

Source
Expand description

WebAssembly instruction set.

StructsΒ§

Expression
Function bodies, initialization values for globals, and offsets of element or data segments are given as expressions, which are sequences of instructions terminated by an 𝖾𝗇𝖽 marker. In some places, validation restricts expressions to be constant, which limits the set of allowable instructions.
MemoryArgument
Argument to load and store instructions that contains an address offset and the expected alignment (expressed as the exponent of a power of 2).

EnumsΒ§

BlockType
A structured instruction can consume input and produce output on the operand stack according to its annotated block type. It is given either as a type index that refers to a suitable function type, or as an optional value type inline, which is a shorthand for the function type []β†’[valtype?].
ControlInstruction
Instructions in this group affect the flow of control. The π–»π—…π—ˆπ–Όπ—„, π—…π—ˆπ—ˆπ—‰ and 𝗂𝖿 instructions are structured instructions. They bracket nested sequences of instructions, called blocks, terminated with, or separated by, 𝖾𝗇𝖽 or π–Ύπ—…π—Œπ–Ύ pseudo-instructions. As the grammar prescribes, they must be well-nested.
Instruction
WebAssembly code consists of sequences of instructions. Its computational model is based on a stack machine in that instructions manipulate values on an implicit operand stack, consuming (popping) argument values and producing or returning (pushing) result values. In addition to dynamic operands from the stack, some instructions also have static immediate arguments, typically indices or type annotations, which are part of the instruction itself. Some instructions are structured in that they bracket nested sequences of instructions. The following sections group instructions into a number of different categories.
MemoryInstruction
Instructions in this group are concerned with linear memory. Memory is accessed with π—…π—ˆπ–Ίπ–½ and π—Œπ—π—ˆπ—‹π–Ύ instructions for the different value types. They all take a memory immediate memarg that contains an address offset and the expected alignment (expressed as the exponent of a power of 2). Integer loads and stores can optionally specify a storage size that is smaller than the bit width of the respective value type. In the case of loads, a sign extension mode sx is then required to select appropriate behavior.
NumericInstruction
Numeric instructions provide basic operations over numeric values of specific type. These operations closely match respective operations available in hardware.
ParametricInstruction
Instructions in this group can operate on operands of any value type.
ReferenceInstruction
Instructions in this group are concerned with accessing references. These instruction produce a null value, check for a null value, or produce a reference to a given function, respectively.
SignExtension
Some integer instructions come in two flavors, where a signedness annotation sx distinguishes whether the operands are to be interpreted as unsigned or signed integers. For the other integer instructions, the use of two’s complement for the signed interpretation means that they behave the same regardless of signedness.
TableInstruction
Instructions in this group are concerned with tables table. An additional instruction that accesses a table is the control instruction 𝖼𝖺𝗅𝗅_𝗂𝗇𝖽𝗂𝗋𝖾𝖼𝗍.
VariableInstruction
Variable instructions are concerned with access to local or global variables. These instructions get or set the values of variables, respectively. The π—…π—ˆπ–Όπ–Ίπ—….𝗍𝖾𝖾 instruction is like π—…π—ˆπ–Όπ–Ίπ—….π—Œπ–Ύπ— but also returns its argument.