WebAssembly 2026-11-05
WebAssembly is a portable, low-level code format with precisely specified execution and validation rules. Programs are organized into WebAssembly modules, often produced by compilation from another programming language. Its type system and stack machine semantics make operations explicit. Although designed with web applications in mind, the core format does not require a web browser.[ref]
WebAssembly Core Specification by the W3C WebAssembly Community Group. Introduction; design goals, execution and embedding
Here is a small WebAssembly text format module exporting addition:
(module (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add)). The two local.get instructions put the arguments on the operand stack; i32.add consumes them and produces one 32-bit result. The function maps inputs 3 and 4 to 7.[ref]WebAssembly Core Specification by the W3C WebAssembly Community Group. Text format, Modules and Functions; integer instruction types
Integer addition wraps modulo . For example, adding one to the bit pattern representing produces zero, rather than an arbitrarily large integer. This is a rule of the machine format, not a numerical approximation.[ref]
WebAssembly Core Specification by the W3C WebAssembly Community Group. Execution, Numerics, iadd
A WebAssembly module obtains external facilities through its host and imports. WebAssembly linear memory is a controlled memory abstraction, not unrestricted access to every host address. Validation and runtime checks provide specified boundaries, but they do not make every allowed computation harmless: an imported operation has the authority that the host gives it.
WebAssembly abstract address 2026-11-05
A WebAssembly abstract address identifies an allocated runtime entity in the appropriate component of the WebAssembly store. Its kind distinguishes a function, memory, table or other entity. It differs from a module-local index and from an offset into WebAssembly linear memory.[ref]
WebAssembly Core Specification by the W3C WebAssembly Community Group. Execution, Runtime Structure: Addresses and Module Instances
For an original lookup example, let the store's memory at address 0 contain bytes
10,11,12, and its memory at address 1 contain 20,21,22. A WebAssembly module instance maps local memory indices 0,1 to store addresses 1,0. Accessing its local memory index 0 at byte offset 2 therefore gives 22; local memory index 1 at the same offset gives 12.The numerical labels need their context. A memory address 1 and a function address 1 select different store components. Byte offset 1 instead selects a location within an already selected memory. Thus writing down the integer 1 alone does not specify which of these references is intended.
The example uses invented store indices, not host-machine pointers observed from an engine. The specification uses abstract addresses to describe how runtime references resolve. WebAssembly module declarations supply local indices, instantiation establishes their runtime mappings, and memory instructions apply offsets within the selected object.[ref]
WebAssembly Core Specification by the W3C WebAssembly Community Group. Runtime Structure: Store, Addresses and Module Instances
WebAssembly module 2026-11-05
A WebAssembly module is the unit of deployment, loading and compilation in WebAssembly. It collects declarations such as functions, types and memories, can request imports, and can expose exports. Optional initialization includes data segments and a start function. A WebAssembly module is represented in a binary encoding or the readable WebAssembly text format.[ref]
WebAssembly Core Specification by the W3C WebAssembly Community Group. Syntax, Modules, opening definition; Text format, Modules
Definitions use zero-based indices, with a separate index space for each kind of definition. Imported functions precede locally defined functions in the function index space. For example, with one imported function and two local functions, their function indices are respectively 0, 1 and 2; memory index 0 belongs to a different space. This explains why inserting a function import can change a numeric call target.[ref]
WebAssembly Core Specification by the W3C WebAssembly Community Group. Syntax, Modules, Indices
A WebAssembly module instance is the runtime realization of these declarations, with references to the allocated or imported objects. Keeping a WebAssembly module distinct from a WebAssembly module instance separates a code description from the state used while executing it. Imported state can be shared; the mere use of the same module does not specify all its runtime resources.[ref]
WebAssembly Core Specification by the W3C WebAssembly Community Group. Execution, Runtime Structure, Module Instances
WebAssembly module instance 2026-11-05
A WebAssembly module instance is the runtime realization of a WebAssembly module. It collects references to the functions, memories and other entities that the WebAssembly module imports, defines or exports. The WebAssembly store contains the allocated runtime objects; a module's local indices are resolved through the corresponding WebAssembly module instance.[ref]
WebAssembly Core Specification by the W3C WebAssembly Community Group. Execution, Runtime Structure, Store and Module Instances
For example,
(module (memory (export "memory") 1)) declares and exports one page of WebAssembly linear memory. Instantiate this WebAssembly module twice. Each instantiation allocates its own declared memory, so writing17 into byte0 through the first WebAssembly module instance leaves byte0 in the second at zero. Code can be reused while mutable state remains distinct.[ref]WebAssembly Core Specification by the W3C WebAssembly Community Group. Execution, Modules, Memory Allocation and Instantiation
The import case supplies a useful counterexample. If a WebAssembly module imports memory and two instantiations receive the same memory object, writes through one are visible through the other. The WebAssembly module instances are distinct but that resource is shared. Instantiation therefore links imported entities as well as allocating local definitions; it also initializes active segments and invokes the start function when one is present.[ref]
WebAssembly Core Specification by the W3C WebAssembly Community Group. Execution, Modules, Instantiation; Runtime Structure, Module Instances
WebAssembly text format 2026-11-05
The WebAssembly text format is the readable textual encoding of WebAssembly modules. Parenthesized declarations describe the same structured program that can be encoded in binary. Symbolic identifiers such as
$add help readers refer to definitions; numeric indices determine references in the underlying module.[ref]WebAssembly Core Specification by the W3C WebAssembly Community Group. Text format, Modules, Functions and Exports; Text format, Values, Identifiers
For example,
(module (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add)) declares and exports a function accepting two 32-bit integers. The local.get instructions push its arguments onto the operand stack; i32.add consumes them and produces the result. Inputs 3 and 4 give 7. The folded instruction (i32.add (local.get 0) (local.get 1)) is an alternative notation for the same instruction sequence.[ref]WebAssembly Core Specification by the W3C WebAssembly Community Group. Text format, Instructions, Folded Instructions; Numeric Instructions, iadd
The parentheses of a folded instruction make operand grouping visible, but do not introduce a different arithmetic operation. Decoding either spelling yields the same instruction structure. Textual readability and runtime behavior are separate: indentation can help a human follow the WebAssembly module, while the declared types and instruction order govern execution.