You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Prettify section names
* Restructure encoding of function signatures
* Revert "[Binary 11] Update the version number to 0xB."
* Leave index space for growing the number of base types
* Comments addressed
* clarify how export/import names convert to JS strings (#569) (#573)
* When embedded in the web, clarify how export/import names convert to JS strings (#569)
* Fixes suggested by @jf
* Address more feedback
Added a link to http://monsur.hossa.in/2012/07/20/utf-8-in-javascript.html. Simplified the decoding algorithm thanks to Luke's feedback.
* Access to proprietary APIs apart from HTML5 (#656)
* comments
Copy file name to clipboardExpand all lines: BinaryEncoding.md
+13-6Lines changed: 13 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,9 @@ A four-byte little endian unsigned integer.
35
35
### varint32
36
36
A [Signed LEB128](https://en.wikipedia.org/wiki/LEB128#Signed_LEB128) variable-length integer, limited to int32 values.
37
37
38
+
### varuint1
39
+
A [LEB128](https://en.wikipedia.org/wiki/LEB128) variable-length integer, limited to the values 0 or 1. `varuint1` values may contain leading zeros. (This type is mainly used for compatibility with potential future extensions.)
40
+
38
41
### varuint32
39
42
A [LEB128](https://en.wikipedia.org/wiki/LEB128) variable-length integer, limited to uint32 values. `varuint32` values may contain leading zeros.
40
43
@@ -75,8 +78,8 @@ The module starts with a preamble of two fields:
75
78
76
79
| Field | Type | Description |
77
80
| ----- | ----- | ----- |
78
-
| magic number |`uint32`| Magic number `0x6d736100`== `'\0asm'`.|
79
-
| version |`uint32`| Version number`11` == `0x0b`. The version for MVP will be reset to `1`. |
81
+
| magic number |`uint32`| Magic number `0x6d736100`(i.e., '\0asm')|
82
+
| version |`uint32`| Version number, currently 10. The version for MVP will be reset to 1. |
80
83
81
84
This preamble is followed by a sequence of sections. Each section is identified by an
82
85
immediate string. Sections whose identity is unknown to the WebAssembly
@@ -117,15 +120,19 @@ The type section declares all function signatures that will be used in the modul
117
120
118
121
| Field | Type | Description |
119
122
| ----- | ----- | ----- |
120
-
| count |`varuint32`| count of signature entries to follow |
123
+
| count |`varuint32`| count of type entries to follow |
121
124
| entries |`type_entry*`| repeated type entries as described below |
122
125
123
126
#### Type entry
124
127
| Field | Type | Description |
125
128
| ----- | ----- | ----- |
129
+
| form |`uint8`|`0x40`, indicating a function type |
126
130
| param_count |`varuint32`| the number of parameters to the function |
127
-
| return_type |`value_type?`| the return type of the function, with `0` indicating no return type |
128
131
| param_types |`value_type*`| the parameter types of the function |
132
+
| return_count |`varuint1`| the number of results from the function |
133
+
| return_type |`value_type?`| the result type of the function (if return_count is 1) |
134
+
135
+
(Note: In the future, this section may contain other forms of type entries as well, which can be distinguished by the `form` field.)
129
136
130
137
### Import section
131
138
@@ -216,7 +223,7 @@ The start section declares the [start function](Modules.md#module-start-function
216
223
217
224
ID: `code`
218
225
219
-
The code section assigns a body to every function in the module.
226
+
The code section contains a body for every function in the module.
220
227
The count of function declared in the [function section](#function-section)
221
228
and function bodies defined in this section must be the same and the `i`th
222
229
declaration corresponds to the `i`th function body.
@@ -230,7 +237,7 @@ declaration corresponds to the `i`th function body.
230
237
231
238
ID: `data`
232
239
233
-
The data section declares the initialized data that should be loaded
240
+
The data section declares the initialized data that is loaded
0 commit comments