Skip to content

Commit

Permalink
Clarify Data and Element segments
Browse files Browse the repository at this point in the history
Addresses #897. Related to WebAssembly/spec#399.
  • Loading branch information
jfbastien authored Dec 12, 2016
1 parent 5b45a4f commit 22901d9
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions JS.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ Otherwise, this function performs synchronous compilation of the `BufferSource`:
the validated `Ast.module`.
1. On failure, a new `WebAssembly.CompileError` is thrown.


### `WebAssembly.Module.exports`

The `exports` function has the signature:
Expand Down Expand Up @@ -379,16 +380,19 @@ the internal `[[Instance]]` slot to `instance`.

Perform [`CreateDataProperty`](https://tc39.github.io/ecma262/#sec-createdataproperty)(`instance`, `"exports"`, `exportsObject`).

If, after evaluating the `offset` [initializer expression](Modules.md#initializer-expression)
of every [Data](Modules.md#data-section) and [Element](Modules.md#elements-section)
Segment, any of the segments do not fit in their respective Memory or Table, throw a
[`RangeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror).
Apply all Data segments, followed by all Element segments, to their respective Memory or Table in the order in which they appear in the Module.

Note: validation rules prevent a Module from having a Data section without having a Memory section or import, as well as prevent a Module from having an Element section without having a Table.

* The `offset` [initializer expression](Modules.md#initializer-expression) of every [Data](Modules.md#data-section) and [Element](Modules.md#elements-section) segment is evaluated, any of the segments do not fit in their respective Memory or Table, throw a [`RangeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror).

- Segments which are partially out-of-bounds cause the entire evaluation of that segment to fail.
- Zero-sized segments do not cause failure, even if their offset is out-of-bounds.
- Any segment evaluation performed prior to such an error is visible.

* Segments may overlap and, if they do, the final value is the last value written in order.

Apply all Data and Element segments to their respective Memory or Table in the
order in which they appear in the module. Segments may overlap and, if they do,
the final value is the last value written in order. Note: there should be no
errors possible that would cause this operation to fail partway through. After
this operation completes, elements of `instance` are visible and callable
After this operation completes, elements of `instance` are visible and callable
through [imported Tables](Modules.md#imports), even if `start` fails.

If a [`start`](Modules.md#module-start-function) is present, it is evaluated
Expand Down

0 comments on commit 22901d9

Please sign in to comment.