Skip to content

Commit 5f700c1

Browse files
committed
Merge pull request #237 from WebAssembly/definition-section
add opcode definitions section
2 parents 22b9b9c + 90f8acd commit 5f700c1

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

BinaryEncoding.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,40 @@ Yes:
6565

6666
## Global structure
6767

68-
* A module contains:
69-
* a header followed by
70-
* a table (sorted by offset) containing, for each section, its type and offset (within the module), followed by
71-
* a sequence of sections.
68+
* A module contains (in this order):
69+
- A header, containing:
70+
+ The [magic number](https://en.wikipedia.org/wiki/Magic_number_%28programming%29)
71+
+ Other data TBD
72+
- A table (sorted by offset) containing, for each section:
73+
+ A string literal section type name
74+
+ 64-bit offset within the module
75+
- A sequence of sections
7276
* A section contains:
73-
* a header followed by
74-
* the section contents (specific to the section type)
75-
* A code section contains:
76-
* the generic section header
77-
* a table containing, for each function, it's signature, offset (within the section), sorted by offset, followed by
78-
* a sequence of functions
79-
* A function contains:
80-
* a table containing, for each type, how many locals are indexed by the function body of that type
81-
* the serialized AST
77+
- A header followed by
78+
- The section contents (specific to the section type)
79+
* A `definitions` section contains (in this order):
80+
- The generic section header
81+
- A table (sorted by offset) containing, for each type which has opcodes:
82+
+ A standardized string literal [type name](AstSemantics.md#local-and-memory-types).
83+
The index of a type name in this table is referred to as a type ID
84+
+ 32-bit offset of its opcode table within the section
85+
- A sequence of opcode tables
86+
- An opcode table contains:
87+
+ A sequence of standardized string literal [opcode names](AstSemantics.md),
88+
where order determines opcode index
89+
* A `code` section contains (in this order):
90+
- The generic section header
91+
- A table (sorted by offset) containing, for each function:
92+
+ Signature
93+
+ 64-bit offset within the section
94+
- A sequence of functions
95+
- A function contains:
96+
+ A table containing, for each type ID that has [locals](AstSemantics.md#addressing-local-variables):
97+
* Type ID
98+
* Count of locals
99+
+ The serialized AST
100+
101+
All strings are encoded as null-terminated UTF8.
82102

83103
## Serialized AST
84104

0 commit comments

Comments
 (0)