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
<p>A data block that resides in memory that can be referenced from multiple agents concurrently is designated a <dfn variants="Shared Data Blocks">Shared Data Block</dfn>. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is <em>address-free</em>: it is tied not to the virtual addresses the block is mapped to in any process, but to the set of locations in memory that the block represents. Two <del>data blocks</del> <ins>Shared Data Blocks</ins> are equal only if the sets of the locations they contain are equal; otherwise, they are not equal and the intersection of the sets of locations they contain is empty. Finally, Shared Data Blocks can be distinguished from Data Blocks.</p>
): either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion
36
+
</h1>
37
+
<dl class="header">
38
+
</dl>
39
+
<emu-alg>
40
+
1. Let _relativeStart_ be ? ToIntegerOrInfinity(_start_).
41
+
1. If _relativeStart_ = -∞, let _from_ be 0.
42
+
1. Else if _relativeStart_ < 0, let _from_ be max(_len_ + _relativeStart_, 0).
43
+
1. Else, let _from_ be min(_relativeStart_, _len_).
44
+
1. If _end_ is *undefined*, let _relativeEnd_ be _len_; else let _relativeEnd_ be ? ToIntegerOrInfinity(_end_).
45
+
1. If _relativeEnd_ = -∞, let _to_ be 0.
46
+
1. Else if _relativeEnd_ < 0, let _to_ be max(_len_ + _relativeEnd_, 0).
47
+
1. Else, let _to_ be min(_relativeEnd_, _len_).
48
+
1. Return the Record { [[From]]: _from_, [[To]]: _to_ }.
): either a normal completion containing an ArrayBuffer or a throw completion
483
+
</h1>
484
+
<dl class="header">
485
+
<dt>description</dt>
486
+
<dd>It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from _fromBlock_.</dd>
487
+
</dl>
488
+
<emu-alg>
489
+
1. Assert: _constructor_ is %ArrayBuffer%.
490
+
1. Assert: _count_ ≤ _byteLength_.
491
+
1. Let _newBuffer_ be ? <emu-meta suppress-effects="user-code">AllocateArrayBuffer(_constructor_, _byteLength_, ~immutable~)</emu-meta>.
492
+
1. Let _toBlock_ be _newBuffer_.[[ArrayBufferData]].
<p>Because neither the identity of a Data Block nor the set of locations in memory represented by it are observable, implementations may implement this operation without allocating new memory locations when _fromBlock_ is the value of the [[ArrayBufferData]] slot for some other immutable ArrayBuffer (and therefore already immutable) and _count_ = _byteLength_.</p>
1. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as a zero-copy move or a `realloc`.
466
536
1. Perform ! DetachArrayBuffer(_arrayBuffer_).
@@ -606,14 +676,17 @@ contributors: Mark S. Miller, Richard Gibson
606
676
1. If IsSharedArrayBuffer(_O_) is *true*, throw a *TypeError* exception.
607
677
1. If IsDetachedBuffer(_O_) is *true*, throw a *TypeError* exception.
608
678
1. Let _len_ be _O_.[[ArrayBufferByteLength]].
609
-
1. Let _relativeStart_ be ? ToIntegerOrInfinity(_start_).
610
-
1. If _relativeStart_ = -∞, let _first_ be 0.
611
-
1. Else if _relativeStart_ < 0, let _first_ be max(_len_ + _relativeStart_, 0).
612
-
1. Else, let _first_ be min(_relativeStart_, _len_).
613
-
1. If _end_ is *undefined*, let _relativeEnd_ be _len_; else let _relativeEnd_ be ? ToIntegerOrInfinity(_end_).
614
-
1. If _relativeEnd_ = -∞, let _final_ be 0.
615
-
1. Else if _relativeEnd_ < 0, let _final_ be max(_len_ + _relativeEnd_, 0).
616
-
1. Else, let _final_ be min(_relativeEnd_, _len_).
679
+
1. <del>Let _relativeStart_ be ? ToIntegerOrInfinity(_start_).</del>
680
+
1. <del>If _relativeStart_ = -∞, let _first_ be 0.</del>
681
+
1. <del>Else if _relativeStart_ < 0, let _first_ be max(_len_ + _relativeStart_, 0).</del>
682
+
1. <del>Else, let _first_ be min(_relativeStart_, _len_).</del>
683
+
1. <del>If _end_ is *undefined*, let _relativeEnd_ be _len_; else let _relativeEnd_ be ? ToIntegerOrInfinity(_end_).</del>
684
+
1. <del>If _relativeEnd_ = -∞, let _final_ be 0.</del>
685
+
1. <del>Else if _relativeEnd_ < 0, let _final_ be max(_len_ + _relativeEnd_, 0).</del>
686
+
1. <del>Else, let _final_ be min(_relativeEnd_, _len_).</del>
687
+
1. <ins>Let _bounds_ be ? ResolveBounds(_len_, _start_, _end_).</ins>
688
+
1. <ins>Let _first_ be _bounds_.[[From]].</ins>
689
+
1. <ins>Let _final_ be _bounds_.[[To]].</ins>
617
690
1. Let _newLen_ be max(_final_ - _first_, 0).
618
691
1. Let _ctor_ be ? SpeciesConstructor(_O_, %ArrayBuffer%).
619
692
1. Let _new_ be ? Construct(_ctor_, « 𝔽(_newLen_) »).
@@ -635,6 +708,33 @@ contributors: Mark S. Miller, Richard Gibson
1. If IsSharedArrayBuffer(_O_) is *true*, throw a *TypeError* exception.
720
+
1. TODO: Confirm inclusion of this redundant check.
721
+
1. If IsDetachedBuffer(_O_) is *true*, throw a *TypeError* exception.
722
+
1. Let _len_ be _O_.[[ArrayBufferByteLength]].
723
+
1. Let _bounds_ be ? ResolveBounds(_len_, _start_, _end_).
724
+
1. Let _first_ be _bounds_.[[From]].
725
+
1. Let _final_ be _bounds_.[[To]].
726
+
1. TODO: Confirm this strictness vs. the conventional `max(_final_ - _first_, 0)`.
727
+
1. Let _newLen_ be _final_ - _first_.
728
+
1. If _newLen_ < 0, throw a *RangeError* exception.
729
+
1. Let _copyLen_ be min(_newLen_, _len_).
730
+
1. NOTE: Side-effects of the above steps may have detached or resized _O_. This algorithm proceeds only when _O_ is not detached, even if _newLen_ is 0.
731
+
1. If IsDetachedBuffer(_O_) is *true*, throw a *TypeError* exception.
732
+
1. Let _newBuffer_ be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, _newLen_, _O_.[[ArrayBufferData]], _first_, _copyLen_).
0 commit comments