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);
596
+
ArrayBuffer toFixedLengthBuffer();
597
+
ArrayBuffer toResizableBuffer();
589
598
readonly attribute ArrayBuffer buffer;
590
599
};
591
600
</pre>
@@ -598,10 +607,27 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
598
607
* \[[BufferObject]] : an {{ArrayBuffer}} whose [=Data Block=] is [=identified with=] the above memory address
599
608
600
609
<div algorithm>
601
-
To <dfn>create a memory buffer</dfn> from a [=memory address=] |memaddr|, perform the following steps:
610
+
To <dfn>create a fixed length memory buffer</dfn> from a [=memory address=] |memaddr|, perform the following steps:
611
+
612
+
1. Let |block| be a [=Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
613
+
1. Let |buffer| be a new {{ArrayBuffer}} with the internal slots \[[ArrayBufferData]], \[[ArrayBufferByteLength]], and \[[ArrayBufferDetachKey]].
614
+
1. Set |buffer|.\[[ArrayBufferData]] to |block|.
615
+
1. Set |buffer|.\[[ArrayBufferByteLength]] to the length of |block|.
616
+
1. Set |buffer|.\[[ArrayBufferDetachKey]] to "WebAssembly.Memory".
617
+
1. Return |buffer|.
618
+
</div>
619
+
620
+
<div algorithm>
621
+
To <dfn>create a resizable memory buffer</dfn> from a [=memory address=] |memaddr| and a |maxsize|, perform the following steps:
602
622
603
623
1. Let |block| be a [=Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
604
-
1. Let |buffer| be a new {{ArrayBuffer}} whose \[[ArrayBufferData]] is |block| and \[[ArrayBufferByteLength]] is set to the length of |block|.
624
+
1. Let |length| be the length of |block|.
625
+
1. If |maxsize| > (65536 × 65536),
626
+
1. Throw a {{RangeError}} exception.
627
+
1. Let |buffer| be a new {{ArrayBuffer}} with the internal slots \[[ArrayBufferData]], \[[ArrayBufferByteLength]], \[[ArrayBufferMaxByteLength]], and \[[ArrayBufferDetachKey]].
628
+
1. Set |buffer|.\[[ArrayBufferData]] to |block|.
629
+
1. Set |buffer|.\[[ArrayBufferByteLength]] to |length|.
630
+
1. Set |buffer|.\[[ArrayBufferMaxByteLength]] is |maxsize|.
605
631
1. Set |buffer|.\[[ArrayBufferDetachKey]] to "WebAssembly.Memory".
606
632
1. Return |buffer|.
607
633
</div>
@@ -610,7 +636,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
610
636
To <dfn>initialize a memory object</dfn> |memory| from a [=memory address=] |memaddr|, perform the following steps:
611
637
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
1. Set **this**.\[[BufferObject]] to |resizableBuffer|.
738
+
1. Return |resizableBuffer|.
739
+
</div>
740
+
741
+
{{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.
742
+
743
+
<div algorithm>
744
+
The <dfn>abstract operation [=HostResizeArrayBuffer=]</dfn> takes arguments |buffer| (an {{ArrayBuffer}}) and |newLength|. It performs the following steps when called.
745
+
746
+
1. If |buffer|.\[[ArrayBufferDetachKey]] is "WebAssembly.Memory",
747
+
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
748
+
1. Assert: |buffer| is the \[[BufferObject]] of exactly one value in |map|.
749
+
1. [=map/iterate|For each=] |memaddr| → |mem| in |map|,
750
+
1. If [=SameValue=](|mem|.\[[BufferObject]], |buffer|) is true,
751
+
1. Assert: |buffer|.\[[ArrayBufferByteLength]] modulo 65536 is 0.
752
+
1. Let |lengthDelta| be |newLength| - |buffer|.\[[ArrayBufferByteLength]].
753
+
1. If |lengthDelta| < 0 or |lengthDelta| modulo 65536 is not 0,
754
+
1. Throw a {{RangeError}} exception.
755
+
1. Let |delta| be |lengthDelta| ÷ 65536.
756
+
1. [=Grow the memory buffer=] associated with |memaddr| by |delta|.
0 commit comments