|
|
|
1.1.4 Dependencies WebAssembly depends on two existing standards: • , for the representation of and the semantics of respective • , for the representation of import/export and the However, to make this specification self-contained, relevant aspects of the aforementioned standards are defined and formalized as part of this specification, such as the and of floating-point values, and the and of Unicode characters. Note: The aforementioned standards are the authoritative source of all respective definitions. Formalizations given in this specification are intended to match these definitions. Any discrepancy in the syntax or semantics described is to be considered an error. 1.2 Overview 1.2.1 Concepts WebAssembly encodes a low-level, assembly-like programming language. This language is structured around the following concepts. Values WebAssembly provides only four basic number types . These are integers and numbers, each in 32 and 64 bit width. 32 bit integers also serve as Booleans and as memory addresses. The usual operations on these types are available, including the full matrix of conversions between them. There is no distinction between signed and unsigned integer types. Instead, integers are interpreted by respective operations as either unsigned or signed in two’s complement representation. of packed data. The supported representations are 4 32-bit, or 2 64-bit numbers, or different widths of packed integer values specifically 2 64-bit integers, 4 32-bit integers, 8 16-bit integers, or 16 8-bit integers. references that represent pointers towards different sorts of entities. Unlike with other types, their size or representation is not observable. Instructions The computational model of WebAssembly is based on a stack machine . Code consists of sequences of instructions that are executed in order. Instructions manipulate values on an implicit operand stack and fall into two main categories. Simple instructions perform basic operations on data. They pop arguments from the operand stack and push results back to it. Control instructions alter control flow. Control flow is structured , meaning it is expressed with well-nested constructs such as blocks, loops, and conditionals. Branches can only target such constructs. Traps Under some conditions, certain instructions may produce a trap , which immediately aborts execution. Traps cannot be handled by WebAssembly code, but are reported to the outside environment, where they typically can be caught. Functions Code is organized into separate functions . Each function takes a sequence of values as parameters and returns a sequence of values as results. Functions can call each other, including recursively, resulting in an implicit call stack that cannot be accessed directly. Functions may also declare mutable local variables that are usable as virtual registers. 4 https://ieeexplore.ieee.org/document/8766229 5 https://www.unicode.org/versions/latest/ 6 https://ieeexplore.ieee.org/document/8766229 7 https://ieeexplore.ieee.org/document/8766229 8 In practice, implementations need not maintain an actual operand stack. Instead, the stack can be viewed as a set of anonymous registers that are implicitly referenced by instructions. The ensures that the stack height, and thus any referenced register, is always known statically. 1.2. Overview 3 |