= WebAssembly
{c}
<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.<WebAssembly Core Specification by the W3C WebAssembly Community Group>[Introduction; design goals, execution and embedding]{ref}
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.<WebAssembly Core Specification by the W3C WebAssembly Community Group>[Text format, Modules and Functions; integer instruction types]{ref}
Integer addition wraps modulo $2^{32}$. For example, adding one to the bit pattern representing $2^{32}-1$ produces zero, rather than an arbitrarily large <integer>. This is a rule of the machine format, not a numerical approximation.<WebAssembly Core Specification by the W3C WebAssembly Community Group>[Execution, Numerics, iadd]{ref}
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.
Back to article page