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.
Articles by others on the same topic
There are currently no matching articles.