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);
654
+
ArrayBuffer toFixedLengthBuffer();
655
+
ArrayBuffer toResizableBuffer();
646
656
readonly attribute ArrayBuffer buffer;
647
657
};
648
658
</pre>
@@ -655,10 +665,27 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
655
665
* \[[BufferObject]] : an {{ArrayBuffer}} whose [=Data Block=] is [=identified with=] the above memory address
656
666
657
667
<div algorithm>
658
-
To <dfn>create a memory buffer</dfn> from a [=memory address=] |memaddr|, perform the following steps:
668
+
To <dfn>create a fixed length memory buffer</dfn> from a [=memory address=] |memaddr|, perform the following steps:
669
+
670
+
1. Let |block| be a [=Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
671
+
1. Let |buffer| be a new {{ArrayBuffer}} with the internal slots \[[ArrayBufferData]], \[[ArrayBufferByteLength]], and \[[ArrayBufferDetachKey]].
672
+
1. Set |buffer|.\[[ArrayBufferData]] to |block|.
673
+
1. Set |buffer|.\[[ArrayBufferByteLength]] to the length of |block|.
674
+
1. Set |buffer|.\[[ArrayBufferDetachKey]] to "WebAssembly.Memory".
675
+
1. Return |buffer|.
676
+
</div>
677
+
678
+
<div algorithm>
679
+
To <dfn>create a resizable memory buffer</dfn> from a [=memory address=] |memaddr| and a |maxsize|, perform the following steps:
659
680
660
681
1. Let |block| be a [=Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
661
-
1. Let |buffer| be a new {{ArrayBuffer}} whose \[[ArrayBufferData]] is |block| and \[[ArrayBufferByteLength]] is set to the length of |block|.
682
+
1. Let |length| be the length of |block|.
683
+
1. If |maxsize| > (65536 × 65536),
684
+
1. Throw a {{RangeError}} exception.
685
+
1. Let |buffer| be a new {{ArrayBuffer}} with the internal slots \[[ArrayBufferData]], \[[ArrayBufferByteLength]], \[[ArrayBufferMaxByteLength]], and \[[ArrayBufferDetachKey]].
686
+
1. Set |buffer|.\[[ArrayBufferData]] to |block|.
687
+
1. Set |buffer|.\[[ArrayBufferByteLength]] to |length|.
688
+
1. Set |buffer|.\[[ArrayBufferMaxByteLength]] is |maxsize|.
662
689
1. Set |buffer|.\[[ArrayBufferDetachKey]] to "WebAssembly.Memory".
663
690
1. Return |buffer|.
664
691
</div>
@@ -667,7 +694,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
667
694
To <dfn>initialize a memory object</dfn> |memory| from a [=memory address=] |memaddr|, perform the following steps:
668
695
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
1. Set **this**.\[[BufferObject]] to |resizableBuffer|.
796
+
1. Return |resizableBuffer|.
797
+
</div>
798
+
799
+
{{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.
800
+
801
+
<div algorithm>
802
+
The <dfn>abstract operation [=HostResizeArrayBuffer=]</dfn> takes arguments |buffer| (an {{ArrayBuffer}}) and |newLength|. It performs the following steps when called.
803
+
804
+
1. If |buffer|.\[[ArrayBufferDetachKey]] is "WebAssembly.Memory",
805
+
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
806
+
1. Assert: |buffer| is the \[[BufferObject]] of exactly one value in |map|.
807
+
1. [=map/iterate|For each=] |memaddr| → |mem| in |map|,
808
+
1. If [=SameValue=](|mem|.\[[BufferObject]], |buffer|) is true,
809
+
1. Assert: |buffer|.\[[ArrayBufferByteLength]] modulo 65536 is 0.
810
+
1. Let |lengthDelta| be |newLength| - |buffer|.\[[ArrayBufferByteLength]].
811
+
1. If |lengthDelta| < 0 or |lengthDelta| modulo 65536 is not 0,
812
+
1. Throw a {{RangeError}} exception.
813
+
1. Let |delta| be |lengthDelta| ÷ 65536.
814
+
1. [=Grow the memory buffer=] associated with |memaddr| by |delta|.
0 commit comments