Skip to content

Binary 0xc #811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f32008b
Clarify that wasm may be viewed as either an AST or a stack machine. …
sunfishcode May 17, 2016
d67792a
Make opcode 0x00 `unreachable`. (#684)
sunfishcode May 21, 2016
e3c2bcc
BinaryEncoding.md changes implied by #682
Jul 18, 2016
b1c24ba
Fix thinko in import section
Jul 18, 2016
b3ea227
Rename definition_kind to external_kind for precision
Jul 19, 2016
d9c0434
Rename resizable_definition to resizable_limits
Jul 19, 2016
c48bdb3
Add opcode delimiter to init_expr
Jul 19, 2016
08b1fd6
Add Elem section to ToC and move it before Data section to reflect Ta…
Jul 19, 2016
30c66b9
Add missing init_expr to global variables and undo the grouped repres…
Jul 19, 2016
0b014b5
Note that only immutable globals can be exported
Jul 19, 2016
7b03fd4
Change the other 'mutability' flag to 'varuint1'
Jul 19, 2016
21562ee
Give 'anyfunc' its own opcode
Jul 19, 2016
b15d041
Add note about immutable global import requirement
Jul 19, 2016
63ef7f7
Remove explicit 'default' flag; make memory/table default by default
Jul 19, 2016
fd4268f
Change (get|set)_global opcodes
Jul 22, 2016
bcf150a
Add end opcode to functions
rossberg Aug 1, 2016
b1965e9
Use section codes instead of section names
Aug 1, 2016
ba254fe
Use LEB for br_table (#738)
Aug 2, 2016
99d098e
Describe operand order of call_indirect (#758)
rossberg Aug 11, 2016
4c3cf81
Remove arities from call/return (#748)
rossberg Aug 16, 2016
9d832f3
Limit varint sizes in Binary Encoding. (#764)
Aug 17, 2016
575a825
Global section (#771)
naturaltransformation Aug 23, 2016
bfe20ee
Make name section a user-string section.
Aug 23, 2016
69dbea2
Update BinaryEncoding.md
Aug 23, 2016
ddaaf09
Update BinaryEncoding.md
Aug 23, 2016
9d54e9c
Use positive section code byte
Aug 24, 2016
7b9403c
Remove specification of name strings for unknown sections
Aug 25, 2016
0ec651a
Update BinaryEncoding.md
Aug 25, 2016
aeeeb69
Remove repetition in definition of var(u)int types (#768)
rossberg Aug 26, 2016
0b63f3b
Fix typo (#781)
wibblymat Aug 30, 2016
9bfc116
Move the element section before the code section (#779)
lukewagner Aug 31, 2016
d42c224
Binary format identifier is out of date (#785)
wibblymat Sep 2, 2016
d9e3b38
Update BinaryEncoding.md to reflect the ml-proto encoding of the memo…
AndrewScheidecker Sep 12, 2016
bc6a51b
Add string back
Sep 14, 2016
477a2a2
Block signatures (#765)
sunfishcode Sep 14, 2016
d8690c5
Make string part of the payload
Sep 15, 2016
9754b05
Remove references to post-order AST in BinaryEncoding.md (#801)
Sep 15, 2016
bf62b1f
Merge with binary_0xc branch
Sep 15, 2016
02d1db5
Merge branch 'binary_0xc_section_codes3' into binary_0xc
Sep 15, 2016
1bf7c33
Simplify loop by removing its exit label.
sunfishcode Sep 15, 2016
d42fdd3
Move description of `return` to correct column (#804)
binji Sep 17, 2016
b1993c2
type correction and missing close quote (#805)
naturaltransformation Sep 21, 2016
1e505de
Remove more references to AST (#806)
Sep 28, 2016
50d8525
Delete h
Sep 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions AstSemantics.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# Abstract Syntax Tree Semantics

WebAssembly code is represented as an Abstract Syntax Tree (AST) where each node
represents an expression. Each function body consists of a list of expressions.
All expressions and operators are typed, with no implicit conversions, subtyping, or overloading rules.
This document describes WebAssembly semantics. The description here is written
in terms of an Abstract Syntax Tree (AST), however it is also possible to
understand WebAssembly semantics in terms of a stack machine. (In practice,
implementations need not build an actual AST or maintain an actual stack; they
need only behave [as if](https://en.wikipedia.org/wiki/As-if_rule) they did so.)

This document explains the high-level design of the AST: its types, constructs, and
semantics. For full details consult [the formal Specification](https://github.com/WebAssembly/spec),
for file-level encoding details consult [Binary Encoding](BinaryEncoding.md),
and for the human-readable text representation consult [Text Format](TextFormat.md).

Each function body consists of a list of expressions. All expressions and
operators are typed, with no implicit conversions or overloading rules.

Verification of WebAssembly code requires only a single pass with constant-time
type checking and well-formedness checking.

Expand Down Expand Up @@ -104,10 +109,9 @@ default linear memories but [new memory operators](FutureFeatures.md#multiple-ta
may be added after the MVP which can also access non-default memories.

Linear memories (default or otherwise) can either be [imported](Modules.md#imports)
or [defined inside the module](Modules.md#linear-memory-section), with defaultness
indicated by a flag on the import or definition. After import or definition,
there is no difference when accessing a linear memory whether it was imported or
defined internally.
or [defined inside the module](Modules.md#linear-memory-section). After import
or definition, there is no difference when accessing a linear memory whether it
was imported or defined internally.

In the MVP, linear memory cannot be shared between threads of execution.
The addition of [threads](PostMVP.md#threads) will allow this.
Expand Down Expand Up @@ -265,10 +269,9 @@ defined by the host environment.
Every WebAssembly [instance](Modules.md) has one specially-designated *default*
table which is indexed by [`call_indirect`](#calls) and other future
table operators. Tables can either be [imported](Modules.md#imports) or
[defined inside the module](Modules.md#table-section), with defaultness
indicated by a flag on the import or definition. After import or definition,
there is no difference when calling into a table whether it was imported or
defined internally.
[defined inside the module](Modules.md#table-section). After import or
definition, there is no difference when calling into a table whether it was
imported or defined internally.

In the MVP, the primary purpose of tables is to implement indirect function
calls in C/C++ using an integer index as the pointer-to-function and the table
Expand Down Expand Up @@ -343,9 +346,12 @@ a value and may appear as children of other expressions.
### Branches and nesting

The `br` and `br_if` constructs express low-level branching.
Branches may only reference labels defined by an outer *enclosing construct*.
This means that, for example, references to a `block`'s label can only occur
within the `block`'s body.
Branches may only reference labels defined by an outer *enclosing construct*,
which can be a `block` (with a label at the `end`), `loop` (with a label at the
beginning), `if` (with a label at the `end` or `else`), `else` (with a label at
the `end`), or the function body (with a label at the `end`). This means that,
for example, references to a `block`'s label can only occur within the
`block`'s body.

In practice, outer `block`s can be used to place labels for any given branching
pattern, except for one restriction: one can't branch into the middle of a loop
Expand All @@ -365,7 +371,7 @@ The `nop`, `br`, `br_if`, `br_table`, and `return` constructs do not yield value
Other control constructs may yield values if their subexpressions yield values:

* `block`: yields either the value of the last expression in the block or the result of an inner branch that targeted the label of the block
* `loop`: yields either the value of the last expression in the loop or the result of an inner branch that targeted the end label of the loop
* `loop`: yields the value of the last expression in the loop
* `if`: yields either the value of the last *then* expression or the last *else* expression or the result of an inner branch that targeted the label of one of these.

In all constructs containing block-like sequences of expressions, all expressions but the last must not yield a value.
Expand Down
Loading