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
1. Let |block| be a [=Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
628
631
1. Let |buffer| be a new {{ArrayBuffer}} with the internal slots \[[ArrayBufferData]], \[[ArrayBufferByteLength]], and \[[ArrayBufferDetachKey]].
629
632
1. Set |buffer|.\[[ArrayBufferData]] to |block|.
630
633
1. Set |buffer|.\[[ArrayBufferByteLength]] to the length of |block|.
631
634
1. Set |buffer|.\[[ArrayBufferDetachKey]] to "WebAssembly.Memory".
632
635
1. Return |buffer|.
633
636
</div>
634
637
635
-
Note: (TODO) Check whether only SharedArrayBuffers need integrity level "frozen" (see the Threads Proposal Overview).
638
+
Issue: (TODO) Check whether only SharedArrayBuffers need integrity level "frozen" (see the Threads Proposal Overview).
636
639
637
640
To create a resizable memory buffer we perform the same steps as above, but also setting the buffer's maximum size.
638
641
639
642
<div algorithm>
640
-
To <dfn>create a resizable memory buffer</dfn> from a [=memory address=] |memaddr| and a |maxsize|, perform the following steps:
643
+
To <dfn>create a resizable memory buffer</dfn> from a [=memory address=] |memaddr|, perform the following steps:
641
644
642
-
1. Let |block| be a [=Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
643
-
1. Let |length| be the length of |block|.
644
-
1. If |maxsize| > (65536 × 65536),
645
-
1. Throw a {{RangeError}} exception.
646
-
1. If |block| is a [=Shared Data Block=],
645
+
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
646
+
1. Let { |min|, |max| } |share| be [=mem_type=](|store|, |memaddr|).
647
+
1. If |max| is not empty,
648
+
1. If |max| > (65536 × 65536),
649
+
1. Issue: Can this happen?
650
+
1. Throw a {{RangeError}} exception.
651
+
1. Let |maxsize| be |max|.
652
+
1. Otherwise,
653
+
1. Let |maxsize| be 65536 × 65536.
654
+
1. If |share| is shared,
655
+
1. Let |block| be a [=Shared Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
647
656
1. Let |buffer| be a new {{SharedArrayBuffer}} with the internal slots \[[ArrayBufferData]], \[[ArrayBufferByteLength]], and \[[ArrayBufferMaxByteLength]].
648
657
1. Set |buffer|.\[[ArrayBufferData]] to |block|.
649
-
1. Set |buffer|.\[[ArrayBufferByteLength]] to the length of |block|.
658
+
1. Set |buffer|.\[[ArrayBufferByteLength]] to |min|.
650
659
1. Set |buffer|.\[[ArrayBufferMaxByteLength]] to |maxsize|.
1. Let |block| be a [=Data Block=] which is [=identified with=] the underlying memory of |memaddr|.
653
663
1. Let |buffer| be a new {{ArrayBuffer}} with the internal slots \[[ArrayBufferData]], \[[ArrayBufferByteLength]], \[[ArrayBufferMaxByteLength]], and \[[ArrayBufferDetachKey]].
654
664
1. Set |buffer|.\[[ArrayBufferData]] to |block|.
655
-
1. Set |buffer|.\[[ArrayBufferByteLength]] to |length|.
665
+
1. Set |buffer|.\[[ArrayBufferByteLength]] to |min|.
656
666
1. Set |buffer|.\[[ArrayBufferMaxByteLength]] to |maxsize|.
657
667
1. Set |buffer|.\[[ArrayBufferDetachKey]] to "WebAssembly.Memory".
658
668
1. Return |buffer|.
@@ -684,9 +694,9 @@ To create a resizable memory buffer we perform the same steps as above, but also
684
694
1. Let |initial| be |descriptor|["initial"].
685
695
1. If |descriptor|["maximum"][=map/exists=], let |maximum| be |descriptor|["maximum"]; otherwise, let |maximum| be empty.
686
696
1. If |maximum| is not empty and |maximum| < |initial|, throw a {{RangeError}} exception.
687
-
1. Let |shared| be |descriptor|["shared"].
688
-
1. If |shared| is true and |maximum| is empty, throw a {{TypeError}} exception.
689
-
1. Let |memtype| be { min |initial|, max |maximum|, shared |shared| }.
697
+
1. Let |share| be shared if |descriptor|["shared"] is true and unshared otherwise.
698
+
1. If |share| is shared and |maximum| is empty, throw a {{TypeError}} exception.
699
+
1. Let |memtype| be ({ min |initial|, max |maximum| }, |share|).
690
700
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
691
701
1. Let (|store|, |memaddr|) be [=mem_alloc=](|store|, |memtype|). If allocation fails, throw a {{RangeError}} exception.
692
702
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
@@ -700,12 +710,13 @@ To create a resizable memory buffer we perform the same steps as above, but also
700
710
1. Assert: |map|[|memaddr|][=map/exists=].
701
711
1. Let |memory| be |map|[|memaddr|].
702
712
1. Let |buffer| be |memory|.\[[BufferObject]].
703
-
1. If [=IsFixedLengthArrayBuffer=](|buffer|) is true,
704
-
1. If |memory|.\[[BufferObject]] is an {{ArrayBuffer}},
713
+
1. If [$IsFixedLengthArrayBuffer$](|buffer|) is true,
1. Set **this**.\[[BufferObject]] to |resizableBuffer|.
777
782
1. Return |resizableBuffer|.
778
783
</div>
779
784
780
-
{{ArrayBuffer}} and {{SharedArrayBuffer}} objects returned by a {{Memory}} object must have size that is a multiple of a WebAssembly [=page size=] (the constant 65536). For this reason [=HostResizeArrayBuffer=] and [=HostGrowSharedArrayBuffer=] are redefined as follows.
785
+
{{ArrayBuffer}} and {{SharedArrayBuffer}} objects returned by a {{Memory}} object must have size that is a multiple of a WebAssembly [=page size=] (the constant 65536). For this reason [$HostResizeArrayBuffer$] and [$HostGrowSharedArrayBuffer$] are redefined as follows.
781
786
782
-
<div algorithm>
783
-
The <dfn>abstract operation [=HostResizeArrayBuffer=]</dfn> takes arguments an {{ArrayBuffer}} |buffer| and |newLength|. It performs the following steps when called.
787
+
<div algorithm export>
788
+
The <dfn>abstract operation [$HostResizeArrayBuffer$]</dfn> takes arguments an {{ArrayBuffer}} |buffer| and |newLength|. It performs the following steps when called.
784
789
785
790
1. If |buffer|.\[[ArrayBufferDetachKey]] is "WebAssembly.Memory",
786
791
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
787
792
1. Assert: |buffer| is the \[[BufferObject]] of exactly one value in |map|.
788
793
1. [=map/iterate|For each=] |memaddr| → |mem| in |map|,
789
-
1. If [=SameValue=](mem.\[[BufferObject]], |buffer|) is true,
794
+
1. If [=SameValue=](|mem|.\[[BufferObject]], |buffer|) is true,
790
795
1. Assert: |buffer|.\[[ArrayBufferByteLength]] modulo 65536 is 0.
791
796
1. Let |lengthDelta| be |newLength| - |buffer|.\[[ArrayBufferByteLength]].
792
797
1. If |lengthDelta| < 0 or |lengthDelta| modulo 65536 is not 0,
@@ -797,13 +802,13 @@ Immediately after a WebAssembly [=memory.grow=] instruction executes, perform th
797
802
1. Otherwise, return unhandled.
798
803
</div>
799
804
800
-
<div algorithm>
801
-
The <dfn>abstract operation [=HostGrowSharedArrayBuffer=]</dfn> takes arguments a {{SharedArrayBuffer}} |buffer| and |newLength|. It performs the following steps when called.
805
+
<div algorithm export>
806
+
The <dfn>abstract operation [$HostGrowSharedArrayBuffer$]</dfn> takes arguments a {{SharedArrayBuffer}} |buffer| and |newLength|. It performs the following steps when called.
802
807
803
808
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
804
809
1. Assert: |buffer| is the \[[BufferObject]] of exactly one value in |map|.
805
810
1. [=map/iterate|For each=] |memaddr| → |mem| in |map|,
806
-
1. If [=SameValue=](mem.\[[BufferObject]], |buffer|) is true,
811
+
1. If [=SameValue=](|mem|.\[[BufferObject]], |buffer|) is true,
807
812
1. Assert: |buffer|.\[[ArrayBufferByteLength]] modulo 65536 is 0.
808
813
1. Let |lengthDelta| be |newLength| - |buffer|.\[[ArrayBufferByteLength]].
809
814
1. If |lengthDelta| < 0 or |lengthDelta| modulo 65536 is not 0,
@@ -813,7 +818,7 @@ Immediately after a WebAssembly [=memory.grow=] instruction executes, perform th
813
818
1. If |newLength| < |buffer|.\[[ArrayBufferByteLength]] or |newLength| > |buffer|.\[[ArrayBufferMaxByteLength]], throw a {{RangeError}} exception.
814
819
1. Let |agentRecord| be the surrounding agent's [=Agent Record=].
815
820
1. Let |isLittleEndian| be |agentRecord|.\[[LittleEndian]] .
816
-
1. Let |event| be an implementation defined [=ReadModifyWriteSharedMemory=] event, whose \[[Order]] is "SeqCst", \[[Payload]] is [§NumericToRawBytes$](Bigint, |newLength|, |isLittleEndian|), \[[Block]] is |buffer|.\[[ArrayBufferByteLengthData]], \[[ByteIndex]] is 0, and \[[ElementSize]] is 8.
821
+
1. Let |event| be an implementation defined [=ReadModifyWriteSharedMemory=] event, whose \[[Order]] is "SeqCst", \[[Payload]] is [$NumericToRawBytes$](Bigint, |newLength|, |isLittleEndian|), \[[Block]] is |buffer|.\[[ArrayBufferByteLengthData]], \[[ByteIndex]] is 0, and \[[ElementSize]] is 8.
817
822
1. Let |eventsRecord| be the [=Agent Events Record|EventsRecord=] in |agentRecord|.\[[CandidateExecution]].\[[EventsRecords]] that corresponds to the surrounding agent's signifier |agentRecord|.\[[Signifier]].
818
823
1. Append |event| to |eventsRecord|.\[[EventsList]].
0 commit comments