From da9a446751e8d5e02ac3b5eaf25de0d151f2bca6 Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Wed, 29 Mar 2017 23:47:55 -0700 Subject: [PATCH 1/5] WebAssembly.Memory: length, initial, maximum As suggested in #1024. I'll follow-up with a similar suggestion for WebAssembly.Instance, which needs its own discussion about encapsulation as well as multiple memories. WebAssembly.Memory is simpler: there's only one Memory and it's not encapsulated. --- JS.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/JS.md b/JS.md index 91a8aecc..4c269e02 100644 --- a/JS.md +++ b/JS.md @@ -510,11 +510,13 @@ 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 four 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]] + * [[Initial]] : the `initial` number of WebAssembly pages + * [[Maximum]] : the `maximum` number of WebAssembly pages, or `undefined` if `maximum` is `None` ### `WebAssembly.Memory` Constructor @@ -608,6 +610,36 @@ 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.length` + +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]]`. + +### `WebAssembly.Memory.prototype.initial` + +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.[[Initial]]`. + +### `WebAssembly.Memory.prototype.maximum` + +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) From 267e27aba5fca29968155d031b6478cc8b3154ba Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Thu, 30 Mar 2017 00:33:56 -0700 Subject: [PATCH 2/5] Initialize slots --- JS.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/JS.md b/JS.md index 4c269e02..a516b8c9 100644 --- a/JS.md +++ b/JS.md @@ -561,8 +561,11 @@ 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`, +[[Initial]] set to `initial`, and +[[Maximum]] set to `undefined` if `maximum` is `None` or `maximum` otherwise. ### `WebAssembly.Memory.prototype [ @@toStringTag ]` Property From 621e9465930d9b2290d6cca150c3464f883af746 Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Thu, 30 Mar 2017 21:02:18 -0700 Subject: [PATCH 3/5] s/length/byteLength/ and feature-test --- JS.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/JS.md b/JS.md index a516b8c9..35d6905f 100644 --- a/JS.md +++ b/JS.md @@ -7,6 +7,14 @@ be loaded and run directly from an HTML `