-
Notifications
You must be signed in to change notification settings - Fork 702
WebAssembly.Memory: length, initial, maximum #1027
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
Changes from all commits
da9a446
267e27a
621e946
5289756
37949fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,14 @@ be loaded and run directly from an HTML `<script type='module'>` tag—and | |
| any other Web API that loads ES6 modules via URL—as part of | ||
| [ES6 Module integration](Modules.md#integration-with-es6-modules).) | ||
|
|
||
| ## Post-MVP JavaScript API | ||
|
|
||
| Some JavaScript APIs were added post-MVP and can be | ||
| [feature-tested](FeatureTest.md) together. These are grouped together, | ||
| and each group is denoted with one of the following symbols: | ||
|
|
||
| * ⚜ | ||
|
|
||
| ## Traps | ||
|
|
||
| Whenever WebAssembly semantics specify a [trap](Semantics.md#traps), | ||
|
|
@@ -510,11 +518,12 @@ call one with the `new` operator. | |
|
|
||
| A `WebAssembly.Memory` object contains a single [linear memory](Semantics.md#linear-memory) | ||
| which can be simultaneously referenced by multiple `Instance` objects. Each | ||
| `Memory` object has two internal slots: | ||
| `Memory` object has three internal slots: | ||
|
|
||
| * [[Memory]] : a [`Memory.memory`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/memory.mli) | ||
| * [[BufferObject]] : the current `ArrayBuffer` whose [[ArrayBufferByteLength]] | ||
| matches the current byte length of [[Memory]] | ||
| * [[Maximum]] : the `maximum` number of WebAssembly pages, or `undefined` if `maximum` is `None` | ||
|
|
||
| ### `WebAssembly.Memory` Constructor | ||
|
|
||
|
|
@@ -559,8 +568,10 @@ Any attempts to [`detach`](http://tc39.github.io/ecma262/#sec-detacharraybuffer) | |
| the detachment performed by [`m.grow`](#webassemblymemoryprototypegrow) shall throw a | ||
| [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror) | ||
|
|
||
| Return a new `WebAssembly.Memory` instance with [[Memory]] set to `m` and | ||
| [[BufferObject]] set to `buffer`. | ||
| Return a new `WebAssembly.Memory` instance with | ||
| [[Memory]] set to `m`, | ||
| [[BufferObject]] set to `buffer`, and | ||
| [[Maximum]] set to `undefined` if `maximum` is `None` or `maximum` otherwise. | ||
|
|
||
| ### `WebAssembly.Memory.prototype [ @@toStringTag ]` Property | ||
|
|
||
|
|
@@ -608,6 +619,30 @@ accessor function performs the following steps: | |
| If `this` is not a `WebAssembly.Memory`, a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror) | ||
| is thrown. Otherwise return `M.[[BufferObject]]`. | ||
|
|
||
| ### `WebAssembly.Memory.prototype.byteLength` | ||
|
|
||
| [⚜](#Post-MVP-JavaScript-API) | ||
|
|
||
| This is an accessor property whose [[Set]] is Undefined and whose [[Get]] | ||
| accessor function performs the following steps: | ||
|
|
||
| Let `T` be the `this` value. If `T` is not a `WebAssembly.Memory`, a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror) | ||
| is thrown. | ||
|
|
||
| Return `T.[[BufferObject]].[[ArrayBufferByteLength]]`. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the motivation for this feature, when a user can do
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah creating the array buffer is expensive-ish. We can optimize it away, but that's being extra silly IMO. |
||
|
|
||
| ### `WebAssembly.Memory.prototype.maximum` | ||
|
|
||
| [⚜](#Post-MVP-JavaScript-API) | ||
|
|
||
| This is an accessor property whose [[Set]] is Undefined and whose [[Get]] | ||
| accessor function performs the following steps: | ||
|
|
||
| Let `T` be the `this` value. If `T` is not a `WebAssembly.Memory`, a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror) | ||
| is thrown. | ||
|
|
||
| Return `T.[[Maximum]]`. | ||
|
|
||
| ## `WebAssembly.Table` Objects | ||
|
|
||
| A `WebAssembly.Table` object contains a single [table](Semantics.md#table) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the motivation for storing the maximum here, rather than looking it up in the store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean "in the store"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He means that the memory instance
m(living in the Wasm abstract store) already has this information, so the internal slot is redundant.