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
unsigned long grow([EnforceRange] unsigned long delta);
629
+
ArrayBuffer toFixedLengthBuffer();
630
+
ArrayBuffer toResizableBuffer();
621
631
readonly attribute ArrayBuffer buffer;
622
632
};
623
633
</pre>
@@ -630,10 +640,27 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
630
640
* \[[BufferObject]] : an {{ArrayBuffer}} whose [=Data Block=] is [=identified with=] the above memory address
631
641
632
642
<div algorithm>
633
-
To <dfn>create a memory buffer</dfn> from a [=memory address=] |memaddr|, perform the following steps:
643
+
To <dfn>create a fixed length memory buffer</dfn> from a [=memory address=] |memaddr|, perform the following steps:
644
+
645
+
1. Let |block| be a [=Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
646
+
1. Let |buffer| be a new {{ArrayBuffer}} with the internal slots \[[ArrayBufferData]], \[[ArrayBufferByteLength]], and \[[ArrayBufferDetachKey]].
647
+
1. Set |buffer|.\[[ArrayBufferData]] to |block|.
648
+
1. Set |buffer|.\[[ArrayBufferByteLength]] to the length of |block|.
649
+
1. Set |buffer|.\[[ArrayBufferDetachKey]] to "WebAssembly.Memory".
650
+
1. Return |buffer|.
651
+
</div>
652
+
653
+
<div algorithm>
654
+
To <dfn>create a resizable memory buffer</dfn> from a [=memory address=] |memaddr| and a |maxsize|, perform the following steps:
634
655
635
656
1. Let |block| be a [=Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
636
-
1. Let |buffer| be a new {{ArrayBuffer}} whose \[[ArrayBufferData]] is |block| and \[[ArrayBufferByteLength]] is set to the length of |block|.
657
+
1. Let |length| be the length of |block|.
658
+
1. If |maxsize| > (65536 × 65536),
659
+
1. Throw a {{RangeError}} exception.
660
+
1. Let |buffer| be a new {{ArrayBuffer}} with the internal slots \[[ArrayBufferData]], \[[ArrayBufferByteLength]], \[[ArrayBufferMaxByteLength]], and \[[ArrayBufferDetachKey]].
661
+
1. Set |buffer|.\[[ArrayBufferData]] to |block|.
662
+
1. Set |buffer|.\[[ArrayBufferByteLength]] to |length|.
663
+
1. Set |buffer|.\[[ArrayBufferMaxByteLength]] is |maxsize|.
637
664
1. Set |buffer|.\[[ArrayBufferDetachKey]] to "WebAssembly.Memory".
638
665
1. Return |buffer|.
639
666
</div>
@@ -642,7 +669,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
642
669
To <dfn>initialize a memory object</dfn> |memory| from a [=memory address=] |memaddr|, perform the following steps:
643
670
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
1. Set **this**.\[[BufferObject]] to |resizableBuffer|.
771
+
1. Return |resizableBuffer|.
772
+
</div>
773
+
774
+
{{ArrayBuffer}} objects returned by a {{Memory}} object must have a size that is a multiple of a WebAssembly [=page size=] (the constant 65536). For this reason [=HostResizeArrayBuffer=] is redefined as follows.
775
+
776
+
<div algorithm>
777
+
The <dfn>abstract operation [=HostResizeArrayBuffer=]</dfn> takes arguments |buffer| (an {{ArrayBuffer}}) and |newLength|. It performs the following steps when called.
778
+
779
+
1. If |buffer|.\[[ArrayBufferDetachKey]] is "WebAssembly.Memory",
780
+
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
781
+
1. Assert: |buffer| is the \[[BufferObject]] of exactly one value in |map|.
782
+
1. [=map/iterate|For each=] |memaddr| → |mem| in |map|,
783
+
1. If [=SameValue=](|mem|.\[[BufferObject]], |buffer|) is true,
784
+
1. Assert: |buffer|.\[[ArrayBufferByteLength]] modulo 65536 is 0.
785
+
1. Let |lengthDelta| be |newLength| - |buffer|.\[[ArrayBufferByteLength]].
786
+
1. If |lengthDelta| < 0 or |lengthDelta| modulo 65536 is not 0,
787
+
1. Throw a {{RangeError}} exception.
788
+
1. Let |delta| be |lengthDelta| ÷ 65536.
789
+
1. [=Grow the memory buffer=] associated with |memaddr| by |delta|.
0 commit comments