From f70b9c6fdf728bdba58787a71ac4c14bea71daf5 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 27 Sep 2024 18:14:37 +0000 Subject: [PATCH 01/95] Initial gh-pages commit From da9b07ddb9acb85c5feba9348fcd90caa98bc34e Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 27 Sep 2024 18:14:37 +0000 Subject: [PATCH 02/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20Ag?= =?UTF-8?q?oric/tc39-proposal-immutable-arraybuffer@d3da23207fa9a5d72ad5a2?= =?UTF-8?q?4f687b5698f6bea5be=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 3330 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3330 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..f98058b --- /dev/null +++ b/index.html @@ -0,0 +1,3330 @@ + + + + + +Proposal Title Goes Here
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Stage -1 Draft / September 27, 2024

Proposal Title Goes Here

+ + +

1 This is an emu-clause

+

This is an algorithm:

+
  1. Let proposal be undefined.
  2. If IsAccepted(proposal) is true, then
    1. Let stage be 0.
  3. Else,
    1. Let stage be -1.
  4. Return ? ToString(stage).
+
+ + +

2 IsAccepted ( proposal )

+

The abstract operation IsAccepted takes argument proposal (an ECMAScript language value) and returns a Boolean. Tells you if the proposal was accepted It performs the following steps when called:

+
  1. If proposal is not a String, or is not accepted, return false.
  2. Return true.
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2024 Your Name(s) Here

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From af0ea1272356423236e4063cf4ed9ec35caf589e Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 27 Sep 2024 22:22:42 +0000 Subject: [PATCH 03/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20Ag?= =?UTF-8?q?oric/tc39-proposal-immutable-arraybuffer@7a301502c9bc26b8c7ff55?= =?UTF-8?q?5e4d5e02da1170955d=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 251 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 231 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index f98058b..5cc5f3c 100644 --- a/index.html +++ b/index.html @@ -1,17 +1,22 @@ - + Built-in Exotic Object Internal Methods and Slots + + + TypedArray Exotic Objects + + + + TypedArraySetElement ( + _O_: a TypedArray, + _index_: a Number, + _value_: an ECMAScript language value,"> -Proposal Title Goes Here
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 0 Draft / December 27, 2024

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks 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 The intersection of the sets of locations contained by two non-equal data blocks may be non-empty only when both data blocks are immutable and one is a strict subset of the other. Finally, Shared Data Blocks can be distinguished from Data Blocks.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field and mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
      9. If Desc has a [[Value]] field and mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If SameValue(O, Receiver) is true, then
        1. IsValidIntegerIndex(O, numericIndex) is true and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
        2. Perform ? TypedArraySetElement(O, numericIndex, V).
        3. Return true.
      2. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  2. Otherwise, let numValue be ? ToNumber(value).
  3. If IsValidIntegerIndex(O, index) is true and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  4. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached or immutable ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+ + +

23.2.3.26.1 SetTypedArrayFromTypedArray ( target, targetOffset, source )

+

The abstract operation SetTypedArrayFromTypedArray takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (a TypedArray) and returns either a normal completion containing unused or a throw completion. It sets multiple values in target, starting at index targetOffset, reading the values from source. It performs the following steps when called:

+
  1. Let targetBuffer be target.[[ViewedArrayBuffer]].
  2. Let targetRecord be MakeTypedArrayWithBufferWitnessRecord(target, seq-cst).
  3. If IsTypedArrayOutOfBounds(targetRecord) is true, throw a TypeError exception.
  4. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let targetLength be TypedArrayLength(targetRecord).
  6. Let srcBuffer be source.[[ViewedArrayBuffer]].
  7. Let srcRecord be MakeTypedArrayWithBufferWitnessRecord(source, seq-cst).
  8. If IsTypedArrayOutOfBounds(srcRecord) is true, throw a TypeError exception.
  9. Let srcLength be TypedArrayLength(srcRecord).
  10. Let targetType be TypedArrayElementType(target).
  11. Let targetElementSize be TypedArrayElementSize(target).
  12. Let targetByteOffset be target.[[ByteOffset]].
  13. Let srcType be TypedArrayElementType(source).
  14. Let srcElementSize be TypedArrayElementSize(source).
  15. Let srcByteOffset be source.[[ByteOffset]].
  16. If targetOffset = +∞, throw a RangeError exception.
  17. If srcLength + targetOffset > targetLength, throw a RangeError exception.
  18. If target.[[ContentType]] is not source.[[ContentType]], throw a TypeError exception.
  19. If IsSharedArrayBuffer(srcBuffer) is true, IsSharedArrayBuffer(targetBuffer) is true, and srcBuffer.[[ArrayBufferData]] is targetBuffer.[[ArrayBufferData]], let sameSharedArrayBuffer be true; otherwise, let sameSharedArrayBuffer be false.
  20. If SameValue(srcBuffer, targetBuffer) is true or sameSharedArrayBuffer is true, then
    1. Let srcByteLength be TypedArrayByteLength(srcRecord).
    2. Set srcBuffer to ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcByteLength).
    3. Let srcByteIndex be 0.
  21. Else,
    1. Let srcByteIndex be srcByteOffset.
  22. Let targetByteIndex be (targetOffset × targetElementSize) + targetByteOffset.
  23. Let limit be targetByteIndex + (targetElementSize × srcLength).
  24. If srcType is targetType, then
    1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Repeat, while targetByteIndex < limit,
      1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
      2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
      3. Set srcByteIndex to srcByteIndex + 1.
      4. Set targetByteIndex to targetByteIndex + 1.
  25. Else,
    1. Repeat, while targetByteIndex < limit,
      1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType, true, unordered).
      2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, unordered).
      3. Set srcByteIndex to srcByteIndex + srcElementSize.
      4. Set targetByteIndex to targetByteIndex + targetElementSize.
  26. Return unused.
+
+ + +

23.2.3.26.2 SetTypedArrayFromArrayLike ( target, targetOffset, source )

+

The abstract operation SetTypedArrayFromArrayLike takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (an ECMAScript language value, but not a TypedArray) and returns either a normal completion containing unused or a throw completion. It sets multiple values in target, starting at index targetOffset, reading the values from source. It performs the following steps when called:

+
  1. Let targetRecord be MakeTypedArrayWithBufferWitnessRecord(target, seq-cst).
  2. If IsTypedArrayOutOfBounds(targetRecord) is true, throw a TypeError exception.
  3. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let targetLength be TypedArrayLength(targetRecord).
  5. Let src be ? ToObject(source).
  6. Let srcLength be ? LengthOfArrayLike(src).
  7. If targetOffset = +∞, throw a RangeError exception.
  8. If srcLength + targetOffset > targetLength, throw a RangeError exception.
  9. Let k be 0.
  10. Repeat, while k < srcLength,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let value be ? Get(src, Pk).
    3. Let targetIndex be 𝔽(targetOffset + k).
    4. Perform ? TypedArraySetElement(target, targetIndex, value).
    5. Set k to k + 1.
  11. Return unused.
+
+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , use ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If use is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer. It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. 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 Data Block memory locations when fromBlock is the value of the [[ArrayBufferData]] slot for some other immutable ArrayBuffer (and therefore already immutable) and count = byteLength. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, count).
  6. Return newBuffer.
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  17. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  18. 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.
  19. Perform ! DetachArrayBuffer(arrayBuffer).
  20. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be max(final - first, 0).
  10. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  11. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  12. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  13. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  14. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  15. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  16. If SameValue(new, O) is true, throw a TypeError exception.
  17. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  18. NOTE: Side-effects of the above steps may have detached or resized O.
  19. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  20. Let fromBuf be O.[[ArrayBufferData]].
  21. Let toBuf be new.[[ArrayBufferData]].
  22. Let currentLen be O.[[ArrayBufferByteLength]].
  23. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  24. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. TODO: Confirm inclusion of this redundant check.
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. Let len be O.[[ArrayBufferByteLength]].
  7. Let bounds be ? ResolveBounds(len, start, end).
  8. Let first be bounds.[[From]].
  9. Let final be bounds.[[To]].
  10. TODO: Confirm this strictness vs. the conventional max(_final_ - _first_, 0).
  11. Let newLen be final - first.
  12. If newLen < 0, throw a RangeError exception.
  13. Let copyLen be min(newLen, len).
  14. 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.
  15. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  16. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, O.[[ArrayBufferData]], first, copyLen).
  17. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, use).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and use (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If use is not present, set use to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, use).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2024 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 7bdbbdc69771726a3c6063d63845f49f3ecbd853 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 27 Dec 2024 00:24:27 +0000 Subject: [PATCH 25/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@efac254ae57c714bc5ecc01d0e596?= =?UTF-8?q?120f40b2e45=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/21/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pr/21/index.html b/pr/21/index.html index 017ee7c..1aecee0 100644 --- a/pr/21/index.html +++ b/pr/21/index.html @@ -3452,7 +3452,7 @@

25.1.3.2 AllocateImmutableArrayBuffer ( con

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

-
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  17. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  18. 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.
  19. Perform ! DetachArrayBuffer(arrayBuffer).
  20. Return newBuffer.
+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  16. Let toBlock be newBuffer.[[ArrayBufferData]].
  17. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  18. 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.
  19. Perform ! DetachArrayBuffer(arrayBuffer).
  20. Return newBuffer.
@@ -3498,7 +3498,7 @@

25.1.6.6 ArrayBuffer.prototype.resize ( new

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

This method performs the following steps when called:

-
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be max(final - first, 0).
  10. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  11. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  12. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  13. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  14. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  15. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  16. If SameValue(new, O) is true, throw a TypeError exception.
  17. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  18. NOTE: Side-effects of the above steps may have detached or resized O.
  19. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  20. Let fromBuf be O.[[ArrayBufferData]].
  21. Let toBuf be new.[[ArrayBufferData]].
  22. Let currentLen be O.[[ArrayBufferByteLength]].
  23. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  24. Return new.
+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
From ba84bc159ddf51640779fcb9fe1c06abbc38c40d Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 27 Dec 2024 00:25:37 +0000 Subject: [PATCH 26/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@efac254ae57c714bc5ecc01d0e596?= =?UTF-8?q?120f40b2e45=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/21/index.html | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/pr/21/index.html b/pr/21/index.html index 1aecee0..952347a 100644 --- a/pr/21/index.html +++ b/pr/21/index.html @@ -1614,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-settypedarrayfromtypedarray":["_ref_11","_ref_12","_ref_13"],"sec-settypedarrayfromarraylike":["_ref_14","_ref_15"],"sec-%typedarray%.prototype.sort":["_ref_16"],"sec-validatetypedarray":["_ref_17"],"sec-allocatearraybuffer":["_ref_18"],"sec-allocateimmutablearraybuffer":["_ref_19","_ref_20","_ref_21","_ref_22"],"sec-arraybuffercopyanddetach":["_ref_23","_ref_24","_ref_25","_ref_26","_ref_27","_ref_28"],"sec-setvalueinbuffer":["_ref_29","_ref_30"],"sec-getmodifysetvalueinbuffer":["_ref_31","_ref_32","_ref_33"],"sec-get-arraybuffer.prototype.immutable":["_ref_34"],"sec-arraybuffer.prototype.resize":["_ref_35","_ref_36","_ref_37"],"sec-arraybuffer.prototype.slice":["_ref_38","_ref_39"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_40","_ref_41"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_42"],"sec-properties-of-the-arraybuffer-instances":["_ref_43"],"sec-setviewvalue":["_ref_44","_ref_45","_ref_46"],"sec-validateintegertypedarray":["_ref_47"],"sec-validateatomicaccessonintegertypedarray":["_ref_48"],"sec-atomicreadmodifywrite":["_ref_49","_ref_50","_ref_51","_ref_52"],"sec-atomics.compareexchange":["_ref_53"],"sec-atomics.store":["_ref_54","_ref_55"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_18","_ref_19","_ref_20","_ref_21","_ref_26","_ref_27","_ref_28","_ref_33","_ref_36","_ref_37","_ref_49","_ref_50"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_38","_ref_40"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4","_ref_15"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"op","aoid":"SetTypedArrayFromTypedArray","refId":"sec-settypedarrayfromtypedarray"},{"type":"clause","id":"sec-settypedarrayfromtypedarray","title":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","number":"23.2.3.26.1"},{"type":"op","aoid":"SetTypedArrayFromArrayLike","refId":"sec-settypedarrayfromarraylike"},{"type":"clause","id":"sec-settypedarrayfromarraylike","title":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","number":"23.2.3.26.2"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_16","_ref_47"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_29","_ref_31","_ref_44"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_22","_ref_25"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_24","_ref_41"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_42"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_11","_ref_14","_ref_17","_ref_23","_ref_30","_ref_32","_ref_34","_ref_35","_ref_39","_ref_45"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_12","_ref_13","_ref_46","_ref_55"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_52"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_43"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_48"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_51","_ref_53","_ref_54"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-settypedarrayfromtypedarray":["_ref_11","_ref_12","_ref_13"],"sec-settypedarrayfromarraylike":["_ref_14","_ref_15"],"sec-%typedarray%.prototype.sort":["_ref_16"],"sec-validatetypedarray":["_ref_17"],"sec-allocatearraybuffer":["_ref_18"],"sec-allocateimmutablearraybuffer":["_ref_19","_ref_20","_ref_21","_ref_22"],"sec-arraybuffercopyanddetach":["_ref_23","_ref_24","_ref_25","_ref_26","_ref_27"],"sec-setvalueinbuffer":["_ref_28","_ref_29"],"sec-getmodifysetvalueinbuffer":["_ref_30","_ref_31","_ref_32"],"sec-get-arraybuffer.prototype.immutable":["_ref_33"],"sec-arraybuffer.prototype.resize":["_ref_34","_ref_35","_ref_36"],"sec-arraybuffer.prototype.slice":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_39","_ref_40"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_41"],"sec-properties-of-the-arraybuffer-instances":["_ref_42"],"sec-setviewvalue":["_ref_43","_ref_44","_ref_45"],"sec-validateintegertypedarray":["_ref_46"],"sec-validateatomicaccessonintegertypedarray":["_ref_47"],"sec-atomicreadmodifywrite":["_ref_48","_ref_49","_ref_50","_ref_51"],"sec-atomics.compareexchange":["_ref_52"],"sec-atomics.store":["_ref_53","_ref_54"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_18","_ref_19","_ref_20","_ref_21","_ref_26","_ref_27","_ref_32","_ref_35","_ref_36","_ref_48","_ref_49"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_37","_ref_39"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4","_ref_15"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"op","aoid":"SetTypedArrayFromTypedArray","refId":"sec-settypedarrayfromtypedarray"},{"type":"clause","id":"sec-settypedarrayfromtypedarray","title":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","number":"23.2.3.26.1"},{"type":"op","aoid":"SetTypedArrayFromArrayLike","refId":"sec-settypedarrayfromarraylike"},{"type":"clause","id":"sec-settypedarrayfromarraylike","title":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","number":"23.2.3.26.2"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_16","_ref_46"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_28","_ref_30","_ref_43"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_22","_ref_25"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_24","_ref_40"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_41"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_11","_ref_14","_ref_17","_ref_23","_ref_29","_ref_31","_ref_33","_ref_34","_ref_38","_ref_44"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_12","_ref_13","_ref_45","_ref_54"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_51"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_42"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_47"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_50","_ref_52","_ref_53"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / December 27, 2024

Immutable ArrayBuffers

+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field and mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
      9. If Desc has a [[Value]] field and mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If SameValue(O, Receiver) is true, then
        1. IsValidIntegerIndex(O, numericIndex) is true and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
        2. Perform ? TypedArraySetElement(O, numericIndex, V).
        3. Return true.
      2. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  2. Otherwise, let numValue be ? ToNumber(value).
  3. If IsValidIntegerIndex(O, index) is true and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  4. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached or immutable ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+ + +

23.2.3.26.1 SetTypedArrayFromTypedArray ( target, targetOffset, source )

+

The abstract operation SetTypedArrayFromTypedArray takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (a TypedArray) and returns either a normal completion containing unused or a throw completion. It sets multiple values in target, starting at index targetOffset, reading the values from source. It performs the following steps when called:

+
  1. Let targetBuffer be target.[[ViewedArrayBuffer]].
  2. Let targetRecord be MakeTypedArrayWithBufferWitnessRecord(target, seq-cst).
  3. If IsTypedArrayOutOfBounds(targetRecord) is true, throw a TypeError exception.
  4. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let targetLength be TypedArrayLength(targetRecord).
  6. Let srcBuffer be source.[[ViewedArrayBuffer]].
  7. Let srcRecord be MakeTypedArrayWithBufferWitnessRecord(source, seq-cst).
  8. If IsTypedArrayOutOfBounds(srcRecord) is true, throw a TypeError exception.
  9. Let srcLength be TypedArrayLength(srcRecord).
  10. Let targetType be TypedArrayElementType(target).
  11. Let targetElementSize be TypedArrayElementSize(target).
  12. Let targetByteOffset be target.[[ByteOffset]].
  13. Let srcType be TypedArrayElementType(source).
  14. Let srcElementSize be TypedArrayElementSize(source).
  15. Let srcByteOffset be source.[[ByteOffset]].
  16. If targetOffset = +∞, throw a RangeError exception.
  17. If srcLength + targetOffset > targetLength, throw a RangeError exception.
  18. If target.[[ContentType]] is not source.[[ContentType]], throw a TypeError exception.
  19. If IsSharedArrayBuffer(srcBuffer) is true, IsSharedArrayBuffer(targetBuffer) is true, and srcBuffer.[[ArrayBufferData]] is targetBuffer.[[ArrayBufferData]], let sameSharedArrayBuffer be true; otherwise, let sameSharedArrayBuffer be false.
  20. If SameValue(srcBuffer, targetBuffer) is true or sameSharedArrayBuffer is true, then
    1. Let srcByteLength be TypedArrayByteLength(srcRecord).
    2. Set srcBuffer to ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcByteLength).
    3. Let srcByteIndex be 0.
  21. Else,
    1. Let srcByteIndex be srcByteOffset.
  22. Let targetByteIndex be (targetOffset × targetElementSize) + targetByteOffset.
  23. Let limit be targetByteIndex + (targetElementSize × srcLength).
  24. If srcType is targetType, then
    1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Repeat, while targetByteIndex < limit,
      1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
      2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
      3. Set srcByteIndex to srcByteIndex + 1.
      4. Set targetByteIndex to targetByteIndex + 1.
  25. Else,
    1. Repeat, while targetByteIndex < limit,
      1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType, true, unordered).
      2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, unordered).
      3. Set srcByteIndex to srcByteIndex + srcElementSize.
      4. Set targetByteIndex to targetByteIndex + targetElementSize.
  26. Return unused.
+
+ + +

23.2.3.26.2 SetTypedArrayFromArrayLike ( target, targetOffset, source )

+

The abstract operation SetTypedArrayFromArrayLike takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (an ECMAScript language value, but not a TypedArray) and returns either a normal completion containing unused or a throw completion. It sets multiple values in target, starting at index targetOffset, reading the values from source. It performs the following steps when called:

+
  1. Let targetRecord be MakeTypedArrayWithBufferWitnessRecord(target, seq-cst).
  2. If IsTypedArrayOutOfBounds(targetRecord) is true, throw a TypeError exception.
  3. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let targetLength be TypedArrayLength(targetRecord).
  5. Let src be ? ToObject(source).
  6. Let srcLength be ? LengthOfArrayLike(src).
  7. If targetOffset = +∞, throw a RangeError exception.
  8. If srcLength + targetOffset > targetLength, throw a RangeError exception.
  9. Let k be 0.
  10. Repeat, while k < srcLength,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let value be ? Get(src, Pk).
    3. Let targetIndex be 𝔽(targetOffset + k).
    4. Perform ? TypedArraySetElement(target, targetIndex, value).
    5. Set k to k + 1.
  11. Return unused.
+
+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , use ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If use is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer. It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  8. Else if preserveResizability is immutable, then
    1. Let newMaxByteLength be immutable.
  9. Else,
    1. Let newMaxByteLength be empty.
  10. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  11. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  12. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  13. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  14. Let toBlock be newBuffer.[[ArrayBufferData]].
  15. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let newLen be max(final - first, 0).
  15. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  16. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  17. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  18. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  19. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  20. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  21. If SameValue(new, O) is true, throw a TypeError exception.
  22. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  23. NOTE: Side-effects of the above steps may have detached or resized O.
  24. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  25. Let fromBuf be O.[[ArrayBufferData]].
  26. Let toBuf be new.[[ArrayBufferData]].
  27. Let currentLen be O.[[ArrayBufferByteLength]].
  28. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  29. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, use).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and use (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If use is not present, set use to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, use).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2024 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 19c8ca6e4cb27494aed68cb1012f0671d841e9e7 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 27 Dec 2024 04:22:06 +0000 Subject: [PATCH 28/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@9e9299fe0dc89ab819b9ebb4ce507?= =?UTF-8?q?f366672e3e3=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index c55e677..83494f8 100644 --- a/index.html +++ b/index.html @@ -3299,7 +3299,7 @@

Proposal proposal-immutable-arraybuffer

Stage 0 Draft / December 27, 2024

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / December 27, 2024

Immutable ArrayBuffers

10 Ordinary and Exotic Objects Behaviours

From 33c6a12c7f9a188b24cec25e21a1d497f50c88d4 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 27 Dec 2024 21:08:07 +0000 Subject: [PATCH 29/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@de139cebdd6a08e2b370f302c85c2?= =?UTF-8?q?1583625ae5b=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/21/index.html | 69 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/pr/21/index.html b/pr/21/index.html index 952347a..dd03fe1 100644 --- a/pr/21/index.html +++ b/pr/21/index.html @@ -1,5 +1,4 @@ - - + + +
+ PR #21 +

+ This document is a preview of merging PR #21, resulting in commit de139cebdd6a08e2b370f302c85c21583625ae5b. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+
  • Toggle shortcuts help?
  • Toggle "can call user code" annotationsu
  • @@ -3291,14 +3348,14 @@

Proposal proposal-immutable-arraybuffer

Stage 0 Draft / December 27, 2024

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / December 27, 2024

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

6.2.9 Data Blocks

-

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks 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 The intersection of the sets of locations contained by two non-equal data blocks may be non-empty only when both data blocks are immutable and one is a strict subset of the other. Finally, Shared Data Blocks can be distinguished from Data Blocks.

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks 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 The intersection of the sets of locations contained by two non-equal data blocks may be non-empty only when both data blocks are immutable and either one is a strict subset of the other or both are strict subsets of an immutable common parent. Finally, Shared Data Blocks can be distinguished from Data Blocks.

@@ -3599,4 +3656,4 @@

Software License

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
\ No newline at end of file +
\ No newline at end of file From fc3d4580e823c87a686741ee75d910c7b0464cea Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 28 Dec 2024 03:07:51 +0000 Subject: [PATCH 30/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@69c859c35d319b0ae5c2931c3a845?= =?UTF-8?q?be940d09436=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 83494f8..f890c94 100644 --- a/index.html +++ b/index.html @@ -3299,7 +3299,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / December 27, 2024

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / December 28, 2024

Immutable ArrayBuffers

10 Ordinary and Exotic Objects Behaviours

From 4e711af54513ff0aa74c2f1cbf830b77ab86dd24 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 28 Dec 2024 03:21:17 +0000 Subject: [PATCH 31/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@69c859c35d319b0ae5c2931c3a845?= =?UTF-8?q?be940d09436=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/21/index.html | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/pr/21/index.html b/pr/21/index.html index dd03fe1..cb7924c 100644 --- a/pr/21/index.html +++ b/pr/21/index.html @@ -1613,7 +1613,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-settypedarrayfromtypedarray":["_ref_11","_ref_12","_ref_13"],"sec-settypedarrayfromarraylike":["_ref_14","_ref_15"],"sec-%typedarray%.prototype.sort":["_ref_16"],"sec-validatetypedarray":["_ref_17"],"sec-allocatearraybuffer":["_ref_18"],"sec-allocateimmutablearraybuffer":["_ref_19","_ref_20","_ref_21","_ref_22"],"sec-arraybuffercopyanddetach":["_ref_23","_ref_24","_ref_25","_ref_26","_ref_27"],"sec-setvalueinbuffer":["_ref_28","_ref_29"],"sec-getmodifysetvalueinbuffer":["_ref_30","_ref_31","_ref_32"],"sec-get-arraybuffer.prototype.immutable":["_ref_33"],"sec-arraybuffer.prototype.resize":["_ref_34","_ref_35","_ref_36"],"sec-arraybuffer.prototype.slice":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_39","_ref_40"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_41"],"sec-properties-of-the-arraybuffer-instances":["_ref_42"],"sec-setviewvalue":["_ref_43","_ref_44","_ref_45"],"sec-validateintegertypedarray":["_ref_46"],"sec-validateatomicaccessonintegertypedarray":["_ref_47"],"sec-atomicreadmodifywrite":["_ref_48","_ref_49","_ref_50","_ref_51"],"sec-atomics.compareexchange":["_ref_52"],"sec-atomics.store":["_ref_53","_ref_54"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_18","_ref_19","_ref_20","_ref_21","_ref_26","_ref_27","_ref_32","_ref_35","_ref_36","_ref_48","_ref_49"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_37","_ref_39"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4","_ref_15"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"op","aoid":"SetTypedArrayFromTypedArray","refId":"sec-settypedarrayfromtypedarray"},{"type":"clause","id":"sec-settypedarrayfromtypedarray","title":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","number":"23.2.3.26.1"},{"type":"op","aoid":"SetTypedArrayFromArrayLike","refId":"sec-settypedarrayfromarraylike"},{"type":"clause","id":"sec-settypedarrayfromarraylike","title":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","number":"23.2.3.26.2"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_16","_ref_46"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_28","_ref_30","_ref_43"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_22","_ref_25"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_24","_ref_40"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_41"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_11","_ref_14","_ref_17","_ref_23","_ref_29","_ref_31","_ref_33","_ref_34","_ref_38","_ref_44"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_12","_ref_13","_ref_45","_ref_54"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_51"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_42"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_47"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_50","_ref_52","_ref_53"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-settypedarrayfromtypedarray":["_ref_11","_ref_12","_ref_13"],"sec-settypedarrayfromarraylike":["_ref_14","_ref_15"],"sec-%typedarray%.prototype.sort":["_ref_16"],"sec-validatetypedarray":["_ref_17"],"sec-allocatearraybuffer":["_ref_18"],"sec-allocateimmutablearraybuffer":["_ref_19","_ref_20","_ref_21"],"sec-arraybuffercopyanddetach":["_ref_22","_ref_23","_ref_24","_ref_25","_ref_26","_ref_27"],"sec-setvalueinbuffer":["_ref_28","_ref_29"],"sec-getmodifysetvalueinbuffer":["_ref_30","_ref_31","_ref_32"],"sec-get-arraybuffer.prototype.immutable":["_ref_33"],"sec-arraybuffer.prototype.resize":["_ref_34","_ref_35","_ref_36"],"sec-arraybuffer.prototype.slice":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_39","_ref_40"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_41"],"sec-properties-of-the-arraybuffer-instances":["_ref_42"],"sec-setviewvalue":["_ref_43","_ref_44","_ref_45"],"sec-validateintegertypedarray":["_ref_46"],"sec-validateatomicaccessonintegertypedarray":["_ref_47"],"sec-atomicreadmodifywrite":["_ref_48","_ref_49","_ref_50","_ref_51"],"sec-atomics.compareexchange":["_ref_52"],"sec-atomics.store":["_ref_53","_ref_54"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_18","_ref_19","_ref_21","_ref_25","_ref_26","_ref_27","_ref_32","_ref_35","_ref_36","_ref_48","_ref_49"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_37","_ref_39"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4","_ref_15"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"op","aoid":"SetTypedArrayFromTypedArray","refId":"sec-settypedarrayfromtypedarray"},{"type":"clause","id":"sec-settypedarrayfromtypedarray","title":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","number":"23.2.3.26.1"},{"type":"op","aoid":"SetTypedArrayFromArrayLike","refId":"sec-settypedarrayfromarraylike"},{"type":"clause","id":"sec-settypedarrayfromarraylike","title":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","number":"23.2.3.26.2"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_16","_ref_46"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_28","_ref_30","_ref_43"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_20","_ref_24"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_23","_ref_40"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_41"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_11","_ref_14","_ref_17","_ref_22","_ref_29","_ref_31","_ref_33","_ref_34","_ref_38","_ref_44"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_12","_ref_13","_ref_45","_ref_54"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_51"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_42"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_47"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_50","_ref_52","_ref_53"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false + +
+ PR #24 +

+ This document is a preview of merging PR #24, resulting in commit aefb4d7fff2b3a941176d5484ada161734f84e47. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / January 1, 2025

Immutable ArrayBuffers

+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field and mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
      9. If Desc has a [[Value]] field and mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If SameValue(O, Receiver) is true, then
        1. IsValidIntegerIndex(O, numericIndex) is true and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
        2. Perform ? TypedArraySetElement(O, numericIndex, V).
        3. Return true.
      2. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  2. Otherwise, let numValue be ? ToNumber(value).
  3. If IsValidIntegerIndex(O, index) is true and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  4. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached or immutable ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+ + +

23.2.3.26.1 SetTypedArrayFromTypedArray ( target, targetOffset, source )

+

The abstract operation SetTypedArrayFromTypedArray takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (a TypedArray) and returns either a normal completion containing unused or a throw completion. It sets multiple values in target, starting at index targetOffset, reading the values from source. It performs the following steps when called:

+
  1. Let targetBuffer be target.[[ViewedArrayBuffer]].
  2. Let targetRecord be MakeTypedArrayWithBufferWitnessRecord(target, seq-cst).
  3. If IsTypedArrayOutOfBounds(targetRecord) is true, throw a TypeError exception.
  4. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let targetLength be TypedArrayLength(targetRecord).
  6. Let srcBuffer be source.[[ViewedArrayBuffer]].
  7. Let srcRecord be MakeTypedArrayWithBufferWitnessRecord(source, seq-cst).
  8. If IsTypedArrayOutOfBounds(srcRecord) is true, throw a TypeError exception.
  9. Let srcLength be TypedArrayLength(srcRecord).
  10. Let targetType be TypedArrayElementType(target).
  11. Let targetElementSize be TypedArrayElementSize(target).
  12. Let targetByteOffset be target.[[ByteOffset]].
  13. Let srcType be TypedArrayElementType(source).
  14. Let srcElementSize be TypedArrayElementSize(source).
  15. Let srcByteOffset be source.[[ByteOffset]].
  16. If targetOffset = +∞, throw a RangeError exception.
  17. If srcLength + targetOffset > targetLength, throw a RangeError exception.
  18. If target.[[ContentType]] is not source.[[ContentType]], throw a TypeError exception.
  19. If IsSharedArrayBuffer(srcBuffer) is true, IsSharedArrayBuffer(targetBuffer) is true, and srcBuffer.[[ArrayBufferData]] is targetBuffer.[[ArrayBufferData]], let sameSharedArrayBuffer be true; otherwise, let sameSharedArrayBuffer be false.
  20. If SameValue(srcBuffer, targetBuffer) is true or sameSharedArrayBuffer is true, then
    1. Let srcByteLength be TypedArrayByteLength(srcRecord).
    2. Set srcBuffer to ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcByteLength).
    3. Let srcByteIndex be 0.
  21. Else,
    1. Let srcByteIndex be srcByteOffset.
  22. Let targetByteIndex be (targetOffset × targetElementSize) + targetByteOffset.
  23. Let limit be targetByteIndex + (targetElementSize × srcLength).
  24. If srcType is targetType, then
    1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Repeat, while targetByteIndex < limit,
      1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
      2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
      3. Set srcByteIndex to srcByteIndex + 1.
      4. Set targetByteIndex to targetByteIndex + 1.
  25. Else,
    1. Repeat, while targetByteIndex < limit,
      1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType, true, unordered).
      2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, unordered).
      3. Set srcByteIndex to srcByteIndex + srcElementSize.
      4. Set targetByteIndex to targetByteIndex + targetElementSize.
  26. Return unused.
+
+ + +

23.2.3.26.2 SetTypedArrayFromArrayLike ( target, targetOffset, source )

+

The abstract operation SetTypedArrayFromArrayLike takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (an ECMAScript language value, but not a TypedArray) and returns either a normal completion containing unused or a throw completion. It sets multiple values in target, starting at index targetOffset, reading the values from source. It performs the following steps when called:

+
  1. Let targetRecord be MakeTypedArrayWithBufferWitnessRecord(target, seq-cst).
  2. If IsTypedArrayOutOfBounds(targetRecord) is true, throw a TypeError exception.
  3. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let targetLength be TypedArrayLength(targetRecord).
  5. Let src be ? ToObject(source).
  6. Let srcLength be ? LengthOfArrayLike(src).
  7. If targetOffset = +∞, throw a RangeError exception.
  8. If srcLength + targetOffset > targetLength, throw a RangeError exception.
  9. Let k be 0.
  10. Repeat, while k < srcLength,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let value be ? Get(src, Pk).
    3. Let targetIndex be 𝔽(targetOffset + k).
    4. Perform ? TypedArraySetElement(target, targetIndex, value).
    5. Set k to k + 1.
  11. Return unused.
+
+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , use ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If use is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer. It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  8. Else if preserveResizability is immutable, then
    1. Let newMaxByteLength be immutable.
  9. Else,
    1. Let newMaxByteLength be empty.
  10. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  11. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  12. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  13. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  14. Let toBlock be newBuffer.[[ArrayBufferData]].
  15. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let newLen be max(final - first, 0).
  15. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  16. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  17. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  18. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  19. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  20. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  21. If SameValue(new, O) is true, throw a TypeError exception.
  22. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  23. NOTE: Side-effects of the above steps may have detached or resized O.
  24. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  25. Let fromBuf be O.[[ArrayBufferData]].
  26. Let toBuf be new.[[ArrayBufferData]].
  27. Let currentLen be O.[[ArrayBufferByteLength]].
  28. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  29. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, use).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and use (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If use is not present, set use to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, use).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From bfa615791139d3547865547253d5abab8b8f34bc Mon Sep 17 00:00:00 2001 From: gibson042 Date: Wed, 1 Jan 2025 20:00:10 +0000 Subject: [PATCH 34/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@04b49a70e61dcd60447fcbdbc7fcc?= =?UTF-8?q?f5430ef413a=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index f890c94..298405f 100644 --- a/index.html +++ b/index.html @@ -3263,12 +3263,12 @@ @media print { @page :left { @bottom-right { - content: '© Ecma International 2024'; + content: '© Ecma International 2025'; } } @page :right { @bottom-left { - content: '© Ecma International 2024'; + content: '© Ecma International 2025'; } } @page :first { @@ -3299,7 +3299,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / December 28, 2024

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / January 1, 2025

Immutable ArrayBuffers

10 Ordinary and Exotic Objects Behaviours

@@ -3551,7 +3551,7 @@

25.4.11 Atomics.store ( typedArray, <

A Copyright & Software License

Copyright Notice

-

© 2024 Mark S. Miller, Richard Gibson

+

© 2025 Mark S. Miller, Richard Gibson

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

From e31b5e3f8cd853f82a55acc5e8ca157b2aa6f951 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Thu, 9 Jan 2025 23:55:34 +0000 Subject: [PATCH 35/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@04b49a70e61dcd60447fcbdbc7fcc?= =?UTF-8?q?f5430ef413a=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/21/index.html | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pr/21/index.html b/pr/21/index.html index 64872b2..041ed5f 100644 --- a/pr/21/index.html +++ b/pr/21/index.html @@ -1,4 +1,5 @@ - +
PR #21

- This document is a preview of merging PR #21, resulting in commit 02c3e615ab54130f06b398bce0f230bcd4d46be5. + This document is a preview of merging PR #21, resulting in commit e52a2d16d982618b70f8cc281eb55997c4412d75.

Do not reference it as authoritative in any way. @@ -3358,14 +3359,14 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / December 28, 2024

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / January 9, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

6.2.9 Data Blocks

-

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks 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 The intersection of the sets of locations contained by two non-equal data blocks may be non-empty only when both data blocks are immutable and either one is a strict subset of the other or both are strict subsets of an immutable common parent. Finally, Shared Data Blocks can be distinguished from Data Blocks.

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

@@ -3653,7 +3654,7 @@

25.4.11 Atomics.store ( typedArray, <

A Copyright & Software License

Copyright Notice

-

© 2024 Mark S. Miller, Richard Gibson

+

© 2025 Mark S. Miller, Richard Gibson

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

@@ -3669,4 +3670,4 @@

Software License

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
\ No newline at end of file + \ No newline at end of file From ed6a2361d1bd88022be7274f345be5e5ca553cc1 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 10 Jan 2025 00:09:05 +0000 Subject: [PATCH 36/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@f837afbb6a45b714eebdcf266c719?= =?UTF-8?q?1346cdd29ee=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 101 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 33 deletions(-) diff --git a/index.html b/index.html index 298405f..ac86aa4 100644 --- a/index.html +++ b/index.html @@ -1,17 +1,9 @@ - + Data Blocks + A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is addr"> @@ -1622,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-settypedarrayfromtypedarray":["_ref_11","_ref_12","_ref_13"],"sec-settypedarrayfromarraylike":["_ref_14","_ref_15"],"sec-%typedarray%.prototype.sort":["_ref_16"],"sec-validatetypedarray":["_ref_17"],"sec-arraybuffercopyanddetach":["_ref_18","_ref_19"],"sec-setvalueinbuffer":["_ref_20","_ref_21"],"sec-getmodifysetvalueinbuffer":["_ref_22","_ref_23"],"sec-get-arraybuffer.prototype.immutable":["_ref_24"],"sec-arraybuffer.prototype.resize":["_ref_25"],"sec-arraybuffer.prototype.slice":["_ref_26"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_27"],"sec-properties-of-the-arraybuffer-instances":["_ref_28"],"sec-setviewvalue":["_ref_29","_ref_30","_ref_31"],"sec-validateintegertypedarray":["_ref_32"],"sec-validateatomicaccessonintegertypedarray":["_ref_33"],"sec-atomicreadmodifywrite":["_ref_34","_ref_35"],"sec-atomics.compareexchange":["_ref_36"],"sec-atomics.store":["_ref_37","_ref_38"]},"entries":[{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4","_ref_15"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"op","aoid":"SetTypedArrayFromTypedArray","refId":"sec-settypedarrayfromtypedarray"},{"type":"clause","id":"sec-settypedarrayfromtypedarray","title":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","number":"23.2.3.26.1"},{"type":"op","aoid":"SetTypedArrayFromArrayLike","refId":"sec-settypedarrayfromarraylike"},{"type":"clause","id":"sec-settypedarrayfromarraylike","title":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","number":"23.2.3.26.2"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_16","_ref_32"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_20","_ref_22","_ref_29"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_19"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_27"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_11","_ref_14","_ref_17","_ref_18","_ref_21","_ref_23","_ref_24","_ref_25","_ref_26","_ref_30"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_12","_ref_13","_ref_31","_ref_38"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_35"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.8"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_28"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_33"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_34","_ref_36","_ref_37"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-settypedarrayfromtypedarray":["_ref_11","_ref_12","_ref_13"],"sec-settypedarrayfromarraylike":["_ref_14","_ref_15"],"sec-%typedarray%.prototype.sort":["_ref_16"],"sec-validatetypedarray":["_ref_17"],"sec-allocatearraybuffer":["_ref_18"],"sec-allocateimmutablearraybuffer":["_ref_19","_ref_20","_ref_21"],"sec-arraybuffercopyanddetach":["_ref_22","_ref_23","_ref_24","_ref_25","_ref_26","_ref_27"],"sec-setvalueinbuffer":["_ref_28","_ref_29"],"sec-getmodifysetvalueinbuffer":["_ref_30","_ref_31","_ref_32"],"sec-get-arraybuffer.prototype.immutable":["_ref_33"],"sec-arraybuffer.prototype.resize":["_ref_34","_ref_35","_ref_36"],"sec-arraybuffer.prototype.slice":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_39","_ref_40"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_41"],"sec-properties-of-the-arraybuffer-instances":["_ref_42"],"sec-setviewvalue":["_ref_43","_ref_44","_ref_45"],"sec-validateintegertypedarray":["_ref_46"],"sec-validateatomicaccessonintegertypedarray":["_ref_47"],"sec-atomicreadmodifywrite":["_ref_48","_ref_49","_ref_50","_ref_51"],"sec-atomics.compareexchange":["_ref_52"],"sec-atomics.store":["_ref_53","_ref_54"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_18","_ref_19","_ref_21","_ref_25","_ref_26","_ref_27","_ref_32","_ref_35","_ref_36","_ref_48","_ref_49"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_37","_ref_39"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4","_ref_15"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"op","aoid":"SetTypedArrayFromTypedArray","refId":"sec-settypedarrayfromtypedarray"},{"type":"clause","id":"sec-settypedarrayfromtypedarray","title":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","number":"23.2.3.26.1"},{"type":"op","aoid":"SetTypedArrayFromArrayLike","refId":"sec-settypedarrayfromarraylike"},{"type":"clause","id":"sec-settypedarrayfromarraylike","title":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","number":"23.2.3.26.2"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_16","_ref_46"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_28","_ref_30","_ref_43"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_20","_ref_24"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_23","_ref_40"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_41"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_11","_ref_14","_ref_17","_ref_22","_ref_29","_ref_31","_ref_33","_ref_34","_ref_38","_ref_44"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_12","_ref_13","_ref_45","_ref_54"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_51"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_42"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_47"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_50","_ref_52","_ref_53"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false + +
+ PR #28 +

+ This document is a preview of merging PR #28, resulting in commit 6382eb078cd6213ac52b22ef8315745de350234d. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / January 12, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field and mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
      9. If Desc has a [[Value]] field and mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If SameValue(O, Receiver) is true, then
        1. IsValidIntegerIndex(O, numericIndex) is true and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
        2. Perform ? TypedArraySetElement(O, numericIndex, V).
        3. Return true.
      2. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  2. Otherwise, let numValue be ? ToNumber(value).
  3. If IsValidIntegerIndex(O, index) is true and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  4. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached or immutable ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+ + +

23.2.3.26.1 SetTypedArrayFromTypedArray ( target, targetOffset, source )

+

The abstract operation SetTypedArrayFromTypedArray takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (a TypedArray) and returns either a normal completion containing unused or a throw completion. It sets multiple values in target, starting at index targetOffset, reading the values from source. It performs the following steps when called:

+
  1. Let targetBuffer be target.[[ViewedArrayBuffer]].
  2. Let targetRecord be MakeTypedArrayWithBufferWitnessRecord(target, seq-cst).
  3. If IsTypedArrayOutOfBounds(targetRecord) is true, throw a TypeError exception.
  4. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let targetLength be TypedArrayLength(targetRecord).
  6. Let srcBuffer be source.[[ViewedArrayBuffer]].
  7. Let srcRecord be MakeTypedArrayWithBufferWitnessRecord(source, seq-cst).
  8. If IsTypedArrayOutOfBounds(srcRecord) is true, throw a TypeError exception.
  9. Let srcLength be TypedArrayLength(srcRecord).
  10. Let targetType be TypedArrayElementType(target).
  11. Let targetElementSize be TypedArrayElementSize(target).
  12. Let targetByteOffset be target.[[ByteOffset]].
  13. Let srcType be TypedArrayElementType(source).
  14. Let srcElementSize be TypedArrayElementSize(source).
  15. Let srcByteOffset be source.[[ByteOffset]].
  16. If targetOffset = +∞, throw a RangeError exception.
  17. If srcLength + targetOffset > targetLength, throw a RangeError exception.
  18. If target.[[ContentType]] is not source.[[ContentType]], throw a TypeError exception.
  19. If IsSharedArrayBuffer(srcBuffer) is true, IsSharedArrayBuffer(targetBuffer) is true, and srcBuffer.[[ArrayBufferData]] is targetBuffer.[[ArrayBufferData]], let sameSharedArrayBuffer be true; otherwise, let sameSharedArrayBuffer be false.
  20. If SameValue(srcBuffer, targetBuffer) is true or sameSharedArrayBuffer is true, then
    1. Let srcByteLength be TypedArrayByteLength(srcRecord).
    2. Set srcBuffer to ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcByteLength).
    3. Let srcByteIndex be 0.
  21. Else,
    1. Let srcByteIndex be srcByteOffset.
  22. Let targetByteIndex be (targetOffset × targetElementSize) + targetByteOffset.
  23. Let limit be targetByteIndex + (targetElementSize × srcLength).
  24. If srcType is targetType, then
    1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Repeat, while targetByteIndex < limit,
      1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
      2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
      3. Set srcByteIndex to srcByteIndex + 1.
      4. Set targetByteIndex to targetByteIndex + 1.
  25. Else,
    1. Repeat, while targetByteIndex < limit,
      1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType, true, unordered).
      2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, unordered).
      3. Set srcByteIndex to srcByteIndex + srcElementSize.
      4. Set targetByteIndex to targetByteIndex + targetElementSize.
  26. Return unused.
+
+ + +

23.2.3.26.2 SetTypedArrayFromArrayLike ( target, targetOffset, source )

+

The abstract operation SetTypedArrayFromArrayLike takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (an ECMAScript language value, but not a TypedArray) and returns either a normal completion containing unused or a throw completion. It sets multiple values in target, starting at index targetOffset, reading the values from source. It performs the following steps when called:

+
  1. Let targetRecord be MakeTypedArrayWithBufferWitnessRecord(target, seq-cst).
  2. If IsTypedArrayOutOfBounds(targetRecord) is true, throw a TypeError exception.
  3. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let targetLength be TypedArrayLength(targetRecord).
  5. Let src be ? ToObject(source).
  6. Let srcLength be ? LengthOfArrayLike(src).
  7. If targetOffset = +∞, throw a RangeError exception.
  8. If srcLength + targetOffset > targetLength, throw a RangeError exception.
  9. Let k be 0.
  10. Repeat, while k < srcLength,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let value be ? Get(src, Pk).
    3. Let targetIndex be 𝔽(targetOffset + k).
    4. Perform ? TypedArraySetElement(target, targetIndex, value).
    5. Set k to k + 1.
  11. Return unused.
+
+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , use ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If use is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer. It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. TODO: Confirm this strictness vs. slice (rejecting negative newLen rather than clamping to 0).
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, use).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and use (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If use is not present, set use to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, use).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 9826c30207b682f4f0a01cdd5076f4cc6ed91578 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sun, 12 Jan 2025 06:21:17 +0000 Subject: [PATCH 38/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@94efda2d1c77f510b25d3a5d94d79?= =?UTF-8?q?4b1631dbda9=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index ac86aa4..a6d4714 100644 --- a/index.html +++ b/index.html @@ -1614,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-settypedarrayfromtypedarray":["_ref_11","_ref_12","_ref_13"],"sec-settypedarrayfromarraylike":["_ref_14","_ref_15"],"sec-%typedarray%.prototype.sort":["_ref_16"],"sec-validatetypedarray":["_ref_17"],"sec-allocatearraybuffer":["_ref_18"],"sec-allocateimmutablearraybuffer":["_ref_19","_ref_20","_ref_21"],"sec-arraybuffercopyanddetach":["_ref_22","_ref_23","_ref_24","_ref_25","_ref_26","_ref_27"],"sec-setvalueinbuffer":["_ref_28","_ref_29"],"sec-getmodifysetvalueinbuffer":["_ref_30","_ref_31","_ref_32"],"sec-get-arraybuffer.prototype.immutable":["_ref_33"],"sec-arraybuffer.prototype.resize":["_ref_34","_ref_35","_ref_36"],"sec-arraybuffer.prototype.slice":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_39","_ref_40"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_41"],"sec-properties-of-the-arraybuffer-instances":["_ref_42"],"sec-setviewvalue":["_ref_43","_ref_44","_ref_45"],"sec-validateintegertypedarray":["_ref_46"],"sec-validateatomicaccessonintegertypedarray":["_ref_47"],"sec-atomicreadmodifywrite":["_ref_48","_ref_49","_ref_50","_ref_51"],"sec-atomics.compareexchange":["_ref_52"],"sec-atomics.store":["_ref_53","_ref_54"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_18","_ref_19","_ref_21","_ref_25","_ref_26","_ref_27","_ref_32","_ref_35","_ref_36","_ref_48","_ref_49"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_37","_ref_39"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4","_ref_15"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"op","aoid":"SetTypedArrayFromTypedArray","refId":"sec-settypedarrayfromtypedarray"},{"type":"clause","id":"sec-settypedarrayfromtypedarray","title":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","number":"23.2.3.26.1"},{"type":"op","aoid":"SetTypedArrayFromArrayLike","refId":"sec-settypedarrayfromarraylike"},{"type":"clause","id":"sec-settypedarrayfromarraylike","title":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","number":"23.2.3.26.2"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_16","_ref_46"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_28","_ref_30","_ref_43"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_20","_ref_24"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_23","_ref_40"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_41"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_11","_ref_14","_ref_17","_ref_22","_ref_29","_ref_31","_ref_33","_ref_34","_ref_38","_ref_44"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_12","_ref_13","_ref_45","_ref_54"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_51"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_42"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_47"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_50","_ref_52","_ref_53"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-settypedarrayfromtypedarray":["_ref_11","_ref_12","_ref_13"],"sec-settypedarrayfromarraylike":["_ref_14","_ref_15"],"sec-%typedarray%.prototype.sort":["_ref_16"],"sec-validatetypedarray":["_ref_17"],"sec-allocatearraybuffer":["_ref_18"],"sec-allocateimmutablearraybuffer":["_ref_19","_ref_20","_ref_21","_ref_22"],"sec-arraybuffercopyanddetach":["_ref_23","_ref_24","_ref_25","_ref_26","_ref_27"],"sec-setvalueinbuffer":["_ref_28","_ref_29"],"sec-getmodifysetvalueinbuffer":["_ref_30","_ref_31","_ref_32"],"sec-get-arraybuffer.prototype.immutable":["_ref_33"],"sec-arraybuffer.prototype.resize":["_ref_34","_ref_35","_ref_36"],"sec-arraybuffer.prototype.slice":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_39","_ref_40"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_41"],"sec-properties-of-the-arraybuffer-instances":["_ref_42"],"sec-setviewvalue":["_ref_43","_ref_44","_ref_45"],"sec-validateintegertypedarray":["_ref_46"],"sec-validateatomicaccessonintegertypedarray":["_ref_47"],"sec-atomicreadmodifywrite":["_ref_48","_ref_49","_ref_50","_ref_51"],"sec-atomics.compareexchange":["_ref_52"],"sec-atomics.store":["_ref_53","_ref_54"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_18","_ref_19","_ref_21","_ref_22","_ref_26","_ref_27","_ref_32","_ref_35","_ref_36","_ref_48","_ref_49"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_37","_ref_39"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4","_ref_15"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"op","aoid":"SetTypedArrayFromTypedArray","refId":"sec-settypedarrayfromtypedarray"},{"type":"clause","id":"sec-settypedarrayfromtypedarray","title":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromTypedArray ( target, targetOffset, source )","number":"23.2.3.26.1"},{"type":"op","aoid":"SetTypedArrayFromArrayLike","refId":"sec-settypedarrayfromarraylike"},{"type":"clause","id":"sec-settypedarrayfromarraylike","title":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","titleHTML":"SetTypedArrayFromArrayLike ( target, targetOffset, source )","number":"23.2.3.26.2"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_16","_ref_46"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_28","_ref_30","_ref_43"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_20","_ref_25"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_24","_ref_40"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_41"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_11","_ref_14","_ref_17","_ref_23","_ref_29","_ref_31","_ref_33","_ref_34","_ref_38","_ref_44"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_12","_ref_13","_ref_45","_ref_54"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_51"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_42"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_47"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_50","_ref_52","_ref_53"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false + +
+ PR #29 +

+ This document is a preview of merging PR #29, resulting in commit efcf5b4099deb141c8f3f4f485f92456c4f76af7. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / January 12, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      9. If Desc has a [[Value]] field, then
        1. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        2. If mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
        3. If mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: Let _taRecord_ be ? ValidateTypedArray(_O_, ~seq-cst~<ins>, ~write~</ins>). here would observably change the observable calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Such a change should be pursued.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , use ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If use is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer. It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. TODO: Confirm this strictness vs. slice (rejecting negative newLen rather than clamping to 0).
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, use).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and use (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If use is not present, set use to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, use).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From cf2d5cf4e18d494f428dbf45b960aab4baece885 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Mon, 13 Jan 2025 06:53:24 +0000 Subject: [PATCH 40/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@94efda2d1c77f510b25d3a5d94d79?= =?UTF-8?q?4b1631dbda9=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/29/index.html | 58 ++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/pr/29/index.html b/pr/29/index.html index 876f07c..87c116c 100644 --- a/pr/29/index.html +++ b/pr/29/index.html @@ -1614,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2","_ref_3"],"sec-typedarray-set":["_ref_4","_ref_5"],"sec-typedarraysetelement":["_ref_6","_ref_7"],"sec-%typedarray%.prototype.copywithin":["_ref_8","_ref_9"],"sec-%typedarray%.prototype.fill":["_ref_10"],"sec-%typedarray%.prototype.reverse":["_ref_11"],"sec-%typedarray%.prototype.set":["_ref_12"],"sec-%typedarray%.prototype.sort":["_ref_13"],"sec-validatetypedarray":["_ref_14"],"sec-allocatearraybuffer":["_ref_15"],"sec-allocateimmutablearraybuffer":["_ref_16","_ref_17","_ref_18","_ref_19"],"sec-arraybuffercopyanddetach":["_ref_20","_ref_21","_ref_22","_ref_23","_ref_24"],"sec-setvalueinbuffer":["_ref_25","_ref_26"],"sec-getmodifysetvalueinbuffer":["_ref_27","_ref_28","_ref_29"],"sec-get-arraybuffer.prototype.immutable":["_ref_30"],"sec-arraybuffer.prototype.resize":["_ref_31","_ref_32","_ref_33"],"sec-arraybuffer.prototype.slice":["_ref_34","_ref_35"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_36","_ref_37"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_38"],"sec-properties-of-the-arraybuffer-instances":["_ref_39"],"sec-setviewvalue":["_ref_40","_ref_41","_ref_42"],"sec-validateintegertypedarray":["_ref_43"],"sec-validateatomicaccessonintegertypedarray":["_ref_44"],"sec-atomicreadmodifywrite":["_ref_45","_ref_46","_ref_47","_ref_48"],"sec-atomics.compareexchange":["_ref_49"],"sec-atomics.store":["_ref_50","_ref_51"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_15","_ref_16","_ref_18","_ref_19","_ref_23","_ref_24","_ref_29","_ref_32","_ref_33","_ref_45","_ref_46"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_34","_ref_36"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_3","_ref_5"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_8","_ref_10","_ref_11","_ref_13","_ref_43"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_25","_ref_27","_ref_40"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_17","_ref_22"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_21","_ref_37"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_38"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_4","_ref_6","_ref_12","_ref_14","_ref_20","_ref_26","_ref_28","_ref_30","_ref_31","_ref_35","_ref_41"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_7","_ref_9","_ref_42","_ref_51"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_48"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_39"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_44"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_47","_ref_49","_ref_50"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2","_ref_3"],"sec-typedarray-set":["_ref_4","_ref_5"],"sec-typedarraysetelement":["_ref_6","_ref_7"],"sec-%typedarray%.prototype.copywithin":["_ref_8","_ref_9"],"sec-%typedarray%.prototype.fill":["_ref_10"],"sec-%typedarray%.prototype.reverse":["_ref_11"],"sec-%typedarray%.prototype.set":["_ref_12","_ref_13"],"sec-%typedarray%.prototype.sort":["_ref_14"],"sec-validatetypedarray":["_ref_15"],"sec-allocatearraybuffer":["_ref_16"],"sec-allocateimmutablearraybuffer":["_ref_17","_ref_18","_ref_19","_ref_20"],"sec-arraybuffercopyanddetach":["_ref_21","_ref_22","_ref_23","_ref_24","_ref_25"],"sec-setvalueinbuffer":["_ref_26","_ref_27"],"sec-getmodifysetvalueinbuffer":["_ref_28","_ref_29","_ref_30"],"sec-get-arraybuffer.prototype.immutable":["_ref_31"],"sec-arraybuffer.prototype.resize":["_ref_32","_ref_33","_ref_34"],"sec-arraybuffer.prototype.slice":["_ref_35","_ref_36"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_39"],"sec-properties-of-the-arraybuffer-instances":["_ref_40"],"sec-setviewvalue":["_ref_41","_ref_42","_ref_43"],"sec-validateintegertypedarray":["_ref_44"],"sec-validateatomicaccessonintegertypedarray":["_ref_45"],"sec-atomicreadmodifywrite":["_ref_46","_ref_47","_ref_48","_ref_49"],"sec-atomics.compareexchange":["_ref_50"],"sec-atomics.store":["_ref_51","_ref_52"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_16","_ref_17","_ref_19","_ref_20","_ref_24","_ref_25","_ref_30","_ref_33","_ref_34","_ref_46","_ref_47"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_35","_ref_37"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_3","_ref_5"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_8","_ref_10","_ref_11","_ref_12","_ref_14","_ref_44"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_26","_ref_28","_ref_41"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_18","_ref_23"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_22","_ref_38"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_39"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_4","_ref_6","_ref_13","_ref_15","_ref_21","_ref_27","_ref_29","_ref_31","_ref_32","_ref_36","_ref_42"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_7","_ref_9","_ref_43","_ref_52"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_49"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_40"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_45"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_48","_ref_50","_ref_51"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false + +
+ PR #32 +

+ This document is a preview of merging PR #32, resulting in commit f0fde7a2ea645b08d615171779e9290099bc4b4f. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 15, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
        1. Let current be ! O.[[GetOwnProperty]](P).
        2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
        3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
      3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
      4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      5. If IsAccessorDescriptor(Desc) is true, return false.
      6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
      7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      8. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , use ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If use is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer. It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. TODO: Confirm this strictness vs. slice (rejecting negative newLen rather than clamping to 0).
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument use (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If use is not present, set use to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, use).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and use (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If use is not present, set use to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, use).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From d8763efb29bf0c16d9b81498709687e96bd61c7c Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 17:14:17 +0000 Subject: [PATCH 44/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@4f18004de40df521ab9001d8ed333?= =?UTF-8?q?35415c83eae=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/33/index.html | 3667 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3667 insertions(+) create mode 100644 pr/33/index.html diff --git a/pr/33/index.html b/pr/33/index.html new file mode 100644 index 0000000..569b41e --- /dev/null +++ b/pr/33/index.html @@ -0,0 +1,3667 @@ + + + + + +Immutable ArrayBuffers + +
+ PR #33 +

+ This document is a preview of merging PR #33, resulting in commit e04608acdf0f4923a34395640fd3657ec8c7d8c8. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 15, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      9. If Desc has a [[Value]] field, then
        1. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        2. If mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
        3. If mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. TODO: Confirm this strictness vs. slice (rejecting negative newLen rather than clamping to 0).
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 9192654c1ef11f9d0ccec0fcf0db798b15f64fdd Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 17:21:52 +0000 Subject: [PATCH 45/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@3b2490050a3a298fd05e890ff4188?= =?UTF-8?q?c6092ee5ee5=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index 163da50..f959b2d 100644 --- a/index.html +++ b/index.html @@ -1614,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2","_ref_3"],"sec-typedarray-set":["_ref_4","_ref_5"],"sec-typedarraysetelement":["_ref_6","_ref_7"],"sec-%typedarray%.prototype.copywithin":["_ref_8","_ref_9"],"sec-%typedarray%.prototype.fill":["_ref_10"],"sec-%typedarray%.prototype.reverse":["_ref_11"],"sec-%typedarray%.prototype.set":["_ref_12","_ref_13"],"sec-%typedarray%.prototype.sort":["_ref_14"],"sec-validatetypedarray":["_ref_15"],"sec-allocatearraybuffer":["_ref_16"],"sec-allocateimmutablearraybuffer":["_ref_17","_ref_18","_ref_19","_ref_20"],"sec-arraybuffercopyanddetach":["_ref_21","_ref_22","_ref_23","_ref_24","_ref_25"],"sec-setvalueinbuffer":["_ref_26","_ref_27"],"sec-getmodifysetvalueinbuffer":["_ref_28","_ref_29","_ref_30"],"sec-get-arraybuffer.prototype.immutable":["_ref_31"],"sec-arraybuffer.prototype.resize":["_ref_32","_ref_33","_ref_34"],"sec-arraybuffer.prototype.slice":["_ref_35","_ref_36"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_39"],"sec-properties-of-the-arraybuffer-instances":["_ref_40"],"sec-setviewvalue":["_ref_41","_ref_42","_ref_43"],"sec-validateintegertypedarray":["_ref_44"],"sec-validateatomicaccessonintegertypedarray":["_ref_45"],"sec-atomicreadmodifywrite":["_ref_46","_ref_47","_ref_48","_ref_49"],"sec-atomics.compareexchange":["_ref_50"],"sec-atomics.store":["_ref_51","_ref_52"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_16","_ref_17","_ref_19","_ref_20","_ref_24","_ref_25","_ref_30","_ref_33","_ref_34","_ref_46","_ref_47"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_35","_ref_37"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_3","_ref_5"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , use ] )","titleHTML":"ValidateTypedArray ( O, order [ , use ] )","number":"23.2.4.4","referencingIds":["_ref_8","_ref_10","_ref_11","_ref_12","_ref_14","_ref_44"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_26","_ref_28","_ref_41"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_18","_ref_23"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_22","_ref_38"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_39"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_4","_ref_6","_ref_13","_ref_15","_ref_21","_ref_27","_ref_29","_ref_31","_ref_32","_ref_36","_ref_42"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_7","_ref_9","_ref_43","_ref_52"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_49"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_40"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , use ] )","number":"25.4.3.1","referencingIds":["_ref_45"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , use ] ] )","number":"25.4.3.3","referencingIds":["_ref_48","_ref_50","_ref_51"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2","_ref_3"],"sec-typedarray-set":["_ref_4","_ref_5"],"sec-typedarraysetelement":["_ref_6","_ref_7"],"sec-%typedarray%.prototype.copywithin":["_ref_8","_ref_9"],"sec-%typedarray%.prototype.fill":["_ref_10"],"sec-%typedarray%.prototype.reverse":["_ref_11"],"sec-%typedarray%.prototype.set":["_ref_12","_ref_13"],"sec-%typedarray%.prototype.sort":["_ref_14"],"sec-validatetypedarray":["_ref_15"],"sec-allocatearraybuffer":["_ref_16"],"sec-allocateimmutablearraybuffer":["_ref_17","_ref_18","_ref_19","_ref_20"],"sec-arraybuffercopyanddetach":["_ref_21","_ref_22","_ref_23","_ref_24","_ref_25"],"sec-setvalueinbuffer":["_ref_26","_ref_27"],"sec-getmodifysetvalueinbuffer":["_ref_28","_ref_29","_ref_30"],"sec-get-arraybuffer.prototype.immutable":["_ref_31"],"sec-arraybuffer.prototype.resize":["_ref_32","_ref_33","_ref_34"],"sec-arraybuffer.prototype.slice":["_ref_35","_ref_36"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_39"],"sec-properties-of-the-arraybuffer-instances":["_ref_40"],"sec-setviewvalue":["_ref_41","_ref_42","_ref_43"],"sec-validateintegertypedarray":["_ref_44"],"sec-validateatomicaccessonintegertypedarray":["_ref_45"],"sec-atomicreadmodifywrite":["_ref_46","_ref_47","_ref_48","_ref_49"],"sec-atomics.compareexchange":["_ref_50"],"sec-atomics.store":["_ref_51","_ref_52"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_16","_ref_17","_ref_19","_ref_20","_ref_24","_ref_25","_ref_30","_ref_33","_ref_34","_ref_46","_ref_47"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_35","_ref_37"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_3","_ref_5"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_8","_ref_10","_ref_11","_ref_12","_ref_14","_ref_44"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_26","_ref_28","_ref_41"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_18","_ref_23"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_22","_ref_38"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_39"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_4","_ref_6","_ref_13","_ref_15","_ref_21","_ref_27","_ref_29","_ref_31","_ref_32","_ref_36","_ref_42"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_7","_ref_9","_ref_43","_ref_52"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_49"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_40"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_45"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_48","_ref_50","_ref_51"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false + +
+ PR #34 +

+ This document is a preview of merging PR #34, resulting in commit f7661f55488d5a72350634fcfaa6e62a22e9b24c. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 15, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      9. If Desc has a [[Value]] field, then
        1. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        2. If mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
        3. If mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. NOTE: This differs from ArrayBuffer.prototype.slice ( start, end ), which instead clamps newLen to be non-negative.
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 79d6e86d7ab646b1e063b359e485166c52a34e18 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 17:33:36 +0000 Subject: [PATCH 47/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@2c584809ced7d8b480d9ab8db3ae6?= =?UTF-8?q?259f1497d17=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 68 +++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/index.html b/index.html index f959b2d..e654183 100644 --- a/index.html +++ b/index.html @@ -1614,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2","_ref_3"],"sec-typedarray-set":["_ref_4","_ref_5"],"sec-typedarraysetelement":["_ref_6","_ref_7"],"sec-%typedarray%.prototype.copywithin":["_ref_8","_ref_9"],"sec-%typedarray%.prototype.fill":["_ref_10"],"sec-%typedarray%.prototype.reverse":["_ref_11"],"sec-%typedarray%.prototype.set":["_ref_12","_ref_13"],"sec-%typedarray%.prototype.sort":["_ref_14"],"sec-validatetypedarray":["_ref_15"],"sec-allocatearraybuffer":["_ref_16"],"sec-allocateimmutablearraybuffer":["_ref_17","_ref_18","_ref_19","_ref_20"],"sec-arraybuffercopyanddetach":["_ref_21","_ref_22","_ref_23","_ref_24","_ref_25"],"sec-setvalueinbuffer":["_ref_26","_ref_27"],"sec-getmodifysetvalueinbuffer":["_ref_28","_ref_29","_ref_30"],"sec-get-arraybuffer.prototype.immutable":["_ref_31"],"sec-arraybuffer.prototype.resize":["_ref_32","_ref_33","_ref_34"],"sec-arraybuffer.prototype.slice":["_ref_35","_ref_36"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_39"],"sec-properties-of-the-arraybuffer-instances":["_ref_40"],"sec-setviewvalue":["_ref_41","_ref_42","_ref_43"],"sec-validateintegertypedarray":["_ref_44"],"sec-validateatomicaccessonintegertypedarray":["_ref_45"],"sec-atomicreadmodifywrite":["_ref_46","_ref_47","_ref_48","_ref_49"],"sec-atomics.compareexchange":["_ref_50"],"sec-atomics.store":["_ref_51","_ref_52"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_16","_ref_17","_ref_19","_ref_20","_ref_24","_ref_25","_ref_30","_ref_33","_ref_34","_ref_46","_ref_47"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_35","_ref_37"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_3","_ref_5"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_8","_ref_10","_ref_11","_ref_12","_ref_14","_ref_44"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_26","_ref_28","_ref_41"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_18","_ref_23"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_22","_ref_38"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_39"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_4","_ref_6","_ref_13","_ref_15","_ref_21","_ref_27","_ref_29","_ref_31","_ref_32","_ref_36","_ref_42"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_7","_ref_9","_ref_43","_ref_52"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_49"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_40"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_45"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_48","_ref_50","_ref_51"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-arraybuffer.prototype.slicetoimmutable":["_ref_0","_ref_38","_ref_39"],"sec-typedarray-getownproperty":["_ref_1"],"sec-typedarray-defineownproperty":["_ref_2","_ref_3","_ref_4"],"sec-typedarray-set":["_ref_5","_ref_6"],"sec-typedarraysetelement":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.copywithin":["_ref_9","_ref_10"],"sec-%typedarray%.prototype.fill":["_ref_11"],"sec-%typedarray%.prototype.reverse":["_ref_12"],"sec-%typedarray%.prototype.set":["_ref_13","_ref_14"],"sec-%typedarray%.prototype.sort":["_ref_15"],"sec-validatetypedarray":["_ref_16"],"sec-allocatearraybuffer":["_ref_17"],"sec-allocateimmutablearraybuffer":["_ref_18","_ref_19","_ref_20","_ref_21"],"sec-arraybuffercopyanddetach":["_ref_22","_ref_23","_ref_24","_ref_25","_ref_26"],"sec-setvalueinbuffer":["_ref_27","_ref_28"],"sec-getmodifysetvalueinbuffer":["_ref_29","_ref_30","_ref_31"],"sec-get-arraybuffer.prototype.immutable":["_ref_32"],"sec-arraybuffer.prototype.resize":["_ref_33","_ref_34","_ref_35"],"sec-arraybuffer.prototype.slice":["_ref_36","_ref_37"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_40"],"sec-properties-of-the-arraybuffer-instances":["_ref_41"],"sec-setviewvalue":["_ref_42","_ref_43","_ref_44"],"sec-validateintegertypedarray":["_ref_45"],"sec-validateatomicaccessonintegertypedarray":["_ref_46"],"sec-atomicreadmodifywrite":["_ref_47","_ref_48","_ref_49","_ref_50"],"sec-atomics.compareexchange":["_ref_51"],"sec-atomics.store":["_ref_52","_ref_53"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_17","_ref_18","_ref_20","_ref_21","_ref_25","_ref_26","_ref_31","_ref_34","_ref_35","_ref_47","_ref_48"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_36","_ref_38"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_3","_ref_4","_ref_6"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_9","_ref_11","_ref_12","_ref_13","_ref_15","_ref_45"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_27","_ref_29","_ref_42"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_19","_ref_24"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_23","_ref_39"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_40"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_1","_ref_2","_ref_5","_ref_7","_ref_14","_ref_16","_ref_22","_ref_28","_ref_30","_ref_32","_ref_33","_ref_37","_ref_43"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_8","_ref_10","_ref_44","_ref_53"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_50"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7","referencingIds":["_ref_0"]},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_41"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_46"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_49","_ref_51","_ref_52"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false + +
+ PR #35 +

+ This document is a preview of merging PR #35, resulting in commit 5c635d270203e1eac5b3183b69314a434e0db3ee. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 15, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      9. If Desc has a [[Value]] field, then
        1. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        2. If mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
        3. If mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. NOTE: This differs from ArrayBuffer.prototype.slice ( start, end ), which instead clamps newLen to be non-negative.
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 949c47127b0f20ec0d03b2b14ebdf5a99cd12570 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 17:58:53 +0000 Subject: [PATCH 49/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@7285e6a6f5c301ac3e29fa5a8038e?= =?UTF-8?q?d7f41ef5ad7=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index e654183..5ff168c 100644 --- a/index.html +++ b/index.html @@ -3448,7 +3448,9 @@

25.1.3.2 AllocateImmutableArrayBuffer ( con

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

-

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It performs the following steps when called:

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
From 4371b29c4698f57bff972af109e2f8544d0ce90a Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 18:28:05 +0000 Subject: [PATCH 50/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@7285e6a6f5c301ac3e29fa5a8038e?= =?UTF-8?q?d7f41ef5ad7=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/36/index.html | 3669 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3669 insertions(+) create mode 100644 pr/36/index.html diff --git a/pr/36/index.html b/pr/36/index.html new file mode 100644 index 0000000..2589a39 --- /dev/null +++ b/pr/36/index.html @@ -0,0 +1,3669 @@ + + + + + +Immutable ArrayBuffers + +
+ PR #36 +

+ This document is a preview of merging PR #36, resulting in commit 6b423a05f83fd9da2b6e7235ff71d09515f70356. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 15, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      9. If Desc has a [[Value]] field, then
        1. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        2. If mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
        3. If mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. NOTE: This differs from ArrayBuffer.prototype.slice ( start, end ), which instead clamps newLen to be non-negative.
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 3fb4bc48b030d3816312c43004cb9c3db9bc0aa6 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 18:30:05 +0000 Subject: [PATCH 51/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@d0427b056092f5fa839ad38983dcb?= =?UTF-8?q?c25d38c0176=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 5ff168c..99bb17c 100644 --- a/index.html +++ b/index.html @@ -3451,7 +3451,7 @@

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBu

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.

It performs the following steps when called:

-
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  8. If preserveResizability is immutable, then
    1. Return ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  9. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
    1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
  10. Else,
    1. Let newMaxByteLength be empty.
  11. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  12. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
  13. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  14. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
  15. Let toBlock be newBuffer.[[ArrayBufferData]].
  16. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
  17. 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.
  18. Perform ! DetachArrayBuffer(arrayBuffer).
  19. Return newBuffer.
+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
From 21b0567062e588f8661f125dfd311fe9a25d488c Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 18:33:40 +0000 Subject: [PATCH 52/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@d0427b056092f5fa839ad38983dcb?= =?UTF-8?q?c25d38c0176=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/37/index.html | 3669 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3669 insertions(+) create mode 100644 pr/37/index.html diff --git a/pr/37/index.html b/pr/37/index.html new file mode 100644 index 0000000..437fc16 --- /dev/null +++ b/pr/37/index.html @@ -0,0 +1,3669 @@ + + + + + +Immutable ArrayBuffers + +
+ PR #37 +

+ This document is a preview of merging PR #37, resulting in commit 4e3705a67f4a2e3ab4525f4741601cfce9925e22. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 15, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      9. If Desc has a [[Value]] field, then
        1. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        2. If mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
        3. If mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. NOTE: This differs from ArrayBuffer.prototype.slice ( start, end ), which instead clamps newLen to be non-negative.
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From b667bc826a738a529bc0bd283fcd80df969a2d1b Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 18:38:32 +0000 Subject: [PATCH 53/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@3c049b9fde02ad7396c68d82306f7?= =?UTF-8?q?07b5735acb6=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 99bb17c..3591708 100644 --- a/index.html +++ b/index.html @@ -3536,7 +3536,7 @@

25.3.1 Abstract Operations For DataView Objects<

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

-
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. Let getIndex be ? ToIndex(requestIndex).
  4. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  5. Otherwise, let numberValue be ? ToNumber(value).
  6. Set isLittleEndian to ToBoolean(isLittleEndian).
  7. Let viewOffset be view.[[ByteOffset]].
  8. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  9. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  10. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  11. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
From 56cbd9708a15082f9504b4e3af09c2e906fa0747 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 18:42:01 +0000 Subject: [PATCH 54/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@3c049b9fde02ad7396c68d82306f7?= =?UTF-8?q?07b5735acb6=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/38/index.html | 3678 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3678 insertions(+) create mode 100644 pr/38/index.html diff --git a/pr/38/index.html b/pr/38/index.html new file mode 100644 index 0000000..2d40dce --- /dev/null +++ b/pr/38/index.html @@ -0,0 +1,3678 @@ + + + + + +Immutable ArrayBuffers + +
+ PR #38 +

+ This document is a preview of merging PR #38, resulting in commit f7891ea25efd7ba3eb6aef64e21b4ee2dab34d45. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 15, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. Let mutable be true.
      3. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      4. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false not mutable, return false.
      5. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      6. If IsAccessorDescriptor(Desc) is true, return false.
      7. If Desc has a [[Writable]] field and Desc.[[Writable]] is false not mutable, return false.
      8. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      9. If Desc has a [[Value]] field, then
        1. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        2. If mutable is false and SameValue(Desc.[[Value]], TypedArrayGetElement(O, numericIndex)) is false, return false.
        3. If mutable is true, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      10. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

+

The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
  2. If key is not present, set key to undefined.
  3. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
  4. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  5. Set arrayBuffer.[[ArrayBufferData]] to null.
  6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
  7. Return unused.
+ Note
+

Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. NOTE: This differs from ArrayBuffer.prototype.slice ( start, end ), which instead clamps newLen to be non-negative.
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 1658d042b4ab6bf2b47d3b42c4139201991c5380 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 15 Feb 2025 18:52:01 +0000 Subject: [PATCH 55/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@e8588465c58dc2ec9ffea4c637964?= =?UTF-8?q?537562595f9=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/index.html b/index.html index 3591708..119afd2 100644 --- a/index.html +++ b/index.html @@ -1614,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-arraybuffer.prototype.slicetoimmutable":["_ref_0","_ref_38","_ref_39"],"sec-typedarray-getownproperty":["_ref_1"],"sec-typedarray-defineownproperty":["_ref_2","_ref_3","_ref_4"],"sec-typedarray-set":["_ref_5","_ref_6"],"sec-typedarraysetelement":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.copywithin":["_ref_9","_ref_10"],"sec-%typedarray%.prototype.fill":["_ref_11"],"sec-%typedarray%.prototype.reverse":["_ref_12"],"sec-%typedarray%.prototype.set":["_ref_13","_ref_14"],"sec-%typedarray%.prototype.sort":["_ref_15"],"sec-validatetypedarray":["_ref_16"],"sec-allocatearraybuffer":["_ref_17"],"sec-allocateimmutablearraybuffer":["_ref_18","_ref_19","_ref_20","_ref_21"],"sec-arraybuffercopyanddetach":["_ref_22","_ref_23","_ref_24","_ref_25","_ref_26"],"sec-setvalueinbuffer":["_ref_27","_ref_28"],"sec-getmodifysetvalueinbuffer":["_ref_29","_ref_30","_ref_31"],"sec-get-arraybuffer.prototype.immutable":["_ref_32"],"sec-arraybuffer.prototype.resize":["_ref_33","_ref_34","_ref_35"],"sec-arraybuffer.prototype.slice":["_ref_36","_ref_37"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_40"],"sec-properties-of-the-arraybuffer-instances":["_ref_41"],"sec-setviewvalue":["_ref_42","_ref_43","_ref_44"],"sec-validateintegertypedarray":["_ref_45"],"sec-validateatomicaccessonintegertypedarray":["_ref_46"],"sec-atomicreadmodifywrite":["_ref_47","_ref_48","_ref_49","_ref_50"],"sec-atomics.compareexchange":["_ref_51"],"sec-atomics.store":["_ref_52","_ref_53"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_17","_ref_18","_ref_20","_ref_21","_ref_25","_ref_26","_ref_31","_ref_34","_ref_35","_ref_47","_ref_48"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_36","_ref_38"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_3","_ref_4","_ref_6"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_9","_ref_11","_ref_12","_ref_13","_ref_15","_ref_45"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_27","_ref_29","_ref_42"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_19","_ref_24"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_23","_ref_39"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_40"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_1","_ref_2","_ref_5","_ref_7","_ref_14","_ref_16","_ref_22","_ref_28","_ref_30","_ref_32","_ref_33","_ref_37","_ref_43"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_8","_ref_10","_ref_44","_ref_53"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_50"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7","referencingIds":["_ref_0"]},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_41"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_46"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_49","_ref_51","_ref_52"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-arraybuffer.prototype.slicetoimmutable":["_ref_0","_ref_41","_ref_42"],"sec-typedarray-getownproperty":["_ref_1"],"sec-typedarray-defineownproperty":["_ref_2","_ref_3","_ref_4"],"sec-typedarray-set":["_ref_5","_ref_6"],"sec-typedarraysetelement":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.copywithin":["_ref_9","_ref_10"],"sec-%typedarray%.prototype.fill":["_ref_11"],"sec-%typedarray%.prototype.reverse":["_ref_12"],"sec-%typedarray%.prototype.set":["_ref_13","_ref_14"],"sec-%typedarray%.prototype.sort":["_ref_15"],"sec-validatetypedarray":["_ref_16"],"sec-allocatearraybuffer":["_ref_17"],"sec-allocateimmutablearraybuffer":["_ref_18","_ref_19","_ref_20","_ref_21"],"sec-arraybuffercopyanddetach":["_ref_22","_ref_23","_ref_24","_ref_25","_ref_26","_ref_27"],"sec-detacharraybuffer":["_ref_28","_ref_29"],"sec-setvalueinbuffer":["_ref_30","_ref_31"],"sec-getmodifysetvalueinbuffer":["_ref_32","_ref_33","_ref_34"],"sec-get-arraybuffer.prototype.immutable":["_ref_35"],"sec-arraybuffer.prototype.resize":["_ref_36","_ref_37","_ref_38"],"sec-arraybuffer.prototype.slice":["_ref_39","_ref_40"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_43"],"sec-properties-of-the-arraybuffer-instances":["_ref_44","_ref_45"],"sec-setviewvalue":["_ref_46","_ref_47","_ref_48"],"sec-validateintegertypedarray":["_ref_49"],"sec-validateatomicaccessonintegertypedarray":["_ref_50"],"sec-atomicreadmodifywrite":["_ref_51","_ref_52","_ref_53","_ref_54"],"sec-atomics.compareexchange":["_ref_55"],"sec-atomics.store":["_ref_56","_ref_57"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_17","_ref_18","_ref_20","_ref_21","_ref_25","_ref_26","_ref_29","_ref_34","_ref_37","_ref_38","_ref_51","_ref_52"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_39","_ref_41"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_3","_ref_4","_ref_6"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_9","_ref_11","_ref_12","_ref_13","_ref_15","_ref_49"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_30","_ref_32","_ref_46"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_19","_ref_24"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_23","_ref_42"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_43"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_1","_ref_2","_ref_5","_ref_7","_ref_14","_ref_16","_ref_22","_ref_28","_ref_31","_ref_33","_ref_35","_ref_36","_ref_40","_ref_47"]},{"type":"op","aoid":"DetachArrayBuffer","refId":"sec-detacharraybuffer"},{"type":"clause","id":"sec-detacharraybuffer","title":"DetachArrayBuffer ( arrayBuffer [ , key ] )","titleHTML":"DetachArrayBuffer ( arrayBuffer [ , key ] )","number":"25.1.3.5","referencingIds":["_ref_27","_ref_45"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_8","_ref_10","_ref_48","_ref_57"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_54"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7","referencingIds":["_ref_0"]},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_44"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_50"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_53","_ref_55","_ref_56"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false + +
+ PR #39 +

+ This document is a preview of merging PR #39, resulting in commit 265d383433d1cb93e239d7505f6c70874d3f8d4c. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 17, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
        1. Let current be ! O.[[GetOwnProperty]](P).
        2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
        3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
      3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
      4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      5. If IsAccessorDescriptor(Desc) is true, return false.
      6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
      7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      8. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

+

The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
  2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If key is not present, set key to undefined.
  4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
  5. Set arrayBuffer.[[ArrayBufferData]] to null.
  6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
  7. Return unused.
+ Note
+

Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. NOTE: This differs from ArrayBuffer.prototype.slice ( start, end ), which instead clamps newLen to be non-negative.
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 462a81ba2fffc4e370969bd2a0cb64c16ec3a883 Mon Sep 17 00:00:00 2001 From: erights Date: Tue, 18 Feb 2025 02:07:14 +0000 Subject: [PATCH 60/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@951732d96f14e2de39128e5da2bf3?= =?UTF-8?q?3064dbcfb86=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 5a8b45b..97cb1d5 100644 --- a/index.html +++ b/index.html @@ -3291,7 +3291,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 17, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 18, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

From 8e233e7a671b81d242f538def5f26855b234210d Mon Sep 17 00:00:00 2001 From: gibson042 Date: Tue, 18 Feb 2025 18:57:43 +0000 Subject: [PATCH 61/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@8618b6759a2c3d5d536f7fe5d7812?= =?UTF-8?q?78584c803c1=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/40/index.html | 3678 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3678 insertions(+) create mode 100644 pr/40/index.html diff --git a/pr/40/index.html b/pr/40/index.html new file mode 100644 index 0000000..0573e95 --- /dev/null +++ b/pr/40/index.html @@ -0,0 +1,3678 @@ + + + + + +Immutable ArrayBuffers + +
+ PR #40 +

+ This document is a preview of merging PR #40, resulting in commit 2f82eca5232bdf1926b8edd7444169ac90b449bf. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 18, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
        1. Let current be ! O.[[GetOwnProperty]](P).
        2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
        3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
      3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
      4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      5. If IsAccessorDescriptor(Desc) is true, return false.
      6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
      7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      8. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

+

The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
  2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If key is not present, set key to undefined.
  4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
  5. Set arrayBuffer.[[ArrayBufferData]] to null.
  6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
  7. Return unused.
+ Note
+

Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be final - first.
  10. NOTE: This differs from ArrayBuffer.prototype.slice ( start, end ), which instead clamps newLen to be non-negative.
  11. If newLen < 0, throw a RangeError exception.
  12. NOTE: Side-effects of the above steps may have detached or resized O.
  13. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  14. Let fromBuf be O.[[ArrayBufferData]].
  15. Let currentLen be O.[[ArrayBufferByteLength]].
  16. If currentLen < final, throw a RangeError exception.
  17. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  18. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 0d30adcc36a2a124751a86fb3a392e8672042805 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Tue, 18 Feb 2025 19:46:06 +0000 Subject: [PATCH 62/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@1dd81c7eb6ed553406973d690760b?= =?UTF-8?q?7aa296cfacf=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 97cb1d5..25cfca3 100644 --- a/index.html +++ b/index.html @@ -3530,7 +3530,7 @@

25.1.6.9 ArrayBuffer.prototype.transferToImmutab

25.1.7 Properties of ArrayBuffer Instances

-

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot.

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

From 1d8e8898c0ccbb79df5ad4b6c0c4bae3fb63dc8d Mon Sep 17 00:00:00 2001 From: gibson042 Date: Wed, 19 Feb 2025 00:04:26 +0000 Subject: [PATCH 63/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@1dd81c7eb6ed553406973d690760b?= =?UTF-8?q?7aa296cfacf=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/41/index.html | 3678 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3678 insertions(+) create mode 100644 pr/41/index.html diff --git a/pr/41/index.html b/pr/41/index.html new file mode 100644 index 0000000..70cedbc --- /dev/null +++ b/pr/41/index.html @@ -0,0 +1,3678 @@ + + + + + +Immutable ArrayBuffers + +
+ PR #41 +

+ This document is a preview of merging PR #41, resulting in commit 586f0764a5b29b05d6be820a61bf9be758a134cd. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 19, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
        1. Let current be ! O.[[GetOwnProperty]](P).
        2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
        3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
      3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
      4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      5. If IsAccessorDescriptor(Desc) is true, return false.
      6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
      7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      8. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

+

The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
  2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If key is not present, set key to undefined.
  4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
  5. Set arrayBuffer.[[ArrayBufferData]] to null.
  6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
  7. Return unused.
+ Note
+

Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be max(final - first, 0).
  10. NOTE: Side-effects of the above steps may have detached or resized O.
  11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  12. Let fromBuf be O.[[ArrayBufferData]].
  13. Let currentLen be O.[[ArrayBufferByteLength]].
  14. If currentLen < final, throw a RangeError exception.
  15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  16. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From d874e7c84af6872f3925a580d1e82f404bca9935 Mon Sep 17 00:00:00 2001 From: erights Date: Wed, 19 Feb 2025 00:15:40 +0000 Subject: [PATCH 64/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@c5a96d3616c5be8a0e9e40d765258?= =?UTF-8?q?3852db22c6f=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 76 +++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/index.html b/index.html index 25cfca3..a26b181 100644 --- a/index.html +++ b/index.html @@ -1614,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-arraybuffer.prototype.slicetoimmutable":["_ref_0","_ref_40","_ref_41"],"sec-typedarray-getownproperty":["_ref_1"],"sec-typedarray-defineownproperty":["_ref_2","_ref_3"],"sec-typedarray-set":["_ref_4","_ref_5"],"sec-typedarraysetelement":["_ref_6","_ref_7"],"sec-%typedarray%.prototype.copywithin":["_ref_8","_ref_9"],"sec-%typedarray%.prototype.fill":["_ref_10"],"sec-%typedarray%.prototype.reverse":["_ref_11"],"sec-%typedarray%.prototype.set":["_ref_12","_ref_13"],"sec-%typedarray%.prototype.sort":["_ref_14"],"sec-validatetypedarray":["_ref_15"],"sec-allocatearraybuffer":["_ref_16"],"sec-allocateimmutablearraybuffer":["_ref_17","_ref_18","_ref_19","_ref_20"],"sec-arraybuffercopyanddetach":["_ref_21","_ref_22","_ref_23","_ref_24","_ref_25","_ref_26"],"sec-detacharraybuffer":["_ref_27","_ref_28"],"sec-setvalueinbuffer":["_ref_29","_ref_30"],"sec-getmodifysetvalueinbuffer":["_ref_31","_ref_32","_ref_33"],"sec-get-arraybuffer.prototype.immutable":["_ref_34"],"sec-arraybuffer.prototype.resize":["_ref_35","_ref_36","_ref_37"],"sec-arraybuffer.prototype.slice":["_ref_38","_ref_39"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_42"],"sec-properties-of-the-arraybuffer-instances":["_ref_43","_ref_44"],"sec-setviewvalue":["_ref_45","_ref_46","_ref_47"],"sec-validateintegertypedarray":["_ref_48"],"sec-validateatomicaccessonintegertypedarray":["_ref_49"],"sec-atomicreadmodifywrite":["_ref_50","_ref_51","_ref_52","_ref_53"],"sec-atomics.compareexchange":["_ref_54"],"sec-atomics.store":["_ref_55","_ref_56"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_16","_ref_17","_ref_19","_ref_20","_ref_24","_ref_25","_ref_28","_ref_33","_ref_36","_ref_37","_ref_50","_ref_51"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_38","_ref_40"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_3","_ref_5"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_8","_ref_10","_ref_11","_ref_12","_ref_14","_ref_48"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_29","_ref_31","_ref_45"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_18","_ref_23"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_22","_ref_41"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_42"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_1","_ref_2","_ref_4","_ref_6","_ref_13","_ref_15","_ref_21","_ref_27","_ref_30","_ref_32","_ref_34","_ref_35","_ref_39","_ref_46"]},{"type":"op","aoid":"DetachArrayBuffer","refId":"sec-detacharraybuffer"},{"type":"clause","id":"sec-detacharraybuffer","title":"DetachArrayBuffer ( arrayBuffer [ , key ] )","titleHTML":"DetachArrayBuffer ( arrayBuffer [ , key ] )","number":"25.1.3.5","referencingIds":["_ref_26","_ref_44"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_7","_ref_9","_ref_47","_ref_56"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_53"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7","referencingIds":["_ref_0"]},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_43"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_49"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_52","_ref_54","_ref_55"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-%typedarray%.prototype.set":["_ref_11","_ref_12"],"sec-%typedarray%.prototype.sort":["_ref_13"],"sec-validatetypedarray":["_ref_14"],"sec-allocatearraybuffer":["_ref_15"],"sec-allocateimmutablearraybuffer":["_ref_16","_ref_17","_ref_18","_ref_19"],"sec-arraybuffercopyanddetach":["_ref_20","_ref_21","_ref_22","_ref_23","_ref_24","_ref_25"],"sec-detacharraybuffer":["_ref_26","_ref_27"],"sec-setvalueinbuffer":["_ref_28","_ref_29"],"sec-getmodifysetvalueinbuffer":["_ref_30","_ref_31","_ref_32"],"sec-get-arraybuffer.prototype.immutable":["_ref_33"],"sec-arraybuffer.prototype.resize":["_ref_34","_ref_35","_ref_36"],"sec-arraybuffer.prototype.slice":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_39","_ref_40"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_41"],"sec-properties-of-the-arraybuffer-instances":["_ref_42","_ref_43"],"sec-setviewvalue":["_ref_44","_ref_45","_ref_46"],"sec-validateintegertypedarray":["_ref_47"],"sec-validateatomicaccessonintegertypedarray":["_ref_48"],"sec-atomicreadmodifywrite":["_ref_49","_ref_50","_ref_51","_ref_52"],"sec-atomics.compareexchange":["_ref_53"],"sec-atomics.store":["_ref_54","_ref_55"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_15","_ref_16","_ref_18","_ref_19","_ref_23","_ref_24","_ref_27","_ref_32","_ref_35","_ref_36","_ref_49","_ref_50"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_37","_ref_39"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_11","_ref_13","_ref_47"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_28","_ref_30","_ref_44"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_17","_ref_22"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_21","_ref_40"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_41"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_12","_ref_14","_ref_20","_ref_26","_ref_29","_ref_31","_ref_33","_ref_34","_ref_38","_ref_45"]},{"type":"op","aoid":"DetachArrayBuffer","refId":"sec-detacharraybuffer"},{"type":"clause","id":"sec-detacharraybuffer","title":"DetachArrayBuffer ( arrayBuffer [ , key ] )","titleHTML":"DetachArrayBuffer ( arrayBuffer [ , key ] )","number":"25.1.3.5","referencingIds":["_ref_25","_ref_43"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_46","_ref_55"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_52"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_42"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_48"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_51","_ref_53","_ref_54"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false + +
+ PR #44 +

+ This document is a preview of merging PR #44, resulting in commit e055cf4c0065abf8c955d490bf3b43f0d85620ec. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 19, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
        1. Let current be ! O.[[GetOwnProperty]](P).
        2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
        3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
      3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
      4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      5. If IsAccessorDescriptor(Desc) is true, return false.
      6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
      7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      8. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities that may take place inside an implementation or observable by it. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

+

The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
  2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If key is not present, set key to undefined.
  4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
  5. Set arrayBuffer.[[ArrayBufferData]] to null.
  6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
  7. Return unused.
+ Note
+

Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be max(final - first, 0).
  10. NOTE: Side-effects of the above steps may have detached or resized O.
  11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  12. Let fromBuf be O.[[ArrayBufferData]].
  13. Let currentLen be O.[[ArrayBufferByteLength]].
  14. If currentLen < final, throw a RangeError exception.
  15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  16. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 28bdf9cb697ec1d2a34523959d267c8c9cdc8134 Mon Sep 17 00:00:00 2001 From: erights Date: Wed, 19 Feb 2025 05:28:35 +0000 Subject: [PATCH 66/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@02b087182c3d2181332bac96618bc?= =?UTF-8?q?9af70e74df0=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index a26b181..e15cde7 100644 --- a/index.html +++ b/index.html @@ -3475,13 +3475,13 @@

25.1.3.5 DetachArrayBuffer ( arrayBuffer

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

-
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 72 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

-
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 72 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
@@ -3545,7 +3545,7 @@

25.3.1 Abstract Operations For DataView Objects<

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

-
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 72 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
From 2f8722ec2233e7927f5f1076ab8e782ebd2786ef Mon Sep 17 00:00:00 2001 From: gibson042 Date: Wed, 19 Feb 2025 12:59:38 +0000 Subject: [PATCH 67/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@259548aeb028d5d8315cfa08d3176?= =?UTF-8?q?f8b73253364=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/44/index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pr/44/index.html b/pr/44/index.html index b12c0f3..7b3a3ea 100644 --- a/pr/44/index.html +++ b/pr/44/index.html @@ -3331,7 +3331,7 @@
PR #44

- This document is a preview of merging PR #44, resulting in commit e055cf4c0065abf8c955d490bf3b43f0d85620ec. + This document is a preview of merging PR #44, resulting in commit 46a078c530ea415fa253fc4d143028cb764c6d3a.

Do not reference it as authoritative in any way. @@ -3506,7 +3506,7 @@

25.1.3.1 AllocateArrayBuffer ( constructor<

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

-

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities that may take place inside an implementation or observable by it. It performs the following steps when called:

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities inside an implementation or observable by it. It performs the following steps when called:

  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
Note

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.

@@ -3543,13 +3543,13 @@

25.1.3.5 DetachArrayBuffer ( arrayBuffer

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

-
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 72 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

-
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 72 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
@@ -3613,7 +3613,7 @@

25.3.1 Abstract Operations For DataView Objects<

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

-
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 69 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 72 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
From 0fddc8d25f46c325c3cf179e84e87d948e769c35 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Wed, 19 Feb 2025 13:00:15 +0000 Subject: [PATCH 68/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@1063845503080955e0b7dc59833ab?= =?UTF-8?q?724f3451840=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/index.html b/index.html index e15cde7..e620bc6 100644 --- a/index.html +++ b/index.html @@ -1614,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-%typedarray%.prototype.set":["_ref_11","_ref_12"],"sec-%typedarray%.prototype.sort":["_ref_13"],"sec-validatetypedarray":["_ref_14"],"sec-allocatearraybuffer":["_ref_15"],"sec-allocateimmutablearraybuffer":["_ref_16","_ref_17","_ref_18","_ref_19"],"sec-arraybuffercopyanddetach":["_ref_20","_ref_21","_ref_22","_ref_23","_ref_24","_ref_25"],"sec-detacharraybuffer":["_ref_26","_ref_27"],"sec-setvalueinbuffer":["_ref_28","_ref_29"],"sec-getmodifysetvalueinbuffer":["_ref_30","_ref_31","_ref_32"],"sec-get-arraybuffer.prototype.immutable":["_ref_33"],"sec-arraybuffer.prototype.resize":["_ref_34","_ref_35","_ref_36"],"sec-arraybuffer.prototype.slice":["_ref_37","_ref_38"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_39","_ref_40"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_41"],"sec-properties-of-the-arraybuffer-instances":["_ref_42","_ref_43"],"sec-setviewvalue":["_ref_44","_ref_45","_ref_46"],"sec-validateintegertypedarray":["_ref_47"],"sec-validateatomicaccessonintegertypedarray":["_ref_48"],"sec-atomicreadmodifywrite":["_ref_49","_ref_50","_ref_51","_ref_52"],"sec-atomics.compareexchange":["_ref_53"],"sec-atomics.store":["_ref_54","_ref_55"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_15","_ref_16","_ref_18","_ref_19","_ref_23","_ref_24","_ref_27","_ref_32","_ref_35","_ref_36","_ref_49","_ref_50"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_37","_ref_39"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_11","_ref_13","_ref_47"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_28","_ref_30","_ref_44"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_17","_ref_22"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_21","_ref_40"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_41"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_12","_ref_14","_ref_20","_ref_26","_ref_29","_ref_31","_ref_33","_ref_34","_ref_38","_ref_45"]},{"type":"op","aoid":"DetachArrayBuffer","refId":"sec-detacharraybuffer"},{"type":"clause","id":"sec-detacharraybuffer","title":"DetachArrayBuffer ( arrayBuffer [ , key ] )","titleHTML":"DetachArrayBuffer ( arrayBuffer [ , key ] )","number":"25.1.3.5","referencingIds":["_ref_25","_ref_43"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_46","_ref_55"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_52"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_42"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_48"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_51","_ref_53","_ref_54"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.reverse":["_ref_10"],"sec-%typedarray%.prototype.set":["_ref_11","_ref_12"],"sec-%typedarray%.prototype.sort":["_ref_13"],"sec-validatetypedarray":["_ref_14"],"sec-allocatearraybuffer":["_ref_15"],"sec-allocateimmutablearraybuffer":["_ref_16","_ref_17","_ref_18","_ref_19","_ref_20"],"sec-arraybuffercopyanddetach":["_ref_21","_ref_22","_ref_23","_ref_24","_ref_25","_ref_26"],"sec-detacharraybuffer":["_ref_27","_ref_28"],"sec-setvalueinbuffer":["_ref_29","_ref_30"],"sec-getmodifysetvalueinbuffer":["_ref_31","_ref_32","_ref_33"],"sec-get-arraybuffer.prototype.immutable":["_ref_34"],"sec-arraybuffer.prototype.resize":["_ref_35","_ref_36","_ref_37"],"sec-arraybuffer.prototype.slice":["_ref_38","_ref_39"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_40","_ref_41"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_42"],"sec-properties-of-the-arraybuffer-instances":["_ref_43","_ref_44"],"sec-setviewvalue":["_ref_45","_ref_46","_ref_47"],"sec-validateintegertypedarray":["_ref_48"],"sec-validateatomicaccessonintegertypedarray":["_ref_49"],"sec-atomicreadmodifywrite":["_ref_50","_ref_51","_ref_52","_ref_53"],"sec-atomics.compareexchange":["_ref_54"],"sec-atomics.store":["_ref_55","_ref_56"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_15","_ref_16","_ref_17","_ref_19","_ref_20","_ref_24","_ref_25","_ref_28","_ref_33","_ref_36","_ref_37","_ref_50","_ref_51"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_38","_ref_40"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_11","_ref_13","_ref_48"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_29","_ref_31","_ref_45"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_18","_ref_23"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_22","_ref_41"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_42"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_12","_ref_14","_ref_21","_ref_27","_ref_30","_ref_32","_ref_34","_ref_35","_ref_39","_ref_46"]},{"type":"op","aoid":"DetachArrayBuffer","refId":"sec-detacharraybuffer"},{"type":"clause","id":"sec-detacharraybuffer","title":"DetachArrayBuffer ( arrayBuffer [ , key ] )","titleHTML":"DetachArrayBuffer ( arrayBuffer [ , key ] )","number":"25.1.3.5","referencingIds":["_ref_26","_ref_44"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_47","_ref_56"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_53"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_43"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_49"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_52","_ref_54","_ref_55"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false + +
+ PR #45 +

+ This document is a preview of merging PR #45, resulting in commit bcfca4c6cd9608d9a85c3f8cb1df74eb4d1c6565. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 21, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
        1. Let current be ! O.[[GetOwnProperty]](P).
        2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
        3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
      3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
      4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      5. If IsAccessorDescriptor(Desc) is true, return false.
      6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
      7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      8. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities inside an implementation or observable by it. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

+

The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
  2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If key is not present, set key to undefined.
  4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
  5. Set arrayBuffer.[[ArrayBufferData]] to null.
  6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
  7. Return unused.
+ Note
+

Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be max(final - first, 0).
  10. NOTE: Side-effects of the above steps may have detached or resized O.
  11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  12. Let fromBuf be O.[[ArrayBufferData]].
  13. Let currentLen be O.[[ArrayBufferByteLength]].
  14. If currentLen < final, throw a RangeError exception.
  15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  16. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 1f4016152226f2dc526c1d6967295100b9388972 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 21 Feb 2025 23:34:51 +0000 Subject: [PATCH 72/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@e8f6f4971589d5da65131a2e42bc4?= =?UTF-8?q?4d4dabd0acb=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 20e10b1..a0eab7d 100644 --- a/index.html +++ b/index.html @@ -3291,7 +3291,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 20, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 21, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

From 3a37229b5216e4a75fbfce57929ca33316e64ff2 Mon Sep 17 00:00:00 2001 From: erights Date: Sat, 22 Feb 2025 00:51:52 +0000 Subject: [PATCH 73/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@bad00bae35ac18c3684bbebf66efa?= =?UTF-8?q?89923b0451d=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index a0eab7d..443cd0f 100644 --- a/index.html +++ b/index.html @@ -3291,7 +3291,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 21, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 22, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

From 025a9c35f1ae421a8fd43d0615283983ba975b15 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Mon, 24 Feb 2025 20:19:56 +0000 Subject: [PATCH 74/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@bad00bae35ac18c3684bbebf66efa?= =?UTF-8?q?89923b0451d=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/47/index.html | 3708 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3708 insertions(+) create mode 100644 pr/47/index.html diff --git a/pr/47/index.html b/pr/47/index.html new file mode 100644 index 0000000..27d82c3 --- /dev/null +++ b/pr/47/index.html @@ -0,0 +1,3708 @@ + + + + + +Immutable ArrayBuffers + +
+ PR #47 +

+ This document is a preview of merging PR #47, resulting in commit 0b35b7bbf5f65613bd92ad69da02379d6bc7937b. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / February 24, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
        1. Let current be ! O.[[GetOwnProperty]](P).
        2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
        3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
      3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
      4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      5. If IsAccessorDescriptor(Desc) is true, return false.
      6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
      7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      8. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.10 %TypedArray%.prototype.filter ( callback [ , thisArg ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.filter as defined in 23.1.3.8.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
  3. Let len be TypedArrayLength(taRecord).
  4. If IsCallable(callback) is false, throw a TypeError exception.
  5. Let kept be a new empty List.
  6. Let captured be 0.
  7. Let k be 0.
  8. Repeat, while k < len,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let kValue be ! Get(O, Pk).
    3. Let selected be ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), O »)).
    4. If selected is true, then
      1. Append kValue to kept.
      2. Set captured to captured + 1.
    5. Set k to k + 1.
  9. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) », write).
  10. Let n be 0.
  11. For each element e of kept, do
    1. Perform !? Set(A, ! ToString(𝔽(n)), e, true).
    2. Set n to n + 1.
  12. Return A.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.22 %TypedArray%.prototype.map ( callback [ , thisArg ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.map as defined in 23.1.3.21.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
  3. Let len be TypedArrayLength(taRecord).
  4. If IsCallable(callback) is false, throw a TypeError exception.
  5. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(len) », write).
  6. Let k be 0.
  7. Repeat, while k < len,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let kValue be ! Get(O, Pk).
    3. Let mappedValue be ? Call(callback, thisArg, « kValue, 𝔽(k), O »).
    4. Perform ? Set(A, Pk, mappedValue, true).
    5. Set k to k + 1.
  8. Return A.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.27 %TypedArray%.prototype.slice ( start, end )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.slice as defined in 23.1.3.28.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
  3. Let srcArrayLength be TypedArrayLength(taRecord).
  4. Let relativeStart be ? ToIntegerOrInfinity(start).
  5. If relativeStart = -∞, let startIndex be 0.
  6. Else if relativeStart < 0, let startIndex be max(srcArrayLength + relativeStart, 0).
  7. Else, let startIndex be min(relativeStart, srcArrayLength).
  8. If end is undefined, let relativeEnd be srcArrayLength; else let relativeEnd be ? ToIntegerOrInfinity(end).
  9. If relativeEnd = -∞, let endIndex be 0.
  10. Else if relativeEnd < 0, let endIndex be max(srcArrayLength + relativeEnd, 0).
  11. Else, let endIndex be min(relativeEnd, srcArrayLength).
  12. Let countBytes be max(endIndex - startIndex, 0).
  13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(countBytes) », write).
  14. If countBytes > 0, then
    1. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    2. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    3. Set endIndex to min(endIndex, TypedArrayLength(taRecord)).
    4. Set countBytes to max(endIndex - startIndex, 0).
    5. Let srcType be TypedArrayElementType(O).
    6. Let targetType be TypedArrayElementType(A).
    7. If srcType is targetType, then
      1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
      2. Let srcBuffer be O.[[ViewedArrayBuffer]].
      3. Let targetBuffer be A.[[ViewedArrayBuffer]].
      4. Let elementSize be TypedArrayElementSize(O).
      5. Let srcByteOffset be O.[[ByteOffset]].
      6. Let srcByteIndex be (startIndex × elementSize) + srcByteOffset.
      7. Let targetByteIndex be A.[[ByteOffset]].
      8. Let endByteIndex be targetByteIndex + (countBytes × elementSize).
      9. Repeat, while targetByteIndex < endByteIndex,
        1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
        3. Set srcByteIndex to srcByteIndex + 1.
        4. Set targetByteIndex to targetByteIndex + 1.
    8. Else,
      1. Let n be 0.
      2. Let k be startIndex.
      3. Repeat, while k < endIndex,
        1. Let Pk be ! ToString(𝔽(k)).
        2. Let kValue be ! Get(O, Pk).
        3. Perform !? Set(A, ! ToString(𝔽(n)), kValue, true).
        4. Set k to k + 1.
        5. Set n to n + 1.
  15. Return A.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.1 TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )

+

The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a TypedArray) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function that is derived from exemplar. Unlike ArraySpeciesCreate, which can create non-Array objects through the use of %Symbol.species%, this operation enforces that the constructor function creates an actual TypedArray. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73.
  3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
  4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList).
  5. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots.
  6. Assert: result has all of the internal slots of a TypedArray instance (23.2.8).
  7. If result.[[ContentType]] is not exemplar.[[ContentType]], throw a TypeError exception.
  8. If accessMode is write and IsImmutableBuffer(result.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  9. Return result.
+
+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities inside an implementation or observable by it. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

+

The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
  2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If key is not present, set key to undefined.
  4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
  5. Set arrayBuffer.[[ArrayBufferData]] to null.
  6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
  7. Return unused.
+ Note
+

Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be max(final - first, 0).
  10. NOTE: Side-effects of the above steps may have detached or resized O.
  11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  12. Let fromBuf be O.[[ArrayBufferData]].
  13. Let currentLen be O.[[ArrayBufferByteLength]].
  14. If currentLen < final, throw a RangeError exception.
  15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  16. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2025 Mark S. Miller, Richard Gibson

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 4ccc2438d8875cc149ccf8d098d1193d06710f48 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Tue, 25 Feb 2025 17:12:27 +0000 Subject: [PATCH 75/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@bad00bae35ac18c3684bbebf66efa?= =?UTF-8?q?89923b0451d=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/47/index.html | 106 ++++++++++++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 39 deletions(-) diff --git a/pr/47/index.html b/pr/47/index.html index 27d82c3..eff8a5b 100644 --- a/pr/47/index.html +++ b/pr/47/index.html @@ -1614,7 +1614,7 @@ }); let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.prototype.copywithin":["_ref_7","_ref_8"],"sec-%typedarray%.prototype.fill":["_ref_9"],"sec-%typedarray%.prototype.filter":["_ref_10","_ref_11"],"sec-%typedarray%.prototype.map":["_ref_12","_ref_13"],"sec-%typedarray%.prototype.reverse":["_ref_14"],"sec-%typedarray%.prototype.set":["_ref_15","_ref_16"],"sec-%typedarray%.prototype.slice":["_ref_17","_ref_18","_ref_19"],"sec-%typedarray%.prototype.sort":["_ref_20"],"typedarray-species-create":["_ref_21"],"sec-validatetypedarray":["_ref_22"],"sec-allocatearraybuffer":["_ref_23"],"sec-allocateimmutablearraybuffer":["_ref_24","_ref_25","_ref_26","_ref_27","_ref_28"],"sec-arraybuffercopyanddetach":["_ref_29","_ref_30","_ref_31","_ref_32","_ref_33","_ref_34"],"sec-detacharraybuffer":["_ref_35","_ref_36"],"sec-setvalueinbuffer":["_ref_37","_ref_38"],"sec-getmodifysetvalueinbuffer":["_ref_39","_ref_40","_ref_41"],"sec-get-arraybuffer.prototype.immutable":["_ref_42"],"sec-arraybuffer.prototype.resize":["_ref_43","_ref_44","_ref_45"],"sec-arraybuffer.prototype.slice":["_ref_46","_ref_47"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_48","_ref_49"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_50"],"sec-properties-of-the-arraybuffer-instances":["_ref_51","_ref_52"],"sec-setviewvalue":["_ref_53","_ref_54","_ref_55"],"sec-validateintegertypedarray":["_ref_56"],"sec-validateatomicaccessonintegertypedarray":["_ref_57"],"sec-atomicreadmodifywrite":["_ref_58","_ref_59","_ref_60","_ref_61"],"sec-atomics.compareexchange":["_ref_62"],"sec-atomics.store":["_ref_63","_ref_64"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_23","_ref_24","_ref_25","_ref_27","_ref_28","_ref_32","_ref_33","_ref_36","_ref_41","_ref_44","_ref_45","_ref_58","_ref_59"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_46","_ref_48"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.filter","title":"%TypedArray%.prototype.filter ( callback [ , thisArg ] )","titleHTML":"%TypedArray%.prototype.filter ( callback [ , thisArg ] )","number":"23.2.3.10"},{"type":"clause","id":"sec-%typedarray%.prototype.map","title":"%TypedArray%.prototype.map ( callback [ , thisArg ] )","titleHTML":"%TypedArray%.prototype.map ( callback [ , thisArg ] )","number":"23.2.3.22"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.slice","title":"%TypedArray%.prototype.slice ( start, end )","titleHTML":"%TypedArray%.prototype.slice ( start, end )","number":"23.2.3.27"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"TypedArraySpeciesCreate","refId":"typedarray-species-create"},{"type":"clause","id":"typedarray-species-create","title":"TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )","titleHTML":"TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )","number":"23.2.4.1","referencingIds":["_ref_11","_ref_13","_ref_18"]},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_7","_ref_9","_ref_10","_ref_12","_ref_14","_ref_15","_ref_17","_ref_20","_ref_56"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_37","_ref_39","_ref_53"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_26","_ref_31"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_30","_ref_49"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_50"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_16","_ref_21","_ref_22","_ref_29","_ref_35","_ref_38","_ref_40","_ref_42","_ref_43","_ref_47","_ref_54"]},{"type":"op","aoid":"DetachArrayBuffer","refId":"sec-detacharraybuffer"},{"type":"clause","id":"sec-detacharraybuffer","title":"DetachArrayBuffer ( arrayBuffer [ , key ] )","titleHTML":"DetachArrayBuffer ( arrayBuffer [ , key ] )","number":"25.1.3.5","referencingIds":["_ref_34","_ref_52"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_8","_ref_19","_ref_55","_ref_64"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_61"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_51"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_57"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_60","_ref_62","_ref_63"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); +let biblio = JSON.parse(`{"refsByClause":{"sec-typedarray-getownproperty":["_ref_0"],"sec-typedarray-defineownproperty":["_ref_1","_ref_2"],"sec-typedarray-set":["_ref_3","_ref_4"],"sec-typedarraysetelement":["_ref_5","_ref_6"],"sec-%typedarray%.from":["_ref_7","_ref_8"],"sec-%typedarray%.of":["_ref_9"],"sec-%typedarray%.prototype.copywithin":["_ref_10","_ref_11"],"sec-%typedarray%.prototype.fill":["_ref_12"],"sec-%typedarray%.prototype.filter":["_ref_13","_ref_14"],"sec-%typedarray%.prototype.map":["_ref_15","_ref_16"],"sec-%typedarray%.prototype.reverse":["_ref_17"],"sec-%typedarray%.prototype.set":["_ref_18","_ref_19"],"sec-%typedarray%.prototype.slice":["_ref_20","_ref_21","_ref_22"],"sec-%typedarray%.prototype.sort":["_ref_23"],"typedarray-species-create":["_ref_24"],"sec-typedarraycreatefromconstructor":["_ref_25"],"sec-validatetypedarray":["_ref_26"],"sec-allocatearraybuffer":["_ref_27"],"sec-allocateimmutablearraybuffer":["_ref_28","_ref_29","_ref_30","_ref_31","_ref_32"],"sec-arraybuffercopyanddetach":["_ref_33","_ref_34","_ref_35","_ref_36","_ref_37","_ref_38"],"sec-detacharraybuffer":["_ref_39","_ref_40"],"sec-setvalueinbuffer":["_ref_41","_ref_42"],"sec-getmodifysetvalueinbuffer":["_ref_43","_ref_44","_ref_45"],"sec-get-arraybuffer.prototype.immutable":["_ref_46"],"sec-arraybuffer.prototype.resize":["_ref_47","_ref_48","_ref_49"],"sec-arraybuffer.prototype.slice":["_ref_50","_ref_51"],"sec-arraybuffer.prototype.slicetoimmutable":["_ref_52","_ref_53"],"sec-arraybuffer.prototype.transfertoimmutable":["_ref_54"],"sec-properties-of-the-arraybuffer-instances":["_ref_55","_ref_56"],"sec-setviewvalue":["_ref_57","_ref_58","_ref_59"],"sec-validateintegertypedarray":["_ref_60"],"sec-validateatomicaccessonintegertypedarray":["_ref_61"],"sec-atomicreadmodifywrite":["_ref_62","_ref_63","_ref_64","_ref_65"],"sec-atomics.compareexchange":["_ref_66"],"sec-atomics.store":["_ref_67","_ref_68"]},"entries":[{"type":"term","term":"Shared Data Block","refId":"sec-data-blocks"},{"type":"clause","id":"sec-data-blocks","titleHTML":"Data Blocks","number":"6.2.9","referencingIds":["_ref_27","_ref_28","_ref_29","_ref_31","_ref_32","_ref_36","_ref_37","_ref_40","_ref_45","_ref_48","_ref_49","_ref_62","_ref_63"]},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6"},{"type":"op","aoid":"ResolveBounds","refId":"sec-resolvebounds"},{"type":"clause","id":"sec-resolvebounds","title":"ResolveBounds ( len, start, end )","titleHTML":"ResolveBounds ( len, start, end )","number":"7.1","referencingIds":["_ref_50","_ref_52"]},{"type":"clause","id":"sec-operations-on-objects","titleHTML":"Operations on Objects","number":"7"},{"type":"clause","id":"sec-typedarray-getownproperty","title":"[[GetOwnProperty]] ( P )","titleHTML":"[[GetOwnProperty]] ( P )","number":"10.4.5.1"},{"type":"clause","id":"sec-typedarray-defineownproperty","title":"[[DefineOwnProperty]] ( P, Desc )","titleHTML":"[[DefineOwnProperty]] ( P, Desc )","number":"10.4.5.3"},{"type":"clause","id":"sec-typedarray-set","title":"[[Set]] ( P, V, Receiver )","titleHTML":"[[Set]] ( P, V, Receiver )","number":"10.4.5.5"},{"type":"op","aoid":"TypedArraySetElement","refId":"sec-typedarraysetelement"},{"type":"clause","id":"sec-typedarraysetelement","title":"TypedArraySetElement ( O, index, value )","titleHTML":"TypedArraySetElement ( O, index, value )","number":"10.4.5.16","referencingIds":["_ref_2","_ref_4"]},{"type":"clause","id":"sec-typedarray-exotic-objects","titleHTML":"TypedArray Exotic Objects","number":"10.4.5"},{"type":"clause","id":"sec-built-in-exotic-object-internal-methods-and-slots","titleHTML":"Built-in Exotic Object Internal Methods and Slots","number":"10.4"},{"type":"clause","id":"sec-ordinary-and-exotic-objects-behaviours","titleHTML":"Ordinary and Exotic Objects Behaviours","number":"10"},{"type":"clause","id":"sec-%typedarray%.from","title":"%TypedArray%.from ( source [ , mapper [ , thisArg ] ] )","titleHTML":"%TypedArray%.from ( source [ , mapper [ , thisArg ] ] )","number":"23.2.2.1"},{"type":"clause","id":"sec-%typedarray%.of","title":"%TypedArray%.of ( ...items )","titleHTML":"%TypedArray%.of ( ...items )","number":"23.2.2.2"},{"type":"clause","id":"sec-properties-of-the-%typedarray%-intrinsic-object","titleHTML":"Properties of the %TypedArray% Intrinsic Object","number":"23.2.2"},{"type":"clause","id":"sec-%typedarray%.prototype.copywithin","title":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","titleHTML":"%TypedArray%.prototype.copyWithin ( target, start [ , end ] )","number":"23.2.3.6"},{"type":"clause","id":"sec-%typedarray%.prototype.fill","title":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","titleHTML":"%TypedArray%.prototype.fill ( value [ , start [ , end ] ] )","number":"23.2.3.9"},{"type":"clause","id":"sec-%typedarray%.prototype.filter","title":"%TypedArray%.prototype.filter ( callback [ , thisArg ] )","titleHTML":"%TypedArray%.prototype.filter ( callback [ , thisArg ] )","number":"23.2.3.10"},{"type":"clause","id":"sec-%typedarray%.prototype.map","title":"%TypedArray%.prototype.map ( callback [ , thisArg ] )","titleHTML":"%TypedArray%.prototype.map ( callback [ , thisArg ] )","number":"23.2.3.22"},{"type":"clause","id":"sec-%typedarray%.prototype.reverse","titleHTML":"%TypedArray%.prototype.reverse ( )","number":"23.2.3.25"},{"type":"clause","id":"sec-%typedarray%.prototype.set","title":"%TypedArray%.prototype.set ( source [ , offset ] )","titleHTML":"%TypedArray%.prototype.set ( source [ , offset ] )","number":"23.2.3.26"},{"type":"clause","id":"sec-%typedarray%.prototype.slice","title":"%TypedArray%.prototype.slice ( start, end )","titleHTML":"%TypedArray%.prototype.slice ( start, end )","number":"23.2.3.27"},{"type":"clause","id":"sec-%typedarray%.prototype.sort","title":"%TypedArray%.prototype.sort ( comparator )","titleHTML":"%TypedArray%.prototype.sort ( comparator )","number":"23.2.3.29"},{"type":"clause","id":"sec-properties-of-the-%typedarrayprototype%-object","titleHTML":"Properties of the %TypedArray% Prototype Object","number":"23.2.3"},{"type":"op","aoid":"TypedArraySpeciesCreate","refId":"typedarray-species-create"},{"type":"clause","id":"typedarray-species-create","title":"TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )","titleHTML":"TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )","number":"23.2.4.1","referencingIds":["_ref_14","_ref_16","_ref_21"]},{"type":"op","aoid":"TypedArrayCreateFromConstructor","refId":"sec-typedarraycreatefromconstructor"},{"type":"clause","id":"sec-typedarraycreatefromconstructor","title":"TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] )","titleHTML":"TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] )","number":"23.2.4.2","referencingIds":["_ref_7","_ref_8","_ref_9","_ref_24"]},{"type":"op","aoid":"ValidateTypedArray","refId":"sec-validatetypedarray"},{"type":"clause","id":"sec-validatetypedarray","title":"ValidateTypedArray ( O, order [ , accessMode ] )","titleHTML":"ValidateTypedArray ( O, order [ , accessMode ] )","number":"23.2.4.4","referencingIds":["_ref_10","_ref_12","_ref_13","_ref_15","_ref_17","_ref_18","_ref_20","_ref_23","_ref_25","_ref_60"]},{"type":"clause","id":"sec-abstract-operations-for-typedarray-objects","titleHTML":"Abstract Operations for TypedArray Objects","number":"23.2.4"},{"type":"clause","id":"sec-typedarray-objects","titleHTML":"TypedArray Objects","number":"23.2","referencingIds":["_ref_41","_ref_43","_ref_57"]},{"type":"clause","id":"sec-indexed-collections","titleHTML":"Indexed Collections","number":"23"},{"type":"op","aoid":"AllocateArrayBuffer","refId":"sec-allocatearraybuffer"},{"type":"clause","id":"sec-allocatearraybuffer","title":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","titleHTML":"AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )","number":"25.1.3.1","referencingIds":["_ref_30","_ref_35"]},{"type":"op","aoid":"AllocateImmutableArrayBuffer","refId":"sec-allocateimmutablearraybuffer"},{"type":"clause","id":"sec-allocateimmutablearraybuffer","title":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","titleHTML":"AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )","number":"25.1.3.2","referencingIds":["_ref_34","_ref_53"]},{"type":"op","aoid":"ArrayBufferCopyAndDetach","refId":"sec-arraybuffercopyanddetach"},{"type":"clause","id":"sec-arraybuffercopyanddetach","title":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","titleHTML":"ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )","number":"25.1.3.3","referencingIds":["_ref_54"]},{"type":"op","aoid":"IsImmutableBuffer","refId":"sec-isimmutablebuffer"},{"type":"clause","id":"sec-isimmutablebuffer","title":"IsImmutableBuffer ( arrayBuffer )","titleHTML":"IsImmutableBuffer ( arrayBuffer )","number":"25.1.3.4","referencingIds":["_ref_0","_ref_1","_ref_3","_ref_5","_ref_19","_ref_26","_ref_33","_ref_39","_ref_42","_ref_44","_ref_46","_ref_47","_ref_51","_ref_58"]},{"type":"op","aoid":"DetachArrayBuffer","refId":"sec-detacharraybuffer"},{"type":"clause","id":"sec-detacharraybuffer","title":"DetachArrayBuffer ( arrayBuffer [ , key ] )","titleHTML":"DetachArrayBuffer ( arrayBuffer [ , key ] )","number":"25.1.3.5","referencingIds":["_ref_38","_ref_56"]},{"type":"op","aoid":"SetValueInBuffer","refId":"sec-setvalueinbuffer"},{"type":"clause","id":"sec-setvalueinbuffer","title":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","titleHTML":"SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )","number":"25.1.3.18","referencingIds":["_ref_6","_ref_11","_ref_22","_ref_59","_ref_68"]},{"type":"op","aoid":"GetModifySetValueInBuffer","refId":"sec-getmodifysetvalueinbuffer"},{"type":"clause","id":"sec-getmodifysetvalueinbuffer","title":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","titleHTML":"GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )","number":"25.1.3.19","referencingIds":["_ref_65"]},{"type":"clause","id":"sec-abstract-operations-for-arraybuffer-objects","titleHTML":"Abstract Operations For ArrayBuffer Objects","number":"25.1.3"},{"type":"clause","id":"sec-get-arraybuffer.prototype.immutable","titleHTML":"get ArrayBuffer.prototype.immutable","number":"25.1.6.1"},{"type":"clause","id":"sec-arraybuffer.prototype.resize","title":"ArrayBuffer.prototype.resize ( newLength )","titleHTML":"ArrayBuffer.prototype.resize ( newLength )","number":"25.1.6.6"},{"type":"clause","id":"sec-arraybuffer.prototype.slice","title":"ArrayBuffer.prototype.slice ( start, end )","titleHTML":"ArrayBuffer.prototype.slice ( start, end )","number":"25.1.6.7"},{"type":"clause","id":"sec-arraybuffer.prototype.slicetoimmutable","title":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","titleHTML":"ArrayBuffer.prototype.sliceToImmutable ( start, end )","number":"25.1.6.8"},{"type":"clause","id":"sec-arraybuffer.prototype.transfertoimmutable","title":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","titleHTML":"ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )","number":"25.1.6.9"},{"type":"clause","id":"sec-properties-of-the-arraybuffer-prototype-object","titleHTML":"Properties of the ArrayBuffer Prototype Object","number":"25.1.6","referencingIds":["_ref_55"]},{"type":"clause","id":"sec-properties-of-the-arraybuffer-instances","titleHTML":"Properties of ArrayBuffer Instances","number":"25.1.7"},{"type":"clause","id":"sec-arraybuffer-objects","titleHTML":"ArrayBuffer Objects","number":"25.1"},{"type":"op","aoid":"SetViewValue","refId":"sec-setviewvalue"},{"type":"clause","id":"sec-setviewvalue","title":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","titleHTML":"SetViewValue ( view, requestIndex, isLittleEndian, type, value )","number":"25.3.1.6"},{"type":"clause","id":"sec-abstract-operations-for-dataview-objects","titleHTML":"Abstract Operations For DataView Objects","number":"25.3.1"},{"type":"clause","id":"sec-dataview-objects","titleHTML":"DataView Objects","number":"25.3"},{"type":"op","aoid":"ValidateIntegerTypedArray","refId":"sec-validateintegertypedarray"},{"type":"clause","id":"sec-validateintegertypedarray","title":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","titleHTML":"ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )","number":"25.4.3.1","referencingIds":["_ref_61"]},{"type":"op","aoid":"ValidateAtomicAccessOnIntegerTypedArray","refId":"sec-validateatomicaccessonintegertypedarray"},{"type":"clause","id":"sec-validateatomicaccessonintegertypedarray","title":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","titleHTML":"ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )","number":"25.4.3.3","referencingIds":["_ref_64","_ref_66","_ref_67"]},{"type":"op","aoid":"AtomicReadModifyWrite","refId":"sec-atomicreadmodifywrite"},{"type":"clause","id":"sec-atomicreadmodifywrite","title":"AtomicReadModifyWrite ( typedArray, index, value, op )","titleHTML":"AtomicReadModifyWrite ( typedArray, index, value, op )","number":"25.4.3.17"},{"type":"clause","id":"sec-abstract-operations-for-atomics","titleHTML":"Abstract Operations for Atomics","number":"25.4.3"},{"type":"clause","id":"sec-atomics.compareexchange","title":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","titleHTML":"Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )","number":"25.4.6"},{"type":"clause","id":"sec-atomics.store","title":"Atomics.store ( typedArray, index, value )","titleHTML":"Atomics.store ( typedArray, index, value )","number":"25.4.11"},{"type":"clause","id":"sec-atomics-object","titleHTML":"The Atomics Object","number":"25.4"},{"type":"clause","id":"sec-structured-data","titleHTML":"Structured Data","number":"25"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright & Software License","number":"A"}]}`); ;let usesMultipage = false
  • Toggle shortcuts help?
  • @@ -3291,7 +3945,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / March 6, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / March 30, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

@@ -3645,14 +4299,14 @@

25.4.11 Atomics.store ( typedArray, <
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
- -

A Copyright & Software License

- -

Copyright Notice

-

© 2025 Mark S. Miller, Richard Gibson

- -

Software License

-

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Copyright & Software License

+ + +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

@@ -3664,5 +4318,5 @@

Software License

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
+

\ No newline at end of file From 668f90eca5d09280b9f354a6c98366e7356c652a Mon Sep 17 00:00:00 2001 From: erights Date: Mon, 31 Mar 2025 00:53:05 +0000 Subject: [PATCH 80/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@8a48be1e33aae33b8d4f5720e7d27?= =?UTF-8?q?87a00f91194=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 1f9cffb..6ac7c32 100644 --- a/index.html +++ b/index.html @@ -3945,7 +3945,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / March 30, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / March 31, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

From 0114c1ebf0a0a4514f48b3b6588a51bebdcb2fe9 Mon Sep 17 00:00:00 2001 From: erights Date: Fri, 4 Apr 2025 01:17:48 +0000 Subject: [PATCH 81/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@f922ef76aefb3e72893d7a03c5b9c?= =?UTF-8?q?9a50ef9cf5d=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 6ac7c32..0632ceb 100644 --- a/index.html +++ b/index.html @@ -3945,7 +3945,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / March 31, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / April 4, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

From df95724d906a94d3abc3fb4bae929a4a516a8f32 Mon Sep 17 00:00:00 2001 From: erights Date: Mon, 14 Apr 2025 02:44:01 +0000 Subject: [PATCH 82/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@177fb8f1d446315f6d6d9daf2028a?= =?UTF-8?q?e99bc78fa3a=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 0632ceb..037beb8 100644 --- a/index.html +++ b/index.html @@ -3945,7 +3945,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / April 4, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / April 14, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

From d31e3ecd4206b3aaba9edf0e115f0ab0408a305e Mon Sep 17 00:00:00 2001 From: erights Date: Thu, 17 Apr 2025 21:28:38 +0000 Subject: [PATCH 83/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@df112bab948a1ef5f435a64816f39?= =?UTF-8?q?08dab93960b=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 037beb8..d85c071 100644 --- a/index.html +++ b/index.html @@ -3945,7 +3945,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / April 14, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / April 17, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

From 2bce77de05415050edb88109699c2b6774ba1249 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 2 May 2025 16:29:07 +0000 Subject: [PATCH 84/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@df112bab948a1ef5f435a64816f39?= =?UTF-8?q?08dab93960b=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/50/index.html | 4393 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 4393 insertions(+) create mode 100644 pr/50/index.html diff --git a/pr/50/index.html b/pr/50/index.html new file mode 100644 index 0000000..f5c0971 --- /dev/null +++ b/pr/50/index.html @@ -0,0 +1,4393 @@ + + + + + +Immutable ArrayBuffers + +
+ PR #50 +

+ This document is a preview of merging PR #50, resulting in commit 62fad7c4c4f1924429bdc3e72be33d17fb98a3e3. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / May 2, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
        1. Let current be ! O.[[GetOwnProperty]](P).
        2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
        3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
      3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
      4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      5. If IsAccessorDescriptor(Desc) is true, return false.
      6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
      7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      8. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.2 Properties of the %TypedArray% Intrinsic Object

+

The %TypedArray% intrinsic object:

+
    +
  • has a [[Prototype]] internal slot whose value is %Function.prototype%.
  • +
  • has a "name" property whose value is "TypedArray".
  • +
  • has the following properties:
  • +
+ + +

23.2.2.1 %TypedArray%.from ( source [ , mapper [ , thisArg ] ] )

+

This method performs the following steps when called:

+
  1. Let C be the this value.
  2. If IsConstructor(C) is false, throw a TypeError exception.
  3. If mapper is undefined, then
    1. Let mapping be false.
  4. Else,
    1. If IsCallable(mapper) is false, throw a TypeError exception.
    2. Let mapping be true.
  5. Let usingIterator be ? GetMethod(source, %Symbol.iterator%).
  6. If usingIterator is not undefined, then
    1. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)).
    2. Let len be the number of elements in values.
    3. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    4. Let k be 0.
    5. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be the first element of values.
      3. Remove the first element from values.
      4. If mapping is true, then
        1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
      5. Else,
        1. Let mappedValue be kValue.
      6. Perform ? Set(targetObj, Pk, mappedValue, true).
      7. Set k to k + 1.
    6. Assert: values is now an empty List.
    7. Return targetObj.
  7. NOTE: source is not an iterable object, so assume it is already an array-like object.
  8. Let arrayLike be ! ToObject(source).
  9. Let len be ? LengthOfArrayLike(arrayLike).
  10. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
  11. Let k be 0.
  12. Repeat, while k < len,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let kValue be ? Get(arrayLike, Pk).
    3. If mapping is true, then
      1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
    4. Else,
      1. Let mappedValue be kValue.
    5. Perform ? Set(targetObj, Pk, mappedValue, true).
    6. Set k to k + 1.
  13. Return targetObj.
+
+ + +

23.2.2.2 %TypedArray%.of ( ...items )

+

This method performs the following steps when called:

+
  1. Let len be the number of elements in items.
  2. Let C be the this value.
  3. If IsConstructor(C) is false, throw a TypeError exception.
  4. Let newObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
  5. Let k be 0.
  6. Repeat, while k < len,
    1. Let kValue be items[k].
    2. Let Pk be ! ToString(𝔽(k)).
    3. Perform ? Set(newObj, Pk, kValue, true).
    4. Set k to k + 1.
  7. Return newObj.
+
+
+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.10 %TypedArray%.prototype.filter ( callback [ , thisArg ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.filter as defined in 23.1.3.8.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
  3. Let len be TypedArrayLength(taRecord).
  4. If IsCallable(callback) is false, throw a TypeError exception.
  5. Let kept be a new empty List.
  6. Let captured be 0.
  7. Let k be 0.
  8. Repeat, while k < len,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let kValue be ! Get(O, Pk).
    3. Let selected be ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), O »)).
    4. If selected is true, then
      1. Append kValue to kept.
      2. Set captured to captured + 1.
    5. Set k to k + 1.
  9. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) », write).
  10. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
  11. Let n be 0.
  12. For each element e of kept, do
    1. Perform ! Set(A, ! ToString(𝔽(n)), e, true).
    2. Set n to n + 1.
  13. Return A.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.22 %TypedArray%.prototype.map ( callback [ , thisArg ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.map as defined in 23.1.3.21.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
  3. Let len be TypedArrayLength(taRecord).
  4. If IsCallable(callback) is false, throw a TypeError exception.
  5. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(len) », write).
  6. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
  7. Let k be 0.
  8. Repeat, while k < len,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let kValue be ! Get(O, Pk).
    3. Let mappedValue be ? Call(callback, thisArg, « kValue, 𝔽(k), O »).
    4. Perform ? Set(A, Pk, mappedValue, true).
    5. Set k to k + 1.
  9. Return A.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.27 %TypedArray%.prototype.slice ( start, end )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.slice as defined in 23.1.3.28.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
  3. Let srcArrayLength be TypedArrayLength(taRecord).
  4. Let relativeStart be ? ToIntegerOrInfinity(start).
  5. If relativeStart = -∞, let startIndex be 0.
  6. Else if relativeStart < 0, let startIndex be max(srcArrayLength + relativeStart, 0).
  7. Else, let startIndex be min(relativeStart, srcArrayLength).
  8. If end is undefined, let relativeEnd be srcArrayLength; else let relativeEnd be ? ToIntegerOrInfinity(end).
  9. If relativeEnd = -∞, let endIndex be 0.
  10. Else if relativeEnd < 0, let endIndex be max(srcArrayLength + relativeEnd, 0).
  11. Else, let endIndex be min(relativeEnd, srcArrayLength).
  12. Let countBytes be max(endIndex - startIndex, 0).
  13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(countBytes) », write).
  14. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
  15. If countBytes > 0, then
    1. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    2. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    3. Set endIndex to min(endIndex, TypedArrayLength(taRecord)).
    4. Set countBytes to max(endIndex - startIndex, 0).
    5. Let srcType be TypedArrayElementType(O).
    6. Let targetType be TypedArrayElementType(A).
    7. If srcType is targetType, then
      1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
      2. Let srcBuffer be O.[[ViewedArrayBuffer]].
      3. Let targetBuffer be A.[[ViewedArrayBuffer]].
      4. Let elementSize be TypedArrayElementSize(O).
      5. Let srcByteOffset be O.[[ByteOffset]].
      6. Let srcByteIndex be (startIndex × elementSize) + srcByteOffset.
      7. Let targetByteIndex be A.[[ByteOffset]].
      8. Let endByteIndex be targetByteIndex + (countBytes × elementSize).
      9. Repeat, while targetByteIndex < endByteIndex,
        1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
        3. Set srcByteIndex to srcByteIndex + 1.
        4. Set targetByteIndex to targetByteIndex + 1.
    8. Else,
      1. Let n be 0.
      2. Let k be startIndex.
      3. Repeat, while k < endIndex,
        1. Let Pk be ! ToString(𝔽(k)).
        2. Let kValue be ! Get(O, Pk).
        3. Perform ! Set(A, ! ToString(𝔽(n)), kValue, true).
        4. Set k to k + 1.
        5. Set n to n + 1.
  16. Return A.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.1 TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )

+

The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a TypedArray) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function that is derived from exemplar. Unlike ArraySpeciesCreate, which can create non-Array objects through the use of %Symbol.species%, this operation enforces that the constructor function creates an actual TypedArray. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73.
  3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
  4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode).
  5. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots.
  6. Assert: result has all of the internal slots of a TypedArray instance (23.2.8).
  7. If result.[[ContentType]] is not exemplar.[[ContentType]], throw a TypeError exception.
  8. Return result.
+
+ + +

23.2.4.2 TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] )

+

The abstract operation TypedArrayCreateFromConstructor takes arguments constructor (a constructor) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let newTypedArray be ? Construct(constructor, argumentList).
  3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode).
  4. If the number of elements in argumentList is 1 and argumentList[0] is a Number, then
    1. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    2. Let length be TypedArrayLength(taRecord).
    3. If length < (argumentList[0]), throw a TypeError exception.
  5. Return newTypedArray.
+
+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities inside an implementation or observable by it. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

+

The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
  2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If key is not present, set key to undefined.
  4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
  5. Set arrayBuffer.[[ArrayBufferData]] to null.
  6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
  7. Return unused.
+ Note
+

Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. Assert: IsImmutableBuffer(O) is false.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be max(final - first, 0).
  10. NOTE: Side-effects of the above steps may have detached or resized O.
  11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  12. Let fromBuf be O.[[ArrayBufferData]].
  13. Let currentLen be O.[[ArrayBufferByteLength]].
  14. If currentLen < final, throw a RangeError exception.
  15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  16. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

Copyright & Software License

+ + +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From adad9f55cb8fbea006dfdd2c543a118e291548dd Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 2 May 2025 16:35:15 +0000 Subject: [PATCH 85/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@df112bab948a1ef5f435a64816f39?= =?UTF-8?q?08dab93960b=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/51/index.html | 4393 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 4393 insertions(+) create mode 100644 pr/51/index.html diff --git a/pr/51/index.html b/pr/51/index.html new file mode 100644 index 0000000..a132969 --- /dev/null +++ b/pr/51/index.html @@ -0,0 +1,4393 @@ + + + + + +Immutable ArrayBuffers + +
+ PR #51 +

+ This document is a preview of merging PR #51, resulting in commit 1fbd0c6875f78e69e8fb1641ae189017ed2924f8. +

+

+ Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

+
+ +
+
    +
  • Toggle shortcuts help?
  • +
  • Toggle "can call user code" annotationsu
  • + +
  • Jump to search box/
  • +
  • Toggle pinning of the current clausep
  • +
  • Jump to nth pin1-9
  • +

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / May 2, 2025

Immutable ArrayBuffers

+ + +

6 ECMAScript Data Types and Values

+ + +

6.2.9 Data Blocks

+

A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

+
+
+ + +

7 Operations on Objects

+ + + + +

7.1 ResolveBounds ( len, start, end )

+

The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

+
  1. Let relativeStart be ? ToIntegerOrInfinity(start).
  2. If relativeStart = -∞, let from be 0.
  3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
  4. Else, let from be min(relativeStart, len).
  5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  6. If relativeEnd = -∞, let to be 0.
  7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
  8. Else, let to be min(relativeEnd, len).
  9. Return the Record { [[From]]: from, [[To]]: to }.
+
+
+
+ + +

10 Ordinary and Exotic Objects Behaviours

+ + +

10.4 Built-in Exotic Object Internal Methods and Slots

+ + +

10.4.5 TypedArray Exotic Objects

+ + +

10.4.5.1 [[GetOwnProperty]] ( P )

+

The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. Let value be TypedArrayGetElement(O, numericIndex).
      2. If value is undefined, return undefined.
      3. Let mutable be true.
      4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
      5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
  2. Return OrdinaryGetOwnProperty(O, P).
+
+ + +

10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

+

The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
        1. Let current be ! O.[[GetOwnProperty]](P).
        2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
        3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
        4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
      3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
      4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
      5. If IsAccessorDescriptor(Desc) is true, return false.
      6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
      7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
      8. Return true.
  2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
+
+ + +

10.4.5.5 [[Set]] ( P, V, Receiver )

+

The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

+
  1. If P is a String, then
    1. Let numericIndex be CanonicalNumericIndexString(P).
    2. If numericIndex is not undefined, then
      1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
      2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
      3. If SameValue(O, Receiver) is true, then
        1. Perform ? TypedArraySetElement(O, numericIndex, V).
        2. Return true.
      4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
  2. Return ? OrdinarySet(O, P, V, Receiver).
+
+ + +

10.4.5.16 TypedArraySetElement ( O, index, value )

+

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
  2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
  3. Otherwise, let numValue be ? ToNumber(value).
  4. If IsValidIntegerIndex(O, index) is true, then
    1. Let offset be O.[[ByteOffset]].
    2. Let elementSize be TypedArrayElementSize(O).
    3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
    4. Let elementType be TypedArrayElementType(O).
    5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
  5. Return unused.
+ Note
+

This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

+
+
+
+
+
+ + +

23 Indexed Collections

+ + +

23.2 TypedArray Objects

+ + +

23.2.2 Properties of the %TypedArray% Intrinsic Object

+

The %TypedArray% intrinsic object:

+
    +
  • has a [[Prototype]] internal slot whose value is %Function.prototype%.
  • +
  • has a "name" property whose value is "TypedArray".
  • +
  • has the following properties:
  • +
+ + +

23.2.2.1 %TypedArray%.from ( source [ , mapper [ , thisArg ] ] )

+

This method performs the following steps when called:

+
  1. Let C be the this value.
  2. If IsConstructor(C) is false, throw a TypeError exception.
  3. If mapper is undefined, then
    1. Let mapping be false.
  4. Else,
    1. If IsCallable(mapper) is false, throw a TypeError exception.
    2. Let mapping be true.
  5. Let usingIterator be ? GetMethod(source, %Symbol.iterator%).
  6. If usingIterator is not undefined, then
    1. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)).
    2. Let len be the number of elements in values.
    3. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    4. Let k be 0.
    5. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be the first element of values.
      3. Remove the first element from values.
      4. If mapping is true, then
        1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
      5. Else,
        1. Let mappedValue be kValue.
      6. Perform ? Set(targetObj, Pk, mappedValue, true).
      7. Set k to k + 1.
    6. Assert: values is now an empty List.
    7. Return targetObj.
  7. NOTE: source is not an iterable object, so assume it is already an array-like object.
  8. Let arrayLike be ! ToObject(source).
  9. Let len be ? LengthOfArrayLike(arrayLike).
  10. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
  11. Let k be 0.
  12. Repeat, while k < len,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let kValue be ? Get(arrayLike, Pk).
    3. If mapping is true, then
      1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
    4. Else,
      1. Let mappedValue be kValue.
    5. Perform ? Set(targetObj, Pk, mappedValue, true).
    6. Set k to k + 1.
  13. Return targetObj.
+
+ + +

23.2.2.2 %TypedArray%.of ( ...items )

+

This method performs the following steps when called:

+
  1. Let len be the number of elements in items.
  2. Let C be the this value.
  3. If IsConstructor(C) is false, throw a TypeError exception.
  4. Let newObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
  5. Let k be 0.
  6. Repeat, while k < len,
    1. Let kValue be items[k].
    2. Let Pk be ! ToString(𝔽(k)).
    3. Perform ? Set(newObj, Pk, kValue, true).
    4. Set k to k + 1.
  7. Return newObj.
+
+
+ + +

23.2.3 Properties of the %TypedArray% Prototype Object

+ + +

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let relativeTarget be ? ToIntegerOrInfinity(target).
  5. If relativeTarget = -∞, let targetIndex be 0.
  6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
  7. Else, let targetIndex be min(relativeTarget, len).
  8. Let relativeStart be ? ToIntegerOrInfinity(start).
  9. If relativeStart = -∞, let startIndex be 0.
  10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  11. Else, let startIndex be min(relativeStart, len).
  12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  13. If relativeEnd = -∞, let endIndex be 0.
  14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  15. Else, let endIndex be min(relativeEnd, len).
  16. Let count be min(endIndex - startIndex, len - targetIndex).
  17. If count > 0, then
    1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
    2. Let buffer be O.[[ViewedArrayBuffer]].
    3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    5. Set len to TypedArrayLength(taRecord).
    6. Let elementSize be TypedArrayElementSize(O).
    7. Let byteOffset be O.[[ByteOffset]].
    8. Let bufferByteLimit be (len × elementSize) + byteOffset.
    9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
    10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
    11. Let countBytes be count × elementSize.
    12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
      1. Let direction be -1.
      2. Set fromByteIndex to fromByteIndex + countBytes - 1.
      3. Set toByteIndex to toByteIndex + countBytes - 1.
    13. Else,
      1. Let direction be 1.
    14. Repeat, while countBytes > 0,
      1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
        1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
        3. Set fromByteIndex to fromByteIndex + direction.
        4. Set toByteIndex to toByteIndex + direction.
        5. Set countBytes to countBytes - 1.
      2. Else,
        1. Set countBytes to 0.
  18. Return O.
+
+ + +

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let startIndex be 0.
  8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
  9. Else, let startIndex be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let endIndex be 0.
  12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
  13. Else, let endIndex be min(relativeEnd, len).
  14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
  15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  16. Set len to TypedArrayLength(taRecord).
  17. Set endIndex to min(endIndex, len).
  18. Let k be startIndex.
  19. Repeat, while k < endIndex,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Perform ! Set(O, Pk, value, true).
    3. Set k to k + 1.
  20. Return O.
+
+ + +

23.2.3.10 %TypedArray%.prototype.filter ( callback [ , thisArg ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.filter as defined in 23.1.3.8.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
  3. Let len be TypedArrayLength(taRecord).
  4. If IsCallable(callback) is false, throw a TypeError exception.
  5. Let kept be a new empty List.
  6. Let captured be 0.
  7. Let k be 0.
  8. Repeat, while k < len,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let kValue be ! Get(O, Pk).
    3. Let selected be ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), O »)).
    4. If selected is true, then
      1. Append kValue to kept.
      2. Set captured to captured + 1.
    5. Set k to k + 1.
  9. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) », write).
  10. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
  11. Let n be 0.
  12. For each element e of kept, do
    1. Perform ! Set(A, ! ToString(𝔽(n)), e, true).
    2. Set n to n + 1.
  13. Return A.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.22 %TypedArray%.prototype.map ( callback [ , thisArg ] )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.map as defined in 23.1.3.21.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
  3. Let len be TypedArrayLength(taRecord).
  4. If IsCallable(callback) is false, throw a TypeError exception.
  5. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(len) », write).
  6. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
  7. Let k be 0.
  8. Repeat, while k < len,
    1. Let Pk be ! ToString(𝔽(k)).
    2. Let kValue be ! Get(O, Pk).
    3. Let mappedValue be ? Call(callback, thisArg, « kValue, 𝔽(k), O »).
    4. Perform ? Set(A, Pk, mappedValue, true).
    5. Set k to k + 1.
  9. Return A.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.25 %TypedArray%.prototype.reverse ( )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
  3. Let len be TypedArrayLength(taRecord).
  4. Let middle be floor(len / 2).
  5. Let lower be 0.
  6. Repeat, while lowermiddle,
    1. Let upper be len - lower - 1.
    2. Let upperP be ! ToString(𝔽(upper)).
    3. Let lowerP be ! ToString(𝔽(lower)).
    4. Let lowerValue be ! Get(O, lowerP).
    5. Let upperValue be ! Get(O, upperP).
    6. Perform ! Set(O, lowerP, upperValue, true).
    7. Perform ! Set(O, upperP, lowerValue, true).
    8. Set lower to lower + 1.
  7. Return O.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

+

This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

+

It performs the following steps when called:

+
  1. Let target be the this value.
  2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
  3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
  4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
  5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  6. Let targetOffset be ? ToIntegerOrInfinity(offset).
  7. If targetOffset < 0, throw a RangeError exception.
  8. If source is an Object that has a [[TypedArrayName]] internal slot, then
    1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
  9. Else,
    1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
  10. Return undefined.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.27 %TypedArray%.prototype.slice ( start, end )

+

The interpretation and use of the arguments of this method are the same as for Array.prototype.slice as defined in 23.1.3.28.

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
  3. Let srcArrayLength be TypedArrayLength(taRecord).
  4. Let relativeStart be ? ToIntegerOrInfinity(start).
  5. If relativeStart = -∞, let startIndex be 0.
  6. Else if relativeStart < 0, let startIndex be max(srcArrayLength + relativeStart, 0).
  7. Else, let startIndex be min(relativeStart, srcArrayLength).
  8. If end is undefined, let relativeEnd be srcArrayLength; else let relativeEnd be ? ToIntegerOrInfinity(end).
  9. If relativeEnd = -∞, let endIndex be 0.
  10. Else if relativeEnd < 0, let endIndex be max(srcArrayLength + relativeEnd, 0).
  11. Else, let endIndex be min(relativeEnd, srcArrayLength).
  12. Let countBytes be max(endIndex - startIndex, 0).
  13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(countBytes) », write).
  14. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
  15. If countBytes > 0, then
    1. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    2. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    3. Set endIndex to min(endIndex, TypedArrayLength(taRecord)).
    4. Set countBytes to max(endIndex - startIndex, 0).
    5. Let srcType be TypedArrayElementType(O).
    6. Let targetType be TypedArrayElementType(A).
    7. If srcType is targetType, then
      1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
      2. Let srcBuffer be O.[[ViewedArrayBuffer]].
      3. Let targetBuffer be A.[[ViewedArrayBuffer]].
      4. Let elementSize be TypedArrayElementSize(O).
      5. Let srcByteOffset be O.[[ByteOffset]].
      6. Let srcByteIndex be (startIndex × elementSize) + srcByteOffset.
      7. Let targetByteIndex be A.[[ByteOffset]].
      8. Let endByteIndex be targetByteIndex + (countBytes × elementSize).
      9. Repeat, while targetByteIndex < endByteIndex,
        1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
        2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
        3. Set srcByteIndex to srcByteIndex + 1.
        4. Set targetByteIndex to targetByteIndex + 1.
    8. Else,
      1. Let n be 0.
      2. Let k be startIndex.
      3. Repeat, while k < endIndex,
        1. Let Pk be ! ToString(𝔽(k)).
        2. Let kValue be ! Get(O, Pk).
        3. Perform ! Set(A, ! ToString(𝔽(n)), kValue, true).
        4. Set k to k + 1.
        5. Set n to n + 1.
  16. Return A.
+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+
+ + +

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

+

This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

+

This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

+

It performs the following steps when called:

+
  1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
  2. Let obj be the this value.
  3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
  4. Let len be TypedArrayLength(taRecord).
  5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
  6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
    1. Return ? CompareTypedArrayElements(x, y, comparator).
  7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
  8. Let j be 0.
  9. Repeat, while j < len,
    1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
    2. Set j to j + 1.
  10. Return obj.
+ Note
+

Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

+
+
+
+ + +

23.2.4 Abstract Operations for TypedArray Objects

+ + +

23.2.4.1 TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )

+

The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a TypedArray) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function that is derived from exemplar. Unlike ArraySpeciesCreate, which can create non-Array objects through the use of %Symbol.species%, this operation enforces that the constructor function creates an actual TypedArray. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73.
  3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
  4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode).
  5. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots.
  6. Assert: result has all of the internal slots of a TypedArray instance (23.2.8).
  7. If result.[[ContentType]] is not exemplar.[[ContentType]], throw a TypeError exception.
  8. Return result.
+
+ + +

23.2.4.2 TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] )

+

The abstract operation TypedArrayCreateFromConstructor takes arguments constructor (a constructor) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let newTypedArray be ? Construct(constructor, argumentList).
  3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode).
  4. If the number of elements in argumentList is 1 and argumentList[0] is a Number, then
    1. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    2. Let length be TypedArrayLength(taRecord).
    3. If length < (argumentList[0]), throw a TypeError exception.
  5. Return newTypedArray.
+
+ + +

23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

+

The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
  3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
  4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
  6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
  7. Return taRecord.
+
+
+
+
+ + +

25 Structured Data

+ + +

25.1 ArrayBuffer Objects

+ + +

25.1.3 Abstract Operations For ArrayBuffer Objects

+ + +

25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

+

The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

+ Editor's Note
The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
  2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
  3. If allocatingResizableBuffer is true, then
    1. If byteLength > maxByteLength, throw a RangeError exception.
    2. Append [[ArrayBufferMaxByteLength]] to slots.
  4. Else if maxByteLength is immutable, then
    1. Append [[ArrayBufferIsImmutable]] to slots.
  5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
  6. Let block be ? CreateByteDataBlock(byteLength).
  7. Set obj.[[ArrayBufferData]] to block.
  8. Set obj.[[ArrayBufferByteLength]] to byteLength.
  9. If allocatingResizableBuffer is true, then
    1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
    2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
    3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
  10. Return obj.
+
+ + + + +

25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

+

The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities inside an implementation or observable by it. It performs the following steps when called:

+
  1. Assert: constructor is %ArrayBuffer%.
  2. Assert: countbyteLength.
  3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
  4. Let toBlock be newBuffer.[[ArrayBufferData]].
  5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
  6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
  7. Return newBuffer.
+ Note
+

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.

+
+
+
+ + +

25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

+

The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

+ Editor's Note
The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
+

It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
  2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If newLength is undefined, then
    1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
  4. Else,
    1. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
  8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
  9. If preserveResizability is immutable, then
    1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
  10. Else,
    1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
      1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
    2. Else,
      1. Let newMaxByteLength be empty.
    3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
    5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
    7. Let toBlock be newBuffer.[[ArrayBufferData]].
    8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
    9. 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.
  11. Perform ! DetachArrayBuffer(arrayBuffer).
  12. Return newBuffer.
+
+ + + + +

25.1.3.4 IsImmutableBuffer ( arrayBuffer )

+

The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

+
  1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
  2. Return false.
+
+
+ + +

25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

+

The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

+
  1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
  2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
  3. If key is not present, set key to undefined.
  4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
  5. Set arrayBuffer.[[ArrayBufferData]] to null.
  6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
  7. Return unused.
+ Note
+

Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

+
+
+ + +

25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

+

The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
    4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
  10. Else,
    1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
  11. Return unused.
+
+ + +

25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

+

The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

+
  1. Assert: IsDetachedBuffer(arrayBuffer) is false.
  2. Assert: IsImmutableBuffer(arrayBuffer) is false.
  3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
  4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
  5. Let block be arrayBuffer.[[ArrayBufferData]].
  6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
  9. If IsSharedArrayBuffer(arrayBuffer) is true, then
    1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
    2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
    3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
    4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
    5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
    6. Append rmwEvent to eventsRecord.[[EventList]].
    7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
  10. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
    2. Let rawBytesModified be op(rawBytesRead, rawBytes).
    3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
  11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
+
+
+ + +

25.1.6 Properties of the ArrayBuffer Prototype Object

+ + + + +

25.1.6.1 get ArrayBuffer.prototype.immutable

+

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Return IsImmutableBuffer(O).
+
+
+ + +

25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Let newByteLength be ? ToIndex(newLength).
  5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
  7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
  8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
  9. If hostHandled is handled, return undefined.
  10. Let oldBlock be O.[[ArrayBufferData]].
  11. Let newBlock be ? CreateByteDataBlock(newByteLength).
  12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
  13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
  14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
  15. Set O.[[ArrayBufferData]] to newBlock.
  16. Set O.[[ArrayBufferByteLength]] to newByteLength.
  17. Return undefined.
+
+ + +

25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let relativeStart be ? ToIntegerOrInfinity(start).
  7. If relativeStart = -∞, let first be 0.
  8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
  9. Else, let first be min(relativeStart, len).
  10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
  11. If relativeEnd = -∞, let final be 0.
  12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
  13. Else, let final be min(relativeEnd, len).
  14. Let bounds be ? ResolveBounds(len, start, end).
  15. Let first be bounds.[[From]].
  16. Let final be bounds.[[To]].
  17. Let newLen be max(final - first, 0).
  18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
  19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
  20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
  21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
  22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
  23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
  24. If SameValue(new, O) is true, throw a TypeError exception.
  25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
  26. NOTE: Side-effects of the above steps may have detached or resized O.
  27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  28. Let fromBuf be O.[[ArrayBufferData]].
  29. Let toBuf be new.[[ArrayBufferData]].
  30. Let currentLen be O.[[ArrayBufferByteLength]].
  31. If first < currentLen, then
    1. Let count be min(newLen, currentLen - first).
    2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
  32. Return new.
+
+ + + + +

25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  5. Let len be O.[[ArrayBufferByteLength]].
  6. Let bounds be ? ResolveBounds(len, start, end).
  7. Let first be bounds.[[From]].
  8. Let final be bounds.[[To]].
  9. Let newLen be max(final - first, 0).
  10. NOTE: Side-effects of the above steps may have detached or resized O.
  11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
  12. Let fromBuf be O.[[ArrayBufferData]].
  13. Let currentLen be O.[[ArrayBufferByteLength]].
  14. If currentLen < final, throw a RangeError exception.
  15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
  16. Return newBuffer.
+
+
+ + + + +

25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

+

This method performs the following steps when called:

+
  1. Let O be the this value.
  2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
+
+
+
+ + +

25.1.7 Properties of ArrayBuffer Instances

+

ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

+

ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

+

ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

+
+
+ + +

25.3 DataView Objects

+ + +

25.3.1 Abstract Operations For DataView Objects

+ + +

25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

+

The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

+
  1. Perform ? RequireInternalSlot(view, [[DataView]]).
  2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
  3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
  4. Let getIndex be ? ToIndex(requestIndex).
  5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
  6. Otherwise, let numberValue be ? ToNumber(value).
  7. Set isLittleEndian to ToBoolean(isLittleEndian).
  8. Let viewOffset be view.[[ByteOffset]].
  9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
  10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
  11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
  12. Let viewSize be GetViewByteLength(viewRecord).
  13. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
  14. If getIndex + elementSize > viewSize, throw a RangeError exception.
  15. Let bufferIndex be getIndex + viewOffset.
  16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
  17. Return undefined.
+
+
+
+ + +

25.4 The Atomics Object

+ + +

25.4.3 Abstract Operations for Atomics

+ + +

25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

+

The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

+
  1. If accessMode is not present, set accessMode to read.
  2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
  3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
  4. If waitable is true, then
    1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
  5. Else,
    1. Let type be TypedArrayElementType(typedArray).
    2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
  6. Return taRecord.
+
+ + +

25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

+

The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

+
  1. If waitable is not present, set waitable to false.
  2. If accessMode is not present, set accessMode to read.
  3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
  4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
+
+ + +

25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

+

The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
+
+
+ + +

25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. Let buffer be typedArray.[[ViewedArrayBuffer]].
  3. Let block be buffer.[[ArrayBufferData]].
  4. If typedArray.[[ContentType]] is bigint, then
    1. Let expected be ? ToBigInt(expectedValue).
    2. Let replacement be ? ToBigInt(replacementValue).
  5. Else,
    1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
    2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
  6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  7. Let elementType be TypedArrayElementType(typedArray).
  8. Let elementSize be TypedArrayElementSize(typedArray).
  9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
  10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
  11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
  12. If IsSharedArrayBuffer(buffer) is true, then
    1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
  13. Else,
    1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
    2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
      1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
  14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
+
+ + +

25.4.11 Atomics.store ( typedArray, index, value )

+

This function performs the following steps when called:

+
  1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
  2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
  3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
  4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
  5. Let buffer be typedArray.[[ViewedArrayBuffer]].
  6. Let elementType be TypedArrayElementType(typedArray).
  7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
  8. Return v.
+
+
+
+

Copyright & Software License

+ + +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file From 3e476f95797576356047f6826a873bbc78761495 Mon Sep 17 00:00:00 2001 From: erights Date: Tue, 6 May 2025 03:45:12 +0000 Subject: [PATCH 86/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@d44119415940d20adea5e43be9349?= =?UTF-8?q?94faf48117d=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index d85c071..68e3f45 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ - Menu -

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / April 17, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / May 6, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

From 1ac34118976439dd47700d9287c20b890d63d693 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Thu, 8 May 2025 12:11:52 +0000 Subject: [PATCH 87/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@d3b1cdf7e482652768da7e9bf3113?= =?UTF-8?q?e04cd0acd26=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 68e3f45..da68613 100644 --- a/index.html +++ b/index.html @@ -3948,7 +3948,7 @@

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / May 6, 2025

Immutable ArrayBuffers

+

Proposal proposal-immutable-arraybuffer

Stage 2 Draft / May 8, 2025

Immutable ArrayBuffers

6 ECMAScript Data Types and Values

@@ -4208,7 +4208,7 @@

25.1.6 Properties of the ArrayBuffer Prototype O

25.1.6.1 get ArrayBuffer.prototype.immutable

ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

-
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. Return IsImmutableBuffer(O).
+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
  3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
  4. Return IsImmutableBuffer(O).
From 2bfb9d763a013780ad02694d5b92b57c96bfb0f6 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Wed, 28 May 2025 04:34:24 +0000 Subject: [PATCH 88/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@b862bc6aabac978513523428822cf?= =?UTF-8?q?a59e4e4cc9d=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index da68613..4085c4a 100644 --- a/index.html +++ b/index.html @@ -413,10 +413,15 @@ Menu.prototype.documentKeydown = function (e) { e.stopPropagation(); - if (e.keyCode === 80) { + if (e.key === 'p') { this.togglePinEntry(); - } else if (e.keyCode >= 48 && e.keyCode < 58) { + } else if ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9].includes(parseInt(e.key))) { this.selectPin((e.keyCode - 9) % 10); + } else if (e.key === '`') { + const hash = document.location.hash; + const id = decodeURIComponent(hash.slice(1)); + const target = document.getElementById(id); + target?.scrollIntoView(true); } }; @@ -2192,12 +2197,7 @@ emu-production.inline, emu-grammar.inline emu-production emu-rhs, emu-production.inline emu-rhs, -emu-grammar[collapsed] emu-production emu-rhs { - display: inline; - padding-left: 1ex; - margin-left: 0; -} - +emu-grammar[collapsed] emu-production emu-rhs, emu-production[collapsed] emu-rhs { display: inline; padding-left: 0.5ex; @@ -3944,11 +3944,13 @@
  • Jump to search box/
  • Toggle pinning of the current clausep
  • -
  • Jump to nth pin1-9
  • +
  • Jump to the nth pin1-9
  • +
  • Jump to the 10th pin0
  • +
  • Jump to the most recent link target`
  • Proposal proposal-immutable-arraybuffer

    Stage 2 Draft / May 8, 2025

    Immutable ArrayBuffers

    +

    Proposal proposal-immutable-arraybuffer

    Stage 2 Draft / May 28, 2025

    Immutable ArrayBuffers

    6 ECMAScript Data Types and Values

    @@ -4215,7 +4217,7 @@

    25.1.6.1 get ArrayBuffer.prototype.immutable

    25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    6. If IsImmutableBuffer(O) is true, throw a TypeError exception.
    7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
    8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
    9. If hostHandled is handled, return undefined.
    10. Let oldBlock be O.[[ArrayBufferData]].
    11. Let newBlock be ? CreateByteDataBlock(newByteLength).
    12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
    13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
    14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
    15. Set O.[[ArrayBufferData]] to newBlock.
    16. Set O.[[ArrayBufferByteLength]] to newByteLength.
    17. Return undefined.
    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    6. Assert: IsImmutableBuffer(O) is false.
    7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
    8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
    9. If hostHandled is handled, return undefined.
    10. Let oldBlock be O.[[ArrayBufferData]].
    11. Let newBlock be ? CreateByteDataBlock(newByteLength).
    12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
    13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
    14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
    15. Set O.[[ArrayBufferData]] to newBlock.
    16. Set O.[[ArrayBufferByteLength]] to newByteLength.
    17. Return undefined.
    From c457fce646de92bcf418266af4ad43b9025350d3 Mon Sep 17 00:00:00 2001 From: bakkot Date: Thu, 29 May 2025 14:25:54 +0000 Subject: [PATCH 89/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@b862bc6aabac978513523428822cf?= =?UTF-8?q?a59e4e4cc9d=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/53/index.html | 4395 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 4395 insertions(+) create mode 100644 pr/53/index.html diff --git a/pr/53/index.html b/pr/53/index.html new file mode 100644 index 0000000..d40dc5c --- /dev/null +++ b/pr/53/index.html @@ -0,0 +1,4395 @@ + + + + + +Immutable ArrayBuffers + +
    + PR #53 +

    + This document is a preview of merging PR #53, resulting in commit 4214691fa39172d14f8bf24b2668032736411412. +

    +

    + Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

    +
    + +
    +
      +
    • Toggle shortcuts help?
    • +
    • Toggle "can call user code" annotationsu
    • + +
    • Jump to search box/
    • +
    • Toggle pinning of the current clausep
    • +
    • Jump to the nth pin1-9
    • +
    • Jump to the 10th pin0
    • +
    • Jump to the most recent link target`
    • +

    Proposal proposal-immutable-arraybuffer

    Stage 2 Draft / May 29, 2025

    Immutable ArrayBuffers

    + + +

    6 ECMAScript Data Types and Values

    + + +

    6.2.9 Data Blocks

    +

    A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

    +
    +
    + + +

    7 Operations on Objects

    + + + + +

    7.1 ResolveBounds ( len, start, end )

    +

    The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

    +
    1. Let relativeStart be ? ToIntegerOrInfinity(start).
    2. If relativeStart = -∞, let from be 0.
    3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
    4. Else, let from be min(relativeStart, len).
    5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    6. If relativeEnd = -∞, let to be 0.
    7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
    8. Else, let to be min(relativeEnd, len).
    9. Return the Record { [[From]]: from, [[To]]: to }.
    +
    +
    +
    + + +

    10 Ordinary and Exotic Objects Behaviours

    + + +

    10.4 Built-in Exotic Object Internal Methods and Slots

    + + +

    10.4.5 TypedArray Exotic Objects

    + + +

    10.4.5.1 [[GetOwnProperty]] ( P )

    +

    The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. Let value be TypedArrayGetElement(O, numericIndex).
        2. If value is undefined, return undefined.
        3. Let mutable be true.
        4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
        5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
    2. Return OrdinaryGetOwnProperty(O, P).
    +
    + + +

    10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

    +

    The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
          1. Let current be ! O.[[GetOwnProperty]](P).
          2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
          3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
          4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
        3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
        4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
        5. If IsAccessorDescriptor(Desc) is true, return false.
        6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
        7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
        8. Return true.
    2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
    +
    + + +

    10.4.5.5 [[Set]] ( P, V, Receiver )

    +

    The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
        3. If SameValue(O, Receiver) is true, then
          1. Perform ? TypedArraySetElement(O, numericIndex, V).
          2. Return true.
        4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
    2. Return ? OrdinarySet(O, P, V, Receiver).
    +
    + + +

    10.4.5.16 TypedArraySetElement ( O, index, value )

    +

    The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

    +
    1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
    2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
    3. Otherwise, let numValue be ? ToNumber(value).
    4. If IsValidIntegerIndex(O, index) is true, then
      1. Let offset be O.[[ByteOffset]].
      2. Let elementSize be TypedArrayElementSize(O).
      3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
      4. Let elementType be TypedArrayElementType(O).
      5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
    5. Return unused.
    + Note
    +

    This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

    +
    +
    +
    +
    +
    + + +

    23 Indexed Collections

    + + +

    23.2 TypedArray Objects

    + + +

    23.2.2 Properties of the %TypedArray% Intrinsic Object

    +

    The %TypedArray% intrinsic object:

    +
      +
    • has a [[Prototype]] internal slot whose value is %Function.prototype%.
    • +
    • has a "name" property whose value is "TypedArray".
    • +
    • has the following properties:
    • +
    + + +

    23.2.2.1 %TypedArray%.from ( source [ , mapper [ , thisArg ] ] )

    +

    This method performs the following steps when called:

    +
    1. Let C be the this value.
    2. If IsConstructor(C) is false, throw a TypeError exception.
    3. If mapper is undefined, then
      1. Let mapping be false.
    4. Else,
      1. If IsCallable(mapper) is false, throw a TypeError exception.
      2. Let mapping be true.
    5. Let usingIterator be ? GetMethod(source, %Symbol.iterator%).
    6. If usingIterator is not undefined, then
      1. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)).
      2. Let len be the number of elements in values.
      3. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
      4. Let k be 0.
      5. Repeat, while k < len,
        1. Let Pk be ! ToString(𝔽(k)).
        2. Let kValue be the first element of values.
        3. Remove the first element from values.
        4. If mapping is true, then
          1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
        5. Else,
          1. Let mappedValue be kValue.
        6. Perform ? Set(targetObj, Pk, mappedValue, true).
        7. Set k to k + 1.
      6. Assert: values is now an empty List.
      7. Return targetObj.
    7. NOTE: source is not an iterable object, so assume it is already an array-like object.
    8. Let arrayLike be ! ToObject(source).
    9. Let len be ? LengthOfArrayLike(arrayLike).
    10. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    11. Let k be 0.
    12. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ? Get(arrayLike, Pk).
      3. If mapping is true, then
        1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
      4. Else,
        1. Let mappedValue be kValue.
      5. Perform ? Set(targetObj, Pk, mappedValue, true).
      6. Set k to k + 1.
    13. Return targetObj.
    +
    + + +

    23.2.2.2 %TypedArray%.of ( ...items )

    +

    This method performs the following steps when called:

    +
    1. Let len be the number of elements in items.
    2. Let C be the this value.
    3. If IsConstructor(C) is false, throw a TypeError exception.
    4. Let newObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    5. Let k be 0.
    6. Repeat, while k < len,
      1. Let kValue be items[k].
      2. Let Pk be ! ToString(𝔽(k)).
      3. Perform ? Set(newObj, Pk, kValue, true).
      4. Set k to k + 1.
    7. Return newObj.
    +
    +
    + + +

    23.2.3 Properties of the %TypedArray% Prototype Object

    + + +

    23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. Let relativeTarget be ? ToIntegerOrInfinity(target).
    5. If relativeTarget = -∞, let targetIndex be 0.
    6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
    7. Else, let targetIndex be min(relativeTarget, len).
    8. Let relativeStart be ? ToIntegerOrInfinity(start).
    9. If relativeStart = -∞, let startIndex be 0.
    10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    11. Else, let startIndex be min(relativeStart, len).
    12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    13. If relativeEnd = -∞, let endIndex be 0.
    14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    15. Else, let endIndex be min(relativeEnd, len).
    16. Let count be min(endIndex - startIndex, len - targetIndex).
    17. If count > 0, then
      1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
      2. Let buffer be O.[[ViewedArrayBuffer]].
      3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      5. Set len to TypedArrayLength(taRecord).
      6. Let elementSize be TypedArrayElementSize(O).
      7. Let byteOffset be O.[[ByteOffset]].
      8. Let bufferByteLimit be (len × elementSize) + byteOffset.
      9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
      10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
      11. Let countBytes be count × elementSize.
      12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
        1. Let direction be -1.
        2. Set fromByteIndex to fromByteIndex + countBytes - 1.
        3. Set toByteIndex to toByteIndex + countBytes - 1.
      13. Else,
        1. Let direction be 1.
      14. Repeat, while countBytes > 0,
        1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
          1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
          3. Set fromByteIndex to fromByteIndex + direction.
          4. Set toByteIndex to toByteIndex + direction.
          5. Set countBytes to countBytes - 1.
        2. Else,
          1. Set countBytes to 0.
    18. Return O.
    +
    + + +

    23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
    5. Otherwise, set value to ? ToNumber(value).
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let startIndex be 0.
    8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    9. Else, let startIndex be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let endIndex be 0.
    12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    13. Else, let endIndex be min(relativeEnd, len).
    14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    16. Set len to TypedArrayLength(taRecord).
    17. Set endIndex to min(endIndex, len).
    18. Let k be startIndex.
    19. Repeat, while k < endIndex,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Perform ! Set(O, Pk, value, true).
      3. Set k to k + 1.
    20. Return O.
    +
    + + +

    23.2.3.10 %TypedArray%.prototype.filter ( callback [ , thisArg ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.filter as defined in 23.1.3.8.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let kept be a new empty List.
    6. Let captured be 0.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let selected be ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), O »)).
      4. If selected is true, then
        1. Append kValue to kept.
        2. Set captured to captured + 1.
      5. Set k to k + 1.
    9. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) », write).
    10. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    11. Let n be 0.
    12. For each element e of kept, do
      1. Perform ! Set(A, ! ToString(𝔽(n)), e, true).
      2. Set n to n + 1.
    13. Return A.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.22 %TypedArray%.prototype.map ( callback [ , thisArg ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.map as defined in 23.1.3.21.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(len) », write).
    6. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let mappedValue be ? Call(callback, thisArg, « kValue, 𝔽(k), O »).
      4. Perform ? Set(A, Pk, mappedValue, true).
      5. Set k to k + 1.
    9. Return A.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.25 %TypedArray%.prototype.reverse ( )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. Let middle be floor(len / 2).
    5. Let lower be 0.
    6. Repeat, while lowermiddle,
      1. Let upper be len - lower - 1.
      2. Let upperP be ! ToString(𝔽(upper)).
      3. Let lowerP be ! ToString(𝔽(lower)).
      4. Let lowerValue be ! Get(O, lowerP).
      5. Let upperValue be ! Get(O, upperP).
      6. Perform ! Set(O, lowerP, upperValue, true).
      7. Perform ! Set(O, upperP, lowerValue, true).
      8. Set lower to lower + 1.
    7. Return O.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

    +

    This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

    +

    It performs the following steps when called:

    +
    1. Let target be the this value.
    2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
    3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
    4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
    5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    6. Let targetOffset be ? ToIntegerOrInfinity(offset).
    7. If targetOffset < 0, throw a RangeError exception.
    8. If source is an Object that has a [[TypedArrayName]] internal slot, then
      1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
    9. Else,
      1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
    10. Return undefined.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.27 %TypedArray%.prototype.slice ( start, end )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.slice as defined in 23.1.3.28.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let srcArrayLength be TypedArrayLength(taRecord).
    4. Let relativeStart be ? ToIntegerOrInfinity(start).
    5. If relativeStart = -∞, let startIndex be 0.
    6. Else if relativeStart < 0, let startIndex be max(srcArrayLength + relativeStart, 0).
    7. Else, let startIndex be min(relativeStart, srcArrayLength).
    8. If end is undefined, let relativeEnd be srcArrayLength; else let relativeEnd be ? ToIntegerOrInfinity(end).
    9. If relativeEnd = -∞, let endIndex be 0.
    10. Else if relativeEnd < 0, let endIndex be max(srcArrayLength + relativeEnd, 0).
    11. Else, let endIndex be min(relativeEnd, srcArrayLength).
    12. Let countBytes be max(endIndex - startIndex, 0).
    13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(countBytes) », write).
    14. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    15. If countBytes > 0, then
      1. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      2. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      3. Set endIndex to min(endIndex, TypedArrayLength(taRecord)).
      4. Set countBytes to max(endIndex - startIndex, 0).
      5. Let srcType be TypedArrayElementType(O).
      6. Let targetType be TypedArrayElementType(A).
      7. If srcType is targetType, then
        1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
        2. Let srcBuffer be O.[[ViewedArrayBuffer]].
        3. Let targetBuffer be A.[[ViewedArrayBuffer]].
        4. Let elementSize be TypedArrayElementSize(O).
        5. Let srcByteOffset be O.[[ByteOffset]].
        6. Let srcByteIndex be (startIndex × elementSize) + srcByteOffset.
        7. Let targetByteIndex be A.[[ByteOffset]].
        8. Let endByteIndex be targetByteIndex + (countBytes × elementSize).
        9. Repeat, while targetByteIndex < endByteIndex,
          1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
          3. Set srcByteIndex to srcByteIndex + 1.
          4. Set targetByteIndex to targetByteIndex + 1.
      8. Else,
        1. Let n be 0.
        2. Let k be startIndex.
        3. Repeat, while k < endIndex,
          1. Let Pk be ! ToString(𝔽(k)).
          2. Let kValue be ! Get(O, Pk).
          3. Perform ! Set(A, ! ToString(𝔽(n)), kValue, true).
          4. Set k to k + 1.
          5. Set n to n + 1.
    16. Return A.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.29 %TypedArray%.prototype.sort ( comparator )

    +

    This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +

    It performs the following steps when called:

    +
    1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
    2. Let obj be the this value.
    3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
    4. Let len be TypedArrayLength(taRecord).
    5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
    6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
      1. Return ? CompareTypedArrayElements(x, y, comparator).
    7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
    8. Let j be 0.
    9. Repeat, while j < len,
      1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
      2. Set j to j + 1.
    10. Return obj.
    + Note
    +

    Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

    +
    +
    +
    + + +

    23.2.4 Abstract Operations for TypedArray Objects

    + + +

    23.2.4.1 TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )

    +

    The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a TypedArray) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function that is derived from exemplar. Unlike ArraySpeciesCreate, which can create non-Array objects through the use of %Symbol.species%, this operation enforces that the constructor function creates an actual TypedArray. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73.
    3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
    4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode).
    5. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots.
    6. Assert: result has all of the internal slots of a TypedArray instance (23.2.8).
    7. If result.[[ContentType]] is not exemplar.[[ContentType]], throw a TypeError exception.
    8. Return result.
    +
    + + +

    23.2.4.2 TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] )

    +

    The abstract operation TypedArrayCreateFromConstructor takes arguments constructor (a constructor) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Let newTypedArray be ? Construct(constructor, argumentList).
    3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode).
    4. If the number of elements in argumentList is 1 and argumentList[0] is a Number, then
      1. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      2. Let length be TypedArrayLength(taRecord).
      3. If length < (argumentList[0]), throw a TypeError exception.
    5. Return newTypedArray.
    +
    + + +

    23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

    +

    The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
    3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
    4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
    6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    7. Return taRecord.
    +
    +
    +
    +
    + + +

    25 Structured Data

    + + +

    25.1 ArrayBuffer Objects

    + + +

    25.1.3 Abstract Operations For ArrayBuffer Objects

    + + +

    25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

    +

    The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

    + Editor's Note
    The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
    +

    It performs the following steps when called:

    +
    1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
    2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
    3. If allocatingResizableBuffer is true, then
      1. If byteLength > maxByteLength, throw a RangeError exception.
      2. Append [[ArrayBufferMaxByteLength]] to slots.
    4. Else if maxByteLength is immutable, then
      1. Append [[ArrayBufferIsImmutable]] to slots.
    5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
    6. Let block be ? CreateByteDataBlock(byteLength).
    7. Set obj.[[ArrayBufferData]] to block.
    8. Set obj.[[ArrayBufferByteLength]] to byteLength.
    9. If allocatingResizableBuffer is true, then
      1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
      2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
      3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
    10. Return obj.
    +
    + + + + +

    25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

    +

    The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities inside an implementation or observable by it. It performs the following steps when called:

    +
    1. Assert: constructor is %ArrayBuffer%.
    2. Assert: countbyteLength.
    3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
    4. Let toBlock be newBuffer.[[ArrayBufferData]].
    5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
    6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
    7. Return newBuffer.
    + Note
    +

    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.

    +
    +
    +
    + + +

    25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

    +

    The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

    + Editor's Note
    The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
    +

    It performs the following steps when called:

    +
    1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
    2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
    3. If newLength is undefined, then
      1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
    4. Else,
      1. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
    6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
    7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    9. If preserveResizability is immutable, then
      1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
    10. Else,
      1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
        1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
      2. Else,
        1. Let newMaxByteLength be empty.
      3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
      4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
      5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
      6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
      7. Let toBlock be newBuffer.[[ArrayBufferData]].
      8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
      9. 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.
    11. Perform ! DetachArrayBuffer(arrayBuffer).
    12. Return newBuffer.
    +
    + + + + +

    25.1.3.4 IsImmutableBuffer ( arrayBuffer )

    +

    The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

    +
    1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
    2. Return false.
    +
    +
    + + +

    25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

    +

    The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

    +
    1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
    2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
    3. If key is not present, set key to undefined.
    4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
    5. Set arrayBuffer.[[ArrayBufferData]] to null.
    6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
    7. Return unused.
    + Note
    +

    Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

    +
    +
    + + +

    25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

    +

    The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

    +
    1. Assert: IsDetachedBuffer(arrayBuffer) is false.
    2. Assert: IsImmutableBuffer(arrayBuffer) is false.
    3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
    4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
    5. Let block be arrayBuffer.[[ArrayBufferData]].
    6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
    9. If IsSharedArrayBuffer(arrayBuffer) is true, then
      1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
      2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
      3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
      4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
    10. Else,
      1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
    11. Return unused.
    +
    + + +

    25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

    +

    The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

    +
    1. Assert: IsDetachedBuffer(arrayBuffer) is false.
    2. Assert: IsImmutableBuffer(arrayBuffer) is false.
    3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
    4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
    5. Let block be arrayBuffer.[[ArrayBufferData]].
    6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
    9. If IsSharedArrayBuffer(arrayBuffer) is true, then
      1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
      2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
      3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
      4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
      5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
      6. Append rmwEvent to eventsRecord.[[EventList]].
      7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
    10. Else,
      1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
      2. Let rawBytesModified be op(rawBytesRead, rawBytes).
      3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
    11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
    +
    +
    + + +

    25.1.6 Properties of the ArrayBuffer Prototype Object

    + + + + +

    25.1.6.1 get ArrayBuffer.prototype.immutable

    +

    ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Return IsImmutableBuffer(O).
    +
    +
    + + +

    25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    6. Assert: IsImmutableBuffer(O) is false.
    7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
    8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
    9. If hostHandled is handled, return undefined.
    10. Let oldBlock be O.[[ArrayBufferData]].
    11. Let newBlock be ? CreateByteDataBlock(newByteLength).
    12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
    13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
    14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
    15. Set O.[[ArrayBufferData]] to newBlock.
    16. Set O.[[ArrayBufferByteLength]] to newByteLength.
    17. Return undefined.
    +
    + + +

    25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let first be 0.
    8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
    9. Else, let first be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let final be 0.
    12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
    13. Else, let final be min(relativeEnd, len).
    14. Let bounds be ? ResolveBounds(len, start, end).
    15. Let first be bounds.[[From]].
    16. Let final be bounds.[[To]].
    17. Let newLen be max(final - first, 0).
    18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
    19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
    20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
    21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
    22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
    23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
    24. If SameValue(new, O) is true, throw a TypeError exception.
    25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
    26. NOTE: Side-effects of the above steps may have detached or resized O.
    27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    28. Let fromBuf be O.[[ArrayBufferData]].
    29. Let toBuf be new.[[ArrayBufferData]].
    30. Let currentLen be O.[[ArrayBufferByteLength]].
    31. If first < currentLen, then
      1. Let count be min(newLen, currentLen - first).
      2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
    32. Return new.
    +
    + + + + +

    25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let bounds be ? ResolveBounds(len, start, end).
    7. Let first be bounds.[[From]].
    8. Let final be bounds.[[To]].
    9. Let newLen be max(final - first, 0).
    10. NOTE: Side-effects of the above steps may have detached or resized O.
    11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    12. Let fromBuf be O.[[ArrayBufferData]].
    13. Let currentLen be O.[[ArrayBufferByteLength]].
    14. If currentLen < final, throw a RangeError exception.
    15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
    16. Return newBuffer.
    +
    +
    + + + + +

    25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
    +
    +
    +
    + + +

    25.1.7 Properties of ArrayBuffer Instances

    +

    ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

    +

    ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

    +

    ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

    +
    +
    + + +

    25.3 DataView Objects

    + + +

    25.3.1 Abstract Operations For DataView Objects

    + + +

    25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

    +

    The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

    +
    1. Perform ? RequireInternalSlot(view, [[DataView]]).
    2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
    3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    4. Let getIndex be ? ToIndex(requestIndex).
    5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
    6. Otherwise, let numberValue be ? ToNumber(value).
    7. Set isLittleEndian to ToBoolean(isLittleEndian).
    8. Let viewOffset be view.[[ByteOffset]].
    9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
    10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
    11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
    12. Let viewSize be GetViewByteLength(viewRecord).
    13. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    14. If getIndex + elementSize > viewSize, throw a RangeError exception.
    15. Let bufferIndex be getIndex + viewOffset.
    16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
    17. Return undefined.
    +
    +
    +
    + + +

    25.4 The Atomics Object

    + + +

    25.4.3 Abstract Operations for Atomics

    + + +

    25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

    +

    The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
    3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
    4. If waitable is true, then
      1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
    5. Else,
      1. Let type be TypedArrayElementType(typedArray).
      2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
    6. Return taRecord.
    +
    + + +

    25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

    +

    The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

    +
    1. If waitable is not present, set waitable to false.
    2. If accessMode is not present, set accessMode to read.
    3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
    4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
    +
    + + +

    25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

    +

    The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
    +
    +
    + + +

    25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

    +

    This function performs the following steps when called:

    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. Let buffer be typedArray.[[ViewedArrayBuffer]].
    3. Let block be buffer.[[ArrayBufferData]].
    4. If typedArray.[[ContentType]] is bigint, then
      1. Let expected be ? ToBigInt(expectedValue).
      2. Let replacement be ? ToBigInt(replacementValue).
    5. Else,
      1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
      2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
    6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    7. Let elementType be TypedArrayElementType(typedArray).
    8. Let elementSize be TypedArrayElementSize(typedArray).
    9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
    11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
    12. If IsSharedArrayBuffer(buffer) is true, then
      1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
    13. Else,
      1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
      2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
        1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
    14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
    +
    + + +

    25.4.11 Atomics.store ( typedArray, index, value )

    +

    This function performs the following steps when called:

    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
    8. Return v.
    +
    +
    +
    +

    Copyright & Software License

    + + +

    Software License

    +

    All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

    + +

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    + +
      +
    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    2. +
    3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    4. +
    5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
    6. +
    + +

    THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    + +
    +
    \ No newline at end of file From 709a7139c80bdca8e64ab7e5287ee47bbf7b094a Mon Sep 17 00:00:00 2001 From: gibson042 Date: Fri, 30 May 2025 18:31:32 +0000 Subject: [PATCH 90/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@cdaf20af1f1ae17fbe0cde7f0e6cc?= =?UTF-8?q?05631650e37=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/index.html b/index.html index 4085c4a..17dc212 100644 --- a/index.html +++ b/index.html @@ -3950,7 +3950,7 @@

    Proposal proposal-immutable-arraybuffer

    Stage 2 Draft / May 28, 2025

    Immutable ArrayBuffers

    +

    Proposal proposal-immutable-arraybuffer

    Stage 2 Draft / May 30, 2025

    Immutable ArrayBuffers

    6 ECMAScript Data Types and Values

    @@ -3969,7 +3969,7 @@

    7 Operations on Objects

    7.1 ResolveBounds ( len, start, end )

    The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

    -
    1. Let relativeStart be ? ToIntegerOrInfinity(start).
    2. If relativeStart = -∞, let from be 0.
    3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
    4. Else, let from be min(relativeStart, len).
    5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    6. If relativeEnd = -∞, let to be 0.
    7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
    8. Else, let to be min(relativeEnd, len).
    9. Return the Record { [[From]]: from, [[To]]: to }.
    +
    1. Let relativeStart be ? ToIntegerOrInfinity(start).
    2. If relativeStart = -∞, let from be 0.
    3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
    4. Else, let from be min(relativeStart, len).
    5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    6. If relativeEnd = -∞, let to be 0.
    7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
    8. Else, let to be min(relativeEnd, len).
    9. Return the Record { [[From]]: from, [[To]]: to }.
    @@ -3992,19 +3992,19 @@

    10.4.5.1 [[GetOwnProperty]]

    10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

    The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

    -
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
          1. Let current be ! O.[[GetOwnProperty]](P).
          2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
          3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
          4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
        3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
        4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
        5. If IsAccessorDescriptor(Desc) is true, return false.
        6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
        7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
        8. Return true.
    2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
          1. Let current be ! O.[[GetOwnProperty]](P).
          2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
          3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
          4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
        3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
        4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
        5. If IsAccessorDescriptor(Desc) is true, return false.
        6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
        7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
        8. Return true.
    2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).

    10.4.5.5 [[Set]] ( P, V, Receiver )

    The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

    -
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
        3. If SameValue(O, Receiver) is true, then
          1. Perform ? TypedArraySetElement(O, numericIndex, V).
          2. Return true.
        4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
    2. Return ? OrdinarySet(O, P, V, Receiver).
    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
        3. If SameValue(O, Receiver) is true, then
          1. Perform ? TypedArraySetElement(O, numericIndex, V).
          2. Return true.
        4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
    2. Return ? OrdinarySet(O, P, V, Receiver).

    10.4.5.16 TypedArraySetElement ( O, index, value )

    The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

    -
    1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
    2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
    3. Otherwise, let numValue be ? ToNumber(value).
    4. If IsValidIntegerIndex(O, index) is true, then
      1. Let offset be O.[[ByteOffset]].
      2. Let elementSize be TypedArrayElementSize(O).
      3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
      4. Let elementType be TypedArrayElementType(O).
      5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
    5. Return unused.
    +
    1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
    2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
    3. Otherwise, let numValue be ? ToNumber(value).
    4. If IsValidIntegerIndex(O, index) is true, then
      1. Let offset be O.[[ByteOffset]].
      2. Let elementSize be TypedArrayElementSize(O).
      3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
      4. Let elementType be TypedArrayElementType(O).
      5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
    5. Return unused.
    Note

    This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

    @@ -4031,13 +4031,13 @@

    23.2.2 Properties of the %TypedArray% Intrinsic

    23.2.2.1 %TypedArray%.from ( source [ , mapper [ , thisArg ] ] )

    This method performs the following steps when called:

    -
    1. Let C be the this value.
    2. If IsConstructor(C) is false, throw a TypeError exception.
    3. If mapper is undefined, then
      1. Let mapping be false.
    4. Else,
      1. If IsCallable(mapper) is false, throw a TypeError exception.
      2. Let mapping be true.
    5. Let usingIterator be ? GetMethod(source, %Symbol.iterator%).
    6. If usingIterator is not undefined, then
      1. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)).
      2. Let len be the number of elements in values.
      3. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
      4. Let k be 0.
      5. Repeat, while k < len,
        1. Let Pk be ! ToString(𝔽(k)).
        2. Let kValue be the first element of values.
        3. Remove the first element from values.
        4. If mapping is true, then
          1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
        5. Else,
          1. Let mappedValue be kValue.
        6. Perform ? Set(targetObj, Pk, mappedValue, true).
        7. Set k to k + 1.
      6. Assert: values is now an empty List.
      7. Return targetObj.
    7. NOTE: source is not an iterable object, so assume it is already an array-like object.
    8. Let arrayLike be ! ToObject(source).
    9. Let len be ? LengthOfArrayLike(arrayLike).
    10. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    11. Let k be 0.
    12. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ? Get(arrayLike, Pk).
      3. If mapping is true, then
        1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
      4. Else,
        1. Let mappedValue be kValue.
      5. Perform ? Set(targetObj, Pk, mappedValue, true).
      6. Set k to k + 1.
    13. Return targetObj.
    +
    1. Let C be the this value.
    2. If IsConstructor(C) is false, throw a TypeError exception.
    3. If mapper is undefined, then
      1. Let mapping be false.
    4. Else,
      1. If IsCallable(mapper) is false, throw a TypeError exception.
      2. Let mapping be true.
    5. Let usingIterator be ? GetMethod(source, %Symbol.iterator%).
    6. If usingIterator is not undefined, then
      1. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)).
      2. Let len be the number of elements in values.
      3. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
      4. Let k be 0.
      5. Repeat, while k < len,
        1. Let Pk be ! ToString(𝔽(k)).
        2. Let kValue be the first element of values.
        3. Remove the first element from values.
        4. If mapping is true, then
          1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
        5. Else,
          1. Let mappedValue be kValue.
        6. Perform ? Set(targetObj, Pk, mappedValue, true).
        7. Set k to k + 1.
      6. Assert: values is now an empty List.
      7. Return targetObj.
    7. NOTE: source is not an iterable object, so assume it is already an array-like object.
    8. Let arrayLike be ! ToObject(source).
    9. Let len be ? LengthOfArrayLike(arrayLike).
    10. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    11. Let k be 0.
    12. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ? Get(arrayLike, Pk).
      3. If mapping is true, then
        1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
      4. Else,
        1. Let mappedValue be kValue.
      5. Perform ? Set(targetObj, Pk, mappedValue, true).
      6. Set k to k + 1.
    13. Return targetObj.

    23.2.2.2 %TypedArray%.of ( ...items )

    This method performs the following steps when called:

    -
    1. Let len be the number of elements in items.
    2. Let C be the this value.
    3. If IsConstructor(C) is false, throw a TypeError exception.
    4. Let newObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    5. Let k be 0.
    6. Repeat, while k < len,
      1. Let kValue be items[k].
      2. Let Pk be ! ToString(𝔽(k)).
      3. Perform ? Set(newObj, Pk, kValue, true).
      4. Set k to k + 1.
    7. Return newObj.
    +
    1. Let len be the number of elements in items.
    2. Let C be the this value.
    3. If IsConstructor(C) is false, throw a TypeError exception.
    4. Let newObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    5. Let k be 0.
    6. Repeat, while k < len,
      1. Let kValue be items[k].
      2. Let Pk be ! ToString(𝔽(k)).
      3. Perform ? Set(newObj, Pk, kValue, true).
      4. Set k to k + 1.
    7. Return newObj.
    @@ -4048,21 +4048,21 @@

    23.2.3 Properties of the %TypedArray% Prototype

    23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

    The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. Let relativeTarget be ? ToIntegerOrInfinity(target).
    5. If relativeTarget = -∞, let targetIndex be 0.
    6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
    7. Else, let targetIndex be min(relativeTarget, len).
    8. Let relativeStart be ? ToIntegerOrInfinity(start).
    9. If relativeStart = -∞, let startIndex be 0.
    10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    11. Else, let startIndex be min(relativeStart, len).
    12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    13. If relativeEnd = -∞, let endIndex be 0.
    14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    15. Else, let endIndex be min(relativeEnd, len).
    16. Let count be min(endIndex - startIndex, len - targetIndex).
    17. If count > 0, then
      1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
      2. Let buffer be O.[[ViewedArrayBuffer]].
      3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      5. Set len to TypedArrayLength(taRecord).
      6. Let elementSize be TypedArrayElementSize(O).
      7. Let byteOffset be O.[[ByteOffset]].
      8. Let bufferByteLimit be (len × elementSize) + byteOffset.
      9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
      10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
      11. Let countBytes be count × elementSize.
      12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
        1. Let direction be -1.
        2. Set fromByteIndex to fromByteIndex + countBytes - 1.
        3. Set toByteIndex to toByteIndex + countBytes - 1.
      13. Else,
        1. Let direction be 1.
      14. Repeat, while countBytes > 0,
        1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
          1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
          3. Set fromByteIndex to fromByteIndex + direction.
          4. Set toByteIndex to toByteIndex + direction.
          5. Set countBytes to countBytes - 1.
        2. Else,
          1. Set countBytes to 0.
    18. Return O.
    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. Let relativeTarget be ? ToIntegerOrInfinity(target).
    5. If relativeTarget = -∞, let targetIndex be 0.
    6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
    7. Else, let targetIndex be min(relativeTarget, len).
    8. Let relativeStart be ? ToIntegerOrInfinity(start).
    9. If relativeStart = -∞, let startIndex be 0.
    10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    11. Else, let startIndex be min(relativeStart, len).
    12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    13. If relativeEnd = -∞, let endIndex be 0.
    14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    15. Else, let endIndex be min(relativeEnd, len).
    16. Let count be min(endIndex - startIndex, len - targetIndex).
    17. If count > 0, then
      1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
      2. Let buffer be O.[[ViewedArrayBuffer]].
      3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      5. Set len to TypedArrayLength(taRecord).
      6. Let elementSize be TypedArrayElementSize(O).
      7. Let byteOffset be O.[[ByteOffset]].
      8. Let bufferByteLimit be (len × elementSize) + byteOffset.
      9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
      10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
      11. Let countBytes be count × elementSize.
      12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
        1. Let direction be -1.
        2. Set fromByteIndex to fromByteIndex + countBytes - 1.
        3. Set toByteIndex to toByteIndex + countBytes - 1.
      13. Else,
        1. Let direction be 1.
      14. Repeat, while countBytes > 0,
        1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
          1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
          3. Set fromByteIndex to fromByteIndex + direction.
          4. Set toByteIndex to toByteIndex + direction.
          5. Set countBytes to countBytes - 1.
        2. Else,
          1. Set countBytes to 0.
    18. Return O.

    23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

    The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
    5. Otherwise, set value to ? ToNumber(value).
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let startIndex be 0.
    8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    9. Else, let startIndex be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let endIndex be 0.
    12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    13. Else, let endIndex be min(relativeEnd, len).
    14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    16. Set len to TypedArrayLength(taRecord).
    17. Set endIndex to min(endIndex, len).
    18. Let k be startIndex.
    19. Repeat, while k < endIndex,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Perform ! Set(O, Pk, value, true).
      3. Set k to k + 1.
    20. Return O.
    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
    5. Otherwise, set value to ? ToNumber(value).
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let startIndex be 0.
    8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    9. Else, let startIndex be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let endIndex be 0.
    12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    13. Else, let endIndex be min(relativeEnd, len).
    14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    16. Set len to TypedArrayLength(taRecord).
    17. Set endIndex to min(endIndex, len).
    18. Let k be startIndex.
    19. Repeat, while k < endIndex,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Perform ! Set(O, Pk, value, true).
      3. Set k to k + 1.
    20. Return O.

    23.2.3.10 %TypedArray%.prototype.filter ( callback [ , thisArg ] )

    The interpretation and use of the arguments of this method are the same as for Array.prototype.filter as defined in 23.1.3.8.

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let kept be a new empty List.
    6. Let captured be 0.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let selected be ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), O »)).
      4. If selected is true, then
        1. Append kValue to kept.
        2. Set captured to captured + 1.
      5. Set k to k + 1.
    9. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) », write).
    10. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    11. Let n be 0.
    12. For each element e of kept, do
      1. Perform ! Set(A, ! ToString(𝔽(n)), e, true).
      2. Set n to n + 1.
    13. Return A.
    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let kept be a new empty List.
    6. Let captured be 0.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let selected be ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), O »)).
      4. If selected is true, then
        1. Append kValue to kept.
        2. Set captured to captured + 1.
      5. Set k to k + 1.
    9. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) », write).
    10. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    11. Let n be 0.
    12. For each element e of kept, do
      1. Perform ! Set(A, ! ToString(𝔽(n)), e, true).
      2. Set n to n + 1.
    13. Return A.

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    @@ -4070,7 +4070,7 @@

    23.2.3.10 %TypedArray%.prototype.filter ( c

    23.2.3.22 %TypedArray%.prototype.map ( callback [ , thisArg ] )

    The interpretation and use of the arguments of this method are the same as for Array.prototype.map as defined in 23.1.3.21.

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(len) », write).
    6. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let mappedValue be ? Call(callback, thisArg, « kValue, 𝔽(k), O »).
      4. Perform ? Set(A, Pk, mappedValue, true).
      5. Set k to k + 1.
    9. Return A.
    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(len) », write).
    6. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let mappedValue be ? Call(callback, thisArg, « kValue, 𝔽(k), O »).
      4. Perform ? Set(A, Pk, mappedValue, true).
      5. Set k to k + 1.
    9. Return A.

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    @@ -4086,7 +4086,7 @@

    23.2.3.25 %TypedArray%.prototype.reverse ( )

    23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

    This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

    It performs the following steps when called:

    -
    1. Let target be the this value.
    2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
    3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
    4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
    5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    6. Let targetOffset be ? ToIntegerOrInfinity(offset).
    7. If targetOffset < 0, throw a RangeError exception.
    8. If source is an Object that has a [[TypedArrayName]] internal slot, then
      1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
    9. Else,
      1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
    10. Return undefined.
    +
    1. Let target be the this value.
    2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
    3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
    4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
    5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    6. Let targetOffset be ? ToIntegerOrInfinity(offset).
    7. If targetOffset < 0, throw a RangeError exception.
    8. If source is an Object that has a [[TypedArrayName]] internal slot, then
      1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
    9. Else,
      1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
    10. Return undefined.

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    @@ -4094,7 +4094,7 @@

    23.2.3.26 %TypedArray%.prototype.set ( sour

    23.2.3.27 %TypedArray%.prototype.slice ( start, end )

    The interpretation and use of the arguments of this method are the same as for Array.prototype.slice as defined in 23.1.3.28.

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let srcArrayLength be TypedArrayLength(taRecord).
    4. Let relativeStart be ? ToIntegerOrInfinity(start).
    5. If relativeStart = -∞, let startIndex be 0.
    6. Else if relativeStart < 0, let startIndex be max(srcArrayLength + relativeStart, 0).
    7. Else, let startIndex be min(relativeStart, srcArrayLength).
    8. If end is undefined, let relativeEnd be srcArrayLength; else let relativeEnd be ? ToIntegerOrInfinity(end).
    9. If relativeEnd = -∞, let endIndex be 0.
    10. Else if relativeEnd < 0, let endIndex be max(srcArrayLength + relativeEnd, 0).
    11. Else, let endIndex be min(relativeEnd, srcArrayLength).
    12. Let countBytes be max(endIndex - startIndex, 0).
    13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(countBytes) », write).
    14. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    15. If countBytes > 0, then
      1. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      2. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      3. Set endIndex to min(endIndex, TypedArrayLength(taRecord)).
      4. Set countBytes to max(endIndex - startIndex, 0).
      5. Let srcType be TypedArrayElementType(O).
      6. Let targetType be TypedArrayElementType(A).
      7. If srcType is targetType, then
        1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
        2. Let srcBuffer be O.[[ViewedArrayBuffer]].
        3. Let targetBuffer be A.[[ViewedArrayBuffer]].
        4. Let elementSize be TypedArrayElementSize(O).
        5. Let srcByteOffset be O.[[ByteOffset]].
        6. Let srcByteIndex be (startIndex × elementSize) + srcByteOffset.
        7. Let targetByteIndex be A.[[ByteOffset]].
        8. Let endByteIndex be targetByteIndex + (countBytes × elementSize).
        9. Repeat, while targetByteIndex < endByteIndex,
          1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
          3. Set srcByteIndex to srcByteIndex + 1.
          4. Set targetByteIndex to targetByteIndex + 1.
      8. Else,
        1. Let n be 0.
        2. Let k be startIndex.
        3. Repeat, while k < endIndex,
          1. Let Pk be ! ToString(𝔽(k)).
          2. Let kValue be ! Get(O, Pk).
          3. Perform ! Set(A, ! ToString(𝔽(n)), kValue, true).
          4. Set k to k + 1.
          5. Set n to n + 1.
    16. Return A.
    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let srcArrayLength be TypedArrayLength(taRecord).
    4. Let relativeStart be ? ToIntegerOrInfinity(start).
    5. If relativeStart = -∞, let startIndex be 0.
    6. Else if relativeStart < 0, let startIndex be max(srcArrayLength + relativeStart, 0).
    7. Else, let startIndex be min(relativeStart, srcArrayLength).
    8. If end is undefined, let relativeEnd be srcArrayLength; else let relativeEnd be ? ToIntegerOrInfinity(end).
    9. If relativeEnd = -∞, let endIndex be 0.
    10. Else if relativeEnd < 0, let endIndex be max(srcArrayLength + relativeEnd, 0).
    11. Else, let endIndex be min(relativeEnd, srcArrayLength).
    12. Let countBytes be max(endIndex - startIndex, 0).
    13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(countBytes) », write).
    14. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    15. If countBytes > 0, then
      1. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      2. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      3. Set endIndex to min(endIndex, TypedArrayLength(taRecord)).
      4. Set countBytes to max(endIndex - startIndex, 0).
      5. Let srcType be TypedArrayElementType(O).
      6. Let targetType be TypedArrayElementType(A).
      7. If srcType is targetType, then
        1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
        2. Let srcBuffer be O.[[ViewedArrayBuffer]].
        3. Let targetBuffer be A.[[ViewedArrayBuffer]].
        4. Let elementSize be TypedArrayElementSize(O).
        5. Let srcByteOffset be O.[[ByteOffset]].
        6. Let srcByteIndex be (startIndex × elementSize) + srcByteOffset.
        7. Let targetByteIndex be A.[[ByteOffset]].
        8. Let endByteIndex be targetByteIndex + (countBytes × elementSize).
        9. Repeat, while targetByteIndex < endByteIndex,
          1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
          3. Set srcByteIndex to srcByteIndex + 1.
          4. Set targetByteIndex to targetByteIndex + 1.
      8. Else,
        1. Let n be 0.
        2. Let k be startIndex.
        3. Repeat, while k < endIndex,
          1. Let Pk be ! ToString(𝔽(k)).
          2. Let kValue be ! Get(O, Pk).
          3. Perform ! Set(A, ! ToString(𝔽(n)), kValue, true).
          4. Set k to k + 1.
          5. Set n to n + 1.
    16. Return A.

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    @@ -4103,7 +4103,7 @@

    23.2.3.29 %TypedArray%.prototype.sort ( com

    This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    It performs the following steps when called:

    -
    1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
    2. Let obj be the this value.
    3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
    4. Let len be TypedArrayLength(taRecord).
    5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
    6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
      1. Return ? CompareTypedArrayElements(x, y, comparator).
    7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
    8. Let j be 0.
    9. Repeat, while j < len,
      1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
      2. Set j to j + 1.
    10. Return obj.
    +
    1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
    2. Let obj be the this value.
    3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
    4. Let len be TypedArrayLength(taRecord).
    5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
    6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
      1. Return ? CompareTypedArrayElements(x, y, comparator).
    7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
    8. Let j be 0.
    9. Repeat, while j < len,
      1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
      2. Set j to j + 1.
    10. Return obj.
    Note

    Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

    @@ -4116,13 +4116,13 @@

    23.2.4 Abstract Operations for TypedArray Object

    23.2.4.1 TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )

    The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a TypedArray) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function that is derived from exemplar. Unlike ArraySpeciesCreate, which can create non-Array objects through the use of %Symbol.species%, this operation enforces that the constructor function creates an actual TypedArray. It performs the following steps when called:

    -
    1. If accessMode is not present, set accessMode to read.
    2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73.
    3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
    4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode).
    5. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots.
    6. Assert: result has all of the internal slots of a TypedArray instance (23.2.8).
    7. If result.[[ContentType]] is not exemplar.[[ContentType]], throw a TypeError exception.
    8. Return result.
    +
    1. If accessMode is not present, set accessMode to read.
    2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73.
    3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
    4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode).
    5. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots.
    6. Assert: result has all of the internal slots of a TypedArray instance (23.2.8).
    7. If result.[[ContentType]] is not exemplar.[[ContentType]], throw a TypeError exception.
    8. Return result.

    23.2.4.2 TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] )

    The abstract operation TypedArrayCreateFromConstructor takes arguments constructor (a constructor) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function. It performs the following steps when called:

    -
    1. If accessMode is not present, set accessMode to read.
    2. Let newTypedArray be ? Construct(constructor, argumentList).
    3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode).
    4. If the number of elements in argumentList is 1 and argumentList[0] is a Number, then
      1. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      2. Let length be TypedArrayLength(taRecord).
      3. If length < (argumentList[0]), throw a TypeError exception.
    5. Return newTypedArray.
    +
    1. If accessMode is not present, set accessMode to read.
    2. Let newTypedArray be ? Construct(constructor, argumentList).
    3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode).
    4. If the number of elements in argumentList is 1 and argumentList[0] is a Number, then
      1. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      2. Let length be TypedArrayLength(taRecord).
      3. If length < (argumentList[0]), throw a TypeError exception.
    5. Return newTypedArray.
    @@ -4148,7 +4148,7 @@

    25.1.3.1 AllocateArrayBuffer ( constructor<

    The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

    Editor's Note
    The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.

    It performs the following steps when called:

    -
    1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
    2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
    3. If allocatingResizableBuffer is true, then
      1. If byteLength > maxByteLength, throw a RangeError exception.
      2. Append [[ArrayBufferMaxByteLength]] to slots.
    4. Else if maxByteLength is immutable, then
      1. Append [[ArrayBufferIsImmutable]] to slots.
    5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
    6. Let block be ? CreateByteDataBlock(byteLength).
    7. Set obj.[[ArrayBufferData]] to block.
    8. Set obj.[[ArrayBufferByteLength]] to byteLength.
    9. If allocatingResizableBuffer is true, then
      1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
      2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
      3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
    10. Return obj.
    +
    1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
    2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
    3. If allocatingResizableBuffer is true, then
      1. If byteLength > maxByteLength, throw a RangeError exception.
      2. Append [[ArrayBufferMaxByteLength]] to slots.
    4. Else if maxByteLength is immutable, then
      1. Append [[ArrayBufferIsImmutable]] to slots.
    5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
    6. Let block be ? CreateByteDataBlock(byteLength).
    7. Set obj.[[ArrayBufferData]] to block.
    8. Set obj.[[ArrayBufferByteLength]] to byteLength.
    9. If allocatingResizableBuffer is true, then
      1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
      2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
      3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
    10. Return obj.
    @@ -4168,7 +4168,7 @@

    25.1.3.3 ArrayBufferCopyAndDetach ( arrayBu

    The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

    Editor's Note
    The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.

    It performs the following steps when called:

    -
    1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
    2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
    3. If newLength is undefined, then
      1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
    4. Else,
      1. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
    6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
    7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    9. If preserveResizability is immutable, then
      1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
    10. Else,
      1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
        1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
      2. Else,
        1. Let newMaxByteLength be empty.
      3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
      4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
      5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
      6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
      7. Let toBlock be newBuffer.[[ArrayBufferData]].
      8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
      9. 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.
    11. Perform ! DetachArrayBuffer(arrayBuffer).
    12. Return newBuffer.
    +
    1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
    2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
    3. If newLength is undefined, then
      1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
    4. Else,
      1. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
    6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
    7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    9. If preserveResizability is immutable, then
      1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
    10. Else,
      1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
        1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
      2. Else,
        1. Let newMaxByteLength be empty.
      3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
      4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
      5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
      6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
      7. Let toBlock be newBuffer.[[ArrayBufferData]].
      8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
      9. 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.
    11. Perform ! DetachArrayBuffer(arrayBuffer).
    12. Return newBuffer.
    @@ -4217,13 +4217,13 @@

    25.1.6.1 get ArrayBuffer.prototype.immutable

    25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    6. Assert: IsImmutableBuffer(O) is false.
    7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
    8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
    9. If hostHandled is handled, return undefined.
    10. Let oldBlock be O.[[ArrayBufferData]].
    11. Let newBlock be ? CreateByteDataBlock(newByteLength).
    12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
    13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
    14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
    15. Set O.[[ArrayBufferData]] to newBlock.
    16. Set O.[[ArrayBufferByteLength]] to newByteLength.
    17. Return undefined.
    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    6. Assert: IsImmutableBuffer(O) is false.
    7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
    8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
    9. If hostHandled is handled, return undefined.
    10. Let oldBlock be O.[[ArrayBufferData]].
    11. Let newBlock be ? CreateByteDataBlock(newByteLength).
    12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
    13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
    14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
    15. Set O.[[ArrayBufferData]] to newBlock.
    16. Set O.[[ArrayBufferByteLength]] to newByteLength.
    17. Return undefined.

    25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let first be 0.
    8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
    9. Else, let first be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let final be 0.
    12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
    13. Else, let final be min(relativeEnd, len).
    14. Let bounds be ? ResolveBounds(len, start, end).
    15. Let first be bounds.[[From]].
    16. Let final be bounds.[[To]].
    17. Let newLen be max(final - first, 0).
    18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
    19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
    20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
    21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
    22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
    23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
    24. If SameValue(new, O) is true, throw a TypeError exception.
    25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
    26. NOTE: Side-effects of the above steps may have detached or resized O.
    27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    28. Let fromBuf be O.[[ArrayBufferData]].
    29. Let toBuf be new.[[ArrayBufferData]].
    30. Let currentLen be O.[[ArrayBufferByteLength]].
    31. If first < currentLen, then
      1. Let count be min(newLen, currentLen - first).
      2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
    32. Return new.
    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let first be 0.
    8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
    9. Else, let first be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let final be 0.
    12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
    13. Else, let final be min(relativeEnd, len).
    14. Let bounds be ? ResolveBounds(len, start, end).
    15. Let first be bounds.[[From]].
    16. Let final be bounds.[[To]].
    17. Let newLen be max(final - first, 0).
    18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
    19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
    20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
    21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
    22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
    23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
    24. If SameValue(new, O) is true, throw a TypeError exception.
    25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
    26. NOTE: Side-effects of the above steps may have detached or resized O.
    27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    28. Let fromBuf be O.[[ArrayBufferData]].
    29. Let toBuf be new.[[ArrayBufferData]].
    30. Let currentLen be O.[[ArrayBufferByteLength]].
    31. If first < currentLen, then
      1. Let count be min(newLen, currentLen - first).
      2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
    32. Return new.
    @@ -4231,7 +4231,7 @@

    25.1.6.7 ArrayBuffer.prototype.slice ( star

    25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let bounds be ? ResolveBounds(len, start, end).
    7. Let first be bounds.[[From]].
    8. Let final be bounds.[[To]].
    9. Let newLen be max(final - first, 0).
    10. NOTE: Side-effects of the above steps may have detached or resized O.
    11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    12. Let fromBuf be O.[[ArrayBufferData]].
    13. Let currentLen be O.[[ArrayBufferByteLength]].
    14. If currentLen < final, throw a RangeError exception.
    15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
    16. Return newBuffer.
    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let bounds be ? ResolveBounds(len, start, end).
    7. Let first be bounds.[[From]].
    8. Let final be bounds.[[To]].
    9. Let newLen be max(final - first, 0).
    10. NOTE: Side-effects of the above steps may have detached or resized O.
    11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    12. Let fromBuf be O.[[ArrayBufferData]].
    13. Let currentLen be O.[[ArrayBufferByteLength]].
    14. If currentLen < final, throw a RangeError exception.
    15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
    16. Return newBuffer.
    @@ -4240,7 +4240,7 @@

    25.1.6.8 ArrayBuffer.prototype.sliceToImmutable

    25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

    This method performs the following steps when called:

    -
    1. Let O be the this value.
    2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
    +
    1. Let O be the this value.
    2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
    @@ -4262,7 +4262,7 @@

    25.3.1 Abstract Operations For DataView Objects<

    25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

    The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

    -
    1. Perform ? RequireInternalSlot(view, [[DataView]]).
    2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
    3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    4. Let getIndex be ? ToIndex(requestIndex).
    5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
    6. Otherwise, let numberValue be ? ToNumber(value).
    7. Set isLittleEndian to ToBoolean(isLittleEndian).
    8. Let viewOffset be view.[[ByteOffset]].
    9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
    10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
    11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
    12. Let viewSize be GetViewByteLength(viewRecord).
    13. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    14. If getIndex + elementSize > viewSize, throw a RangeError exception.
    15. Let bufferIndex be getIndex + viewOffset.
    16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
    17. Return undefined.
    +
    1. Perform ? RequireInternalSlot(view, [[DataView]]).
    2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
    3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    4. Let getIndex be ? ToIndex(requestIndex).
    5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
    6. Otherwise, let numberValue be ? ToNumber(value).
    7. Set isLittleEndian to ToBoolean(isLittleEndian).
    8. Let viewOffset be view.[[ByteOffset]].
    9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
    10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
    11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
    12. Let viewSize be GetViewByteLength(viewRecord).
    13. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    14. If getIndex + elementSize > viewSize, throw a RangeError exception.
    15. Let bufferIndex be getIndex + viewOffset.
    16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
    17. Return undefined.
    @@ -4282,26 +4282,26 @@

    25.4.3.1 ValidateIntegerTypedArray ( typedA

    25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

    The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

    -
    1. If waitable is not present, set waitable to false.
    2. If accessMode is not present, set accessMode to read.
    3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
    4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
    +
    1. If waitable is not present, set waitable to false.
    2. If accessMode is not present, set accessMode to read.
    3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
    4. Return ? ValidateAtomicAccess(taRecord, requestIndex).

    25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

    The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

    -
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).

    25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

    This function performs the following steps when called:

    -
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. Let buffer be typedArray.[[ViewedArrayBuffer]].
    3. Let block be buffer.[[ArrayBufferData]].
    4. If typedArray.[[ContentType]] is bigint, then
      1. Let expected be ? ToBigInt(expectedValue).
      2. Let replacement be ? ToBigInt(replacementValue).
    5. Else,
      1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
      2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
    6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    7. Let elementType be TypedArrayElementType(typedArray).
    8. Let elementSize be TypedArrayElementSize(typedArray).
    9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
    11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
    12. If IsSharedArrayBuffer(buffer) is true, then
      1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
    13. Else,
      1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
      2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
        1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
    14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. Let buffer be typedArray.[[ViewedArrayBuffer]].
    3. Let block be buffer.[[ArrayBufferData]].
    4. If typedArray.[[ContentType]] is bigint, then
      1. Let expected be ? ToBigInt(expectedValue).
      2. Let replacement be ? ToBigInt(replacementValue).
    5. Else,
      1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
      2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
    6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    7. Let elementType be TypedArrayElementType(typedArray).
    8. Let elementSize be TypedArrayElementSize(typedArray).
    9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
    11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
    12. If IsSharedArrayBuffer(buffer) is true, then
      1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
    13. Else,
      1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
      2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
        1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
    14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).

    25.4.11 Atomics.store ( typedArray, index, value )

    This function performs the following steps when called:

    -
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
    8. Return v.
    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
    8. Return v.
    From 875f403dacb980e027ca3cd880ff3d1b6f7ff411 Mon Sep 17 00:00:00 2001 From: erights Date: Sun, 27 Jul 2025 14:39:11 +0000 Subject: [PATCH 91/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@746375b93131a4802ddb8f613ab11?= =?UTF-8?q?40ee80522a0=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 64 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index 17dc212..b643199 100644 --- a/index.html +++ b/index.html @@ -1914,6 +1914,23 @@ margin: 0 auto; } +#metadata-block { + margin: 4em 0; + padding: 10px; + border: 1px solid #ee8421; +} + +#metadata-block h1 { + font-size: 1.5em; + margin-top: 0; +} + +#metadata-block > ul { + list-style-type: none; + margin: 0; + padding: 0; +} + span[aria-hidden='true'] { font-size: 0; white-space: pre; @@ -3252,6 +3269,7 @@ #ecma-logo { background: var(--figure-background); + width: 500px; } + +
    + PR #56 +

    + This document is a preview of merging PR #56, resulting in commit 493a990e3f1c678bfae79e01dbc6191136a26018. +

    +

    + Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

    +
    + +
    +
      +
    • Toggle shortcuts help?
    • +
    • Toggle "can call user code" annotationsu
    • + +
    • Jump to search box/
    • +
    • Toggle pinning of the current clausep
    • +
    • Jump to the nth pin1-9
    • +
    • Jump to the 10th pin0
    • +
    • Jump to the most recent link target`
    • +

    Proposal proposal-immutable-arraybuffer

    Stage 2 Draft / July 28, 2025

    Immutable ArrayBuffers

    + + +

    6 ECMAScript Data Types and Values

    + + +

    6.2.9 Data Blocks

    +

    A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

    +
    +
    + + +

    7 Operations on Objects

    + + + + +

    7.1 ResolveBounds ( len, start, end )

    +

    The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

    +
    1. Let relativeStart be ? ToIntegerOrInfinity(start).
    2. If relativeStart = -∞, let from be 0.
    3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
    4. Else, let from be min(relativeStart, len).
    5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    6. If relativeEnd = -∞, let to be 0.
    7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
    8. Else, let to be min(relativeEnd, len).
    9. Return the Record { [[From]]: from, [[To]]: to }.
    +
    +
    +
    + + +

    10 Ordinary and Exotic Objects Behaviours

    + + +

    10.4 Built-in Exotic Object Internal Methods and Slots

    + + +

    10.4.5 TypedArray Exotic Objects

    + + +

    10.4.5.1 [[GetOwnProperty]] ( P )

    +

    The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. Let value be TypedArrayGetElement(O, numericIndex).
        2. If value is undefined, return undefined.
        3. Let mutable be true.
        4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
        5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
    2. Return OrdinaryGetOwnProperty(O, P).
    +
    + + +

    10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

    +

    The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
          1. Let current be ! O.[[GetOwnProperty]](P).
          2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
          3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
          4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
        3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
        4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
        5. If IsAccessorDescriptor(Desc) is true, return false.
        6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
        7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
        8. Return true.
    2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
    +
    + + +

    10.4.5.5 [[Set]] ( P, V, Receiver )

    +

    The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
        3. If SameValue(O, Receiver) is true, then
          1. Perform ? TypedArraySetElement(O, numericIndex, V).
          2. Return true.
        4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
    2. Return ? OrdinarySet(O, P, V, Receiver).
    +
    + + +

    10.4.5.16 TypedArraySetElement ( O, index, value )

    +

    The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

    +
    1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
    2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
    3. Otherwise, let numValue be ? ToNumber(value).
    4. If IsValidIntegerIndex(O, index) is true, then
      1. Let offset be O.[[ByteOffset]].
      2. Let elementSize be TypedArrayElementSize(O).
      3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
      4. Let elementType be TypedArrayElementType(O).
      5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
    5. Return unused.
    + Note
    +

    This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

    +
    +
    +
    +
    +
    + + +

    23 Indexed Collections

    + + +

    23.2 TypedArray Objects

    + + +

    23.2.2 Properties of the %TypedArray% Intrinsic Object

    +

    The %TypedArray% intrinsic object:

    +
      +
    • has a [[Prototype]] internal slot whose value is %Function.prototype%.
    • +
    • has a "name" property whose value is "TypedArray".
    • +
    • has the following properties:
    • +
    + + +

    23.2.2.1 %TypedArray%.from ( source [ , mapper [ , thisArg ] ] )

    +

    This method performs the following steps when called:

    +
    1. Let C be the this value.
    2. If IsConstructor(C) is false, throw a TypeError exception.
    3. If mapper is undefined, then
      1. Let mapping be false.
    4. Else,
      1. If IsCallable(mapper) is false, throw a TypeError exception.
      2. Let mapping be true.
    5. Let usingIterator be ? GetMethod(source, %Symbol.iterator%).
    6. If usingIterator is not undefined, then
      1. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)).
      2. Let len be the number of elements in values.
      3. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
      4. Let k be 0.
      5. Repeat, while k < len,
        1. Let Pk be ! ToString(𝔽(k)).
        2. Let kValue be the first element of values.
        3. Remove the first element from values.
        4. If mapping is true, then
          1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
        5. Else,
          1. Let mappedValue be kValue.
        6. Perform ? Set(targetObj, Pk, mappedValue, true).
        7. Set k to k + 1.
      6. Assert: values is now an empty List.
      7. Return targetObj.
    7. NOTE: source is not an iterable object, so assume it is already an array-like object.
    8. Let arrayLike be ! ToObject(source).
    9. Let len be ? LengthOfArrayLike(arrayLike).
    10. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    11. Let k be 0.
    12. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ? Get(arrayLike, Pk).
      3. If mapping is true, then
        1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
      4. Else,
        1. Let mappedValue be kValue.
      5. Perform ? Set(targetObj, Pk, mappedValue, true).
      6. Set k to k + 1.
    13. Return targetObj.
    +
    + + +

    23.2.2.2 %TypedArray%.of ( ...items )

    +

    This method performs the following steps when called:

    +
    1. Let len be the number of elements in items.
    2. Let C be the this value.
    3. If IsConstructor(C) is false, throw a TypeError exception.
    4. Let newObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    5. Let k be 0.
    6. Repeat, while k < len,
      1. Let kValue be items[k].
      2. Let Pk be ! ToString(𝔽(k)).
      3. Perform ? Set(newObj, Pk, kValue, true).
      4. Set k to k + 1.
    7. Return newObj.
    +
    +
    + + +

    23.2.3 Properties of the %TypedArray% Prototype Object

    + + +

    23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. Let relativeTarget be ? ToIntegerOrInfinity(target).
    5. If relativeTarget = -∞, let targetIndex be 0.
    6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
    7. Else, let targetIndex be min(relativeTarget, len).
    8. Let relativeStart be ? ToIntegerOrInfinity(start).
    9. If relativeStart = -∞, let startIndex be 0.
    10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    11. Else, let startIndex be min(relativeStart, len).
    12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    13. If relativeEnd = -∞, let endIndex be 0.
    14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    15. Else, let endIndex be min(relativeEnd, len).
    16. Let count be min(endIndex - startIndex, len - targetIndex).
    17. If count > 0, then
      1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
      2. Let buffer be O.[[ViewedArrayBuffer]].
      3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      5. Set len to TypedArrayLength(taRecord).
      6. Let elementSize be TypedArrayElementSize(O).
      7. Let byteOffset be O.[[ByteOffset]].
      8. Let bufferByteLimit be (len × elementSize) + byteOffset.
      9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
      10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
      11. Let countBytes be count × elementSize.
      12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
        1. Let direction be -1.
        2. Set fromByteIndex to fromByteIndex + countBytes - 1.
        3. Set toByteIndex to toByteIndex + countBytes - 1.
      13. Else,
        1. Let direction be 1.
      14. Repeat, while countBytes > 0,
        1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
          1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
          3. Set fromByteIndex to fromByteIndex + direction.
          4. Set toByteIndex to toByteIndex + direction.
          5. Set countBytes to countBytes - 1.
        2. Else,
          1. Set countBytes to 0.
    18. Return O.
    +
    + + +

    23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
    5. Otherwise, set value to ? ToNumber(value).
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let startIndex be 0.
    8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    9. Else, let startIndex be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let endIndex be 0.
    12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    13. Else, let endIndex be min(relativeEnd, len).
    14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    16. Set len to TypedArrayLength(taRecord).
    17. Set endIndex to min(endIndex, len).
    18. Let k be startIndex.
    19. Repeat, while k < endIndex,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Perform ! Set(O, Pk, value, true).
      3. Set k to k + 1.
    20. Return O.
    +
    + + +

    23.2.3.10 %TypedArray%.prototype.filter ( callback [ , thisArg ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.filter as defined in 23.1.3.8.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let kept be a new empty List.
    6. Let captured be 0.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let selected be ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), O »)).
      4. If selected is true, then
        1. Append kValue to kept.
        2. Set captured to captured + 1.
      5. Set k to k + 1.
    9. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) », write).
    10. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    11. Let n be 0.
    12. For each element e of kept, do
      1. Perform ! Set(A, ! ToString(𝔽(n)), e, true).
      2. Set n to n + 1.
    13. Return A.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.22 %TypedArray%.prototype.map ( callback [ , thisArg ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.map as defined in 23.1.3.21.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(len) », write).
    6. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let mappedValue be ? Call(callback, thisArg, « kValue, 𝔽(k), O »).
      4. Perform ? Set(A, Pk, mappedValue, true).
      5. Set k to k + 1.
    9. Return A.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.25 %TypedArray%.prototype.reverse ( )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. Let middle be floor(len / 2).
    5. Let lower be 0.
    6. Repeat, while lowermiddle,
      1. Let upper be len - lower - 1.
      2. Let upperP be ! ToString(𝔽(upper)).
      3. Let lowerP be ! ToString(𝔽(lower)).
      4. Let lowerValue be ! Get(O, lowerP).
      5. Let upperValue be ! Get(O, upperP).
      6. Perform ! Set(O, lowerP, upperValue, true).
      7. Perform ! Set(O, upperP, lowerValue, true).
      8. Set lower to lower + 1.
    7. Return O.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

    +

    This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

    +

    It performs the following steps when called:

    +
    1. Let target be the this value.
    2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
    3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
    4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
    5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    6. Let targetOffset be ? ToIntegerOrInfinity(offset).
    7. If targetOffset < 0, throw a RangeError exception.
    8. If source is an Object that has a [[TypedArrayName]] internal slot, then
      1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
    9. Else,
      1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
    10. Return undefined.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.27 %TypedArray%.prototype.slice ( start, end )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.slice as defined in 23.1.3.28.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let srcArrayLength be TypedArrayLength(taRecord).
    4. Let relativeStart be ? ToIntegerOrInfinity(start).
    5. If relativeStart = -∞, let startIndex be 0.
    6. Else if relativeStart < 0, let startIndex be max(srcArrayLength + relativeStart, 0).
    7. Else, let startIndex be min(relativeStart, srcArrayLength).
    8. If end is undefined, let relativeEnd be srcArrayLength; else let relativeEnd be ? ToIntegerOrInfinity(end).
    9. If relativeEnd = -∞, let endIndex be 0.
    10. Else if relativeEnd < 0, let endIndex be max(srcArrayLength + relativeEnd, 0).
    11. Else, let endIndex be min(relativeEnd, srcArrayLength).
    12. Let countBytes be max(endIndex - startIndex, 0).
    13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(countBytes) », write).
    14. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    15. If countBytes > 0, then
      1. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      2. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      3. Set endIndex to min(endIndex, TypedArrayLength(taRecord)).
      4. Set countBytes to max(endIndex - startIndex, 0).
      5. Let srcType be TypedArrayElementType(O).
      6. Let targetType be TypedArrayElementType(A).
      7. If srcType is targetType, then
        1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
        2. Let srcBuffer be O.[[ViewedArrayBuffer]].
        3. Let targetBuffer be A.[[ViewedArrayBuffer]].
        4. Let elementSize be TypedArrayElementSize(O).
        5. Let srcByteOffset be O.[[ByteOffset]].
        6. Let srcByteIndex be (startIndex × elementSize) + srcByteOffset.
        7. Let targetByteIndex be A.[[ByteOffset]].
        8. Let endByteIndex be targetByteIndex + (countBytes × elementSize).
        9. Repeat, while targetByteIndex < endByteIndex,
          1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
          3. Set srcByteIndex to srcByteIndex + 1.
          4. Set targetByteIndex to targetByteIndex + 1.
      8. Else,
        1. Let n be 0.
        2. Let k be startIndex.
        3. Repeat, while k < endIndex,
          1. Let Pk be ! ToString(𝔽(k)).
          2. Let kValue be ! Get(O, Pk).
          3. Perform ! Set(A, ! ToString(𝔽(n)), kValue, true).
          4. Set k to k + 1.
          5. Set n to n + 1.
    16. Return A.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.29 %TypedArray%.prototype.sort ( comparator )

    +

    This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +

    It performs the following steps when called:

    +
    1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
    2. Let obj be the this value.
    3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
    4. Let len be TypedArrayLength(taRecord).
    5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
    6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
      1. Return ? CompareTypedArrayElements(x, y, comparator).
    7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
    8. Let j be 0.
    9. Repeat, while j < len,
      1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
      2. Set j to j + 1.
    10. Return obj.
    + Note
    +

    Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

    +
    +
    +
    + + +

    23.2.4 Abstract Operations for TypedArray Objects

    + + +

    23.2.4.1 TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )

    +

    The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a TypedArray) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function that is derived from exemplar. Unlike ArraySpeciesCreate, which can create non-Array objects through the use of %Symbol.species%, this operation enforces that the constructor function creates an actual TypedArray. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73.
    3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
    4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode).
    5. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots.
    6. Assert: result has all of the internal slots of a TypedArray instance (23.2.8).
    7. If result.[[ContentType]] is not exemplar.[[ContentType]], throw a TypeError exception.
    8. Return result.
    +
    + + +

    23.2.4.2 TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] )

    +

    The abstract operation TypedArrayCreateFromConstructor takes arguments constructor (a constructor) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Let newTypedArray be ? Construct(constructor, argumentList).
    3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode).
    4. If the number of elements in argumentList is 1 and argumentList[0] is a Number, then
      1. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      2. Let length be TypedArrayLength(taRecord).
      3. If length < (argumentList[0]), throw a TypeError exception.
    5. Return newTypedArray.
    +
    + + +

    23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

    +

    The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
    3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
    4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
    6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    7. Return taRecord.
    +
    +
    +
    +
    + + +

    25 Structured Data

    + + +

    25.1 ArrayBuffer Objects

    + + +

    25.1.3 Abstract Operations For ArrayBuffer Objects

    + + +

    25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

    +

    The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

    + Editor's Note
    The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
    +

    It performs the following steps when called:

    +
    1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
    2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
    3. If allocatingResizableBuffer is true, then
      1. If byteLength > maxByteLength, throw a RangeError exception.
      2. Append [[ArrayBufferMaxByteLength]] to slots.
    4. Else if maxByteLength is immutable, then
      1. Append [[ArrayBufferIsImmutable]] to slots.
    5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
    6. Let block be ? CreateByteDataBlock(byteLength).
    7. Set obj.[[ArrayBufferData]] to block.
    8. Set obj.[[ArrayBufferByteLength]] to byteLength.
    9. If allocatingResizableBuffer is true, then
      1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
      2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
      3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
    10. Return obj.
    +
    + + + + +

    25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

    +

    The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities inside an implementation or observable by it. It performs the following steps when called:

    +
    1. Assert: constructor is %ArrayBuffer%.
    2. Assert: countbyteLength.
    3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
    4. Let toBlock be newBuffer.[[ArrayBufferData]].
    5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
    6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
    7. Return newBuffer.
    + Note
    +

    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.

    +
    +
    +
    + + +

    25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

    +

    The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

    + Editor's Note
    The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
    +

    It performs the following steps when called:

    +
    1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
    2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
    3. If newLength is undefined, then
      1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
    4. Else,
      1. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
    6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
    7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    9. If preserveResizability is immutable, then
      1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
    10. Else,
      1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
        1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
      2. Else,
        1. Let newMaxByteLength be empty.
      3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
      4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
      5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
      6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
      7. Let toBlock be newBuffer.[[ArrayBufferData]].
      8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
      9. 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.
    11. Perform ! DetachArrayBuffer(arrayBuffer).
    12. Return newBuffer.
    +
    + + + + +

    25.1.3.4 IsImmutableBuffer ( arrayBuffer )

    +

    The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

    +
    1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
    2. Return false.
    +
    +
    + + +

    25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

    +

    The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

    +
    1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
    2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
    3. If key is not present, set key to undefined.
    4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
    5. Set arrayBuffer.[[ArrayBufferData]] to null.
    6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
    7. Return unused.
    + Note
    +

    Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

    +
    +
    + + +

    25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

    +

    The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

    +
    1. Assert: IsDetachedBuffer(arrayBuffer) is false.
    2. Assert: IsImmutableBuffer(arrayBuffer) is false.
    3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
    4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
    5. Let block be arrayBuffer.[[ArrayBufferData]].
    6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
    9. If IsSharedArrayBuffer(arrayBuffer) is true, then
      1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
      2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
      3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
      4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
    10. Else,
      1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
    11. Return unused.
    +
    + + +

    25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

    +

    The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

    +
    1. Assert: IsDetachedBuffer(arrayBuffer) is false.
    2. Assert: IsImmutableBuffer(arrayBuffer) is false.
    3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
    4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
    5. Let block be arrayBuffer.[[ArrayBufferData]].
    6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
    9. If IsSharedArrayBuffer(arrayBuffer) is true, then
      1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
      2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
      3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
      4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
      5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
      6. Append rmwEvent to eventsRecord.[[EventList]].
      7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
    10. Else,
      1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
      2. Let rawBytesModified be op(rawBytesRead, rawBytes).
      3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
    11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
    +
    +
    + + +

    25.1.6 Properties of the ArrayBuffer Prototype Object

    + + + + +

    25.1.6.1 get ArrayBuffer.prototype.immutable

    +

    ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Return IsImmutableBuffer(O).
    +
    +
    + + +

    25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    6. Assert: IsImmutableBuffer(O) is false.
    7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
    8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
    9. If hostHandled is handled, return undefined.
    10. Let oldBlock be O.[[ArrayBufferData]].
    11. Let newBlock be ? CreateByteDataBlock(newByteLength).
    12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
    13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
    14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
    15. Set O.[[ArrayBufferData]] to newBlock.
    16. Set O.[[ArrayBufferByteLength]] to newByteLength.
    17. Return undefined.
    +
    + + +

    25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let first be 0.
    8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
    9. Else, let first be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let final be 0.
    12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
    13. Else, let final be min(relativeEnd, len).
    14. Let bounds be ? ResolveBounds(len, start, end).
    15. Let first be bounds.[[From]].
    16. Let final be bounds.[[To]].
    17. Let newLen be max(final - first, 0).
    18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
    19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
    20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
    21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
    22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
    23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
    24. If SameValue(new, O) is true, throw a TypeError exception.
    25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
    26. NOTE: Side-effects of the above steps may have detached or resized O.
    27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    28. Let fromBuf be O.[[ArrayBufferData]].
    29. Let toBuf be new.[[ArrayBufferData]].
    30. Let currentLen be O.[[ArrayBufferByteLength]].
    31. If first < currentLen, then
      1. Let count be min(newLen, currentLen - first).
      2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
    32. Return new.
    +
    + + + + +

    25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let bounds be ? ResolveBounds(len, start, end).
    7. Let first be bounds.[[From]].
    8. Let final be bounds.[[To]].
    9. Let newLen be max(final - first, 0).
    10. NOTE: Side-effects of the above steps may have detached or resized O.
    11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    12. Let fromBuf be O.[[ArrayBufferData]].
    13. Let currentLen be O.[[ArrayBufferByteLength]].
    14. If currentLen < final, throw a RangeError exception.
    15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
    16. Return newBuffer.
    +
    +
    + + + + +

    25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
    +
    +
    +
    + + +

    25.1.7 Properties of ArrayBuffer Instances

    +

    ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

    +

    ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

    +

    ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

    +
    +
    + + +

    25.3 DataView Objects

    + + +

    25.3.1 Abstract Operations For DataView Objects

    + + +

    25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

    +

    The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

    +
    1. Perform ? RequireInternalSlot(view, [[DataView]]).
    2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
    3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    4. Let getIndex be ? ToIndex(requestIndex).
    5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
    6. Otherwise, let numberValue be ? ToNumber(value).
    7. Set isLittleEndian to ToBoolean(isLittleEndian).
    8. Let viewOffset be view.[[ByteOffset]].
    9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
    10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
    11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
    12. Let viewSize be GetViewByteLength(viewRecord).
    13. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    14. If getIndex + elementSize > viewSize, throw a RangeError exception.
    15. Let bufferIndex be getIndex + viewOffset.
    16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
    17. Return undefined.
    +
    +
    +
    + + +

    25.4 The Atomics Object

    + + +

    25.4.3 Abstract Operations for Atomics

    + + +

    25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

    +

    The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
    3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
    4. If waitable is true, then
      1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
    5. Else,
      1. Let type be TypedArrayElementType(typedArray).
      2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
    6. Return taRecord.
    +
    + + +

    25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

    +

    The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

    +
    1. If waitable is not present, set waitable to false.
    2. If accessMode is not present, set accessMode to read.
    3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
    4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
    +
    + + +

    25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

    +

    The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
    +
    +
    + + +

    25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

    +

    This function performs the following steps when called:

    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. Let buffer be typedArray.[[ViewedArrayBuffer]].
    3. Let block be buffer.[[ArrayBufferData]].
    4. If typedArray.[[ContentType]] is bigint, then
      1. Let expected be ? ToBigInt(expectedValue).
      2. Let replacement be ? ToBigInt(replacementValue).
    5. Else,
      1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
      2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
    6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    7. Let elementType be TypedArrayElementType(typedArray).
    8. Let elementSize be TypedArrayElementSize(typedArray).
    9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
    11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
    12. If IsSharedArrayBuffer(buffer) is true, then
      1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
    13. Else,
      1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
      2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
        1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
    14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
    +
    + + +

    25.4.11 Atomics.store ( typedArray, index, value )

    +

    This function performs the following steps when called:

    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
    8. Return v.
    +
    +
    +
    +

    Copyright & Software License

    + + +

    Software License

    +

    All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

    + +

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    + +
      +
    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    2. +
    3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    4. +
    5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
    6. +
    + +

    THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    + +
    +
    \ No newline at end of file From 6f26c7e7b40c780a28c05568d08b091a90185f58 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Mon, 28 Jul 2025 23:52:56 +0000 Subject: [PATCH 93/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@6df24a7f71205c41920ad8b227159?= =?UTF-8?q?0b045dc2050=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index b643199..bc3219b 100644 --- a/index.html +++ b/index.html @@ -3990,7 +3990,7 @@

    Proposal proposal-immutable-arraybuffer

    Stage 2 Draft / July 27, 2025

    Immutable ArrayBuffers

    +

    Proposal proposal-immutable-arraybuffer

    Stage 2 Draft / July 28, 2025

    Immutable ArrayBuffers

    6 ECMAScript Data Types and Values

    From 0ec95ab69e16b95735a07de95cb3fa7e475bbb6f Mon Sep 17 00:00:00 2001 From: nicolo-ribaudo Date: Wed, 17 Sep 2025 15:40:26 +0000 Subject: [PATCH 94/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@6df24a7f71205c41920ad8b227159?= =?UTF-8?q?0b045dc2050=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/58/index.html | 4409 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 4409 insertions(+) create mode 100644 pr/58/index.html diff --git a/pr/58/index.html b/pr/58/index.html new file mode 100644 index 0000000..8467e8f --- /dev/null +++ b/pr/58/index.html @@ -0,0 +1,4409 @@ + + + + + +Immutable ArrayBuffers + +
    + PR #58 +

    + This document is a preview of merging PR #58, resulting in commit b7c2bbdcf328d99be1b6a5a7588df24e11888cb5. +

    +

    + Do not reference it as authoritative in any way. + Instead, see https://github.com/tc39/proposal-immutable-arraybuffer for the living specification. +

    +
    + +
    +
      +
    • Toggle shortcuts help?
    • +
    • Toggle "can call user code" annotationsu
    • + +
    • Jump to search box/
    • +
    • Toggle pinning of the current clausep
    • +
    • Jump to the nth pin1-9
    • +
    • Jump to the 10th pin0
    • +
    • Jump to the most recent link target`
    • +

    Proposal proposal-immutable-arraybuffer

    Stage 2.7 Draft / September 17, 2025

    Immutable ArrayBuffers

    + + +

    6 ECMAScript Data Types and Values

    + + +

    6.2.9 Data Blocks

    +

    A data block that resides in memory that can be referenced from multiple agents concurrently is designated a Shared Data Block. A Shared Data Block has an identity (for the purposes of equality testing Shared Data Block values) that is address-free: 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 data blocks Shared Data Blocks 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.

    +
    +
    + + +

    7 Operations on Objects

    + + + + +

    7.1 ResolveBounds ( len, start, end )

    +

    The abstract operation ResolveBounds takes arguments len (an integer), start (an ECMAScript language value), and end (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[From]] (a non-negative integer) and [[To]] (a non-negative integer) or a throw completion. It performs the following steps when called:

    +
    1. Let relativeStart be ? ToIntegerOrInfinity(start).
    2. If relativeStart = -∞, let from be 0.
    3. Else if relativeStart < 0, let from be max(len + relativeStart, 0).
    4. Else, let from be min(relativeStart, len).
    5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    6. If relativeEnd = -∞, let to be 0.
    7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0).
    8. Else, let to be min(relativeEnd, len).
    9. Return the Record { [[From]]: from, [[To]]: to }.
    +
    +
    +
    + + +

    10 Ordinary and Exotic Objects Behaviours

    + + +

    10.4 Built-in Exotic Object Internal Methods and Slots

    + + +

    10.4.5 TypedArray Exotic Objects

    + + +

    10.4.5.1 [[GetOwnProperty]] ( P )

    +

    The [[GetOwnProperty]] internal method of a TypedArray O takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. Let value be TypedArrayGetElement(O, numericIndex).
        2. If value is undefined, return undefined.
        3. Let mutable be true.
        4. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
        5. Return the PropertyDescriptor { [[Value]]: value, [[Writable]]: true mutable, [[Enumerable]]: true, [[Configurable]]: true mutable }.
    2. Return OrdinaryGetOwnProperty(O, P).
    +
    + + +

    10.4.5.3 [[DefineOwnProperty]] ( P, Desc )

    +

    The [[DefineOwnProperty]] internal method of a TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. If IsValidIntegerIndex(O, numericIndex) is false, return false.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, then
          1. Let current be ! O.[[GetOwnProperty]](P).
          2. Assert: current.[[Configurable]] and current.[[Writable]] are both false.
          3. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.
          4. Return ValidateAndApplyPropertyDescriptor(O, P, false, Desc, current).
        3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is false, return false.
        4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
        5. If IsAccessorDescriptor(Desc) is true, return false.
        6. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, return false.
        7. If Desc has a [[Value]] field, perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
        8. Return true.
    2. Return ! OrdinaryDefineOwnProperty(O, P, Desc).
    +
    + + +

    10.4.5.5 [[Set]] ( P, V, Receiver )

    +

    The [[Set]] internal method of a TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

    +
    1. If P is a String, then
      1. Let numericIndex be CanonicalNumericIndexString(P).
      2. If numericIndex is not undefined, then
        1. NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.
        2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
        3. If SameValue(O, Receiver) is true, then
          1. Perform ? TypedArraySetElement(O, numericIndex, V).
          2. Return true.
        4. If IsValidIntegerIndex(O, numericIndex) is false, return true.
    2. Return ? OrdinarySet(O, P, V, Receiver).
    +
    + + +

    10.4.5.16 TypedArraySetElement ( O, index, value )

    +

    The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

    +
    1. Assert: IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is false.
    2. If O.[[ContentType]] is bigint, let numValue be ? ToBigInt(value).
    3. Otherwise, let numValue be ? ToNumber(value).
    4. If IsValidIntegerIndex(O, index) is true, then
      1. Let offset be O.[[ByteOffset]].
      2. Let elementSize be TypedArrayElementSize(O).
      3. Let byteIndexInBuffer be ((index) × elementSize) + offset.
      4. Let elementType be TypedArrayElementType(O).
      5. Perform SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered).
    5. Return unused.
    + Note
    +

    This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.

    +
    +
    +
    +
    +
    + + +

    23 Indexed Collections

    + + +

    23.2 TypedArray Objects

    + + +

    23.2.2 Properties of the %TypedArray% Intrinsic Object

    +

    The %TypedArray% intrinsic object:

    +
      +
    • has a [[Prototype]] internal slot whose value is %Function.prototype%.
    • +
    • has a "name" property whose value is "TypedArray".
    • +
    • has the following properties:
    • +
    + + +

    23.2.2.1 %TypedArray%.from ( source [ , mapper [ , thisArg ] ] )

    +

    This method performs the following steps when called:

    +
    1. Let C be the this value.
    2. If IsConstructor(C) is false, throw a TypeError exception.
    3. If mapper is undefined, then
      1. Let mapping be false.
    4. Else,
      1. If IsCallable(mapper) is false, throw a TypeError exception.
      2. Let mapping be true.
    5. Let usingIterator be ? GetMethod(source, %Symbol.iterator%).
    6. If usingIterator is not undefined, then
      1. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)).
      2. Let len be the number of elements in values.
      3. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
      4. Let k be 0.
      5. Repeat, while k < len,
        1. Let Pk be ! ToString(𝔽(k)).
        2. Let kValue be the first element of values.
        3. Remove the first element from values.
        4. If mapping is true, then
          1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
        5. Else,
          1. Let mappedValue be kValue.
        6. Perform ? Set(targetObj, Pk, mappedValue, true).
        7. Set k to k + 1.
      6. Assert: values is now an empty List.
      7. Return targetObj.
    7. NOTE: source is not an iterable object, so assume it is already an array-like object.
    8. Let arrayLike be ! ToObject(source).
    9. Let len be ? LengthOfArrayLike(arrayLike).
    10. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    11. Let k be 0.
    12. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ? Get(arrayLike, Pk).
      3. If mapping is true, then
        1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »).
      4. Else,
        1. Let mappedValue be kValue.
      5. Perform ? Set(targetObj, Pk, mappedValue, true).
      6. Set k to k + 1.
    13. Return targetObj.
    +
    + + +

    23.2.2.2 %TypedArray%.of ( ...items )

    +

    This method performs the following steps when called:

    +
    1. Let len be the number of elements in items.
    2. Let C be the this value.
    3. If IsConstructor(C) is false, throw a TypeError exception.
    4. Let newObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write).
    5. Let k be 0.
    6. Repeat, while k < len,
      1. Let kValue be items[k].
      2. Let Pk be ! ToString(𝔽(k)).
      3. Perform ? Set(newObj, Pk, kValue, true).
      4. Set k to k + 1.
    7. Return newObj.
    +
    +
    + + +

    23.2.3 Properties of the %TypedArray% Prototype Object

    + + +

    23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.copyWithin as defined in 23.1.3.4.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. Let relativeTarget be ? ToIntegerOrInfinity(target).
    5. If relativeTarget = -∞, let targetIndex be 0.
    6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0).
    7. Else, let targetIndex be min(relativeTarget, len).
    8. Let relativeStart be ? ToIntegerOrInfinity(start).
    9. If relativeStart = -∞, let startIndex be 0.
    10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    11. Else, let startIndex be min(relativeStart, len).
    12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    13. If relativeEnd = -∞, let endIndex be 0.
    14. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    15. Else, let endIndex be min(relativeEnd, len).
    16. Let count be min(endIndex - startIndex, len - targetIndex).
    17. If count > 0, then
      1. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
      2. Let buffer be O.[[ViewedArrayBuffer]].
      3. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      4. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      5. Set len to TypedArrayLength(taRecord).
      6. Let elementSize be TypedArrayElementSize(O).
      7. Let byteOffset be O.[[ByteOffset]].
      8. Let bufferByteLimit be (len × elementSize) + byteOffset.
      9. Let toByteIndex be (targetIndex × elementSize) + byteOffset.
      10. Let fromByteIndex be (startIndex × elementSize) + byteOffset.
      11. Let countBytes be count × elementSize.
      12. If fromByteIndex < toByteIndex and toByteIndex < fromByteIndex + countBytes, then
        1. Let direction be -1.
        2. Set fromByteIndex to fromByteIndex + countBytes - 1.
        3. Set toByteIndex to toByteIndex + countBytes - 1.
      13. Else,
        1. Let direction be 1.
      14. Repeat, while countBytes > 0,
        1. If fromByteIndex < bufferByteLimit and toByteIndex < bufferByteLimit, then
          1. Let value be GetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered).
          3. Set fromByteIndex to fromByteIndex + direction.
          4. Set toByteIndex to toByteIndex + direction.
          5. Set countBytes to countBytes - 1.
        2. Else,
          1. Set countBytes to 0.
    18. Return O.
    +
    + + +

    23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.fill as defined in 23.1.3.7.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value).
    5. Otherwise, set value to ? ToNumber(value).
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let startIndex be 0.
    8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0).
    9. Else, let startIndex be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let endIndex be 0.
    12. Else if relativeEnd < 0, let endIndex be max(len + relativeEnd, 0).
    13. Else, let endIndex be min(relativeEnd, len).
    14. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
    15. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    16. Set len to TypedArrayLength(taRecord).
    17. Set endIndex to min(endIndex, len).
    18. Let k be startIndex.
    19. Repeat, while k < endIndex,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Perform ! Set(O, Pk, value, true).
      3. Set k to k + 1.
    20. Return O.
    +
    + + +

    23.2.3.10 %TypedArray%.prototype.filter ( callback [ , thisArg ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.filter as defined in 23.1.3.8.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let kept be a new empty List.
    6. Let captured be 0.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let selected be ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), O »)).
      4. If selected is true, then
        1. Append kValue to kept.
        2. Set captured to captured + 1.
      5. Set k to k + 1.
    9. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) », write).
    10. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    11. Let n be 0.
    12. For each element e of kept, do
      1. Perform ! Set(A, ! ToString(𝔽(n)), e, true).
      2. Set n to n + 1.
    13. Return A.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.22 %TypedArray%.prototype.map ( callback [ , thisArg ] )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.map as defined in 23.1.3.21.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let len be TypedArrayLength(taRecord).
    4. If IsCallable(callback) is false, throw a TypeError exception.
    5. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(len) », write).
    6. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    7. Let k be 0.
    8. Repeat, while k < len,
      1. Let Pk be ! ToString(𝔽(k)).
      2. Let kValue be ! Get(O, Pk).
      3. Let mappedValue be ? Call(callback, thisArg, « kValue, 𝔽(k), O »).
      4. Perform ? Set(A, Pk, mappedValue, true).
      5. Set k to k + 1.
    9. Return A.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.25 %TypedArray%.prototype.reverse ( )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse as defined in 23.1.3.26.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst, write).
    3. Let len be TypedArrayLength(taRecord).
    4. Let middle be floor(len / 2).
    5. Let lower be 0.
    6. Repeat, while lowermiddle,
      1. Let upper be len - lower - 1.
      2. Let upperP be ! ToString(𝔽(upper)).
      3. Let lowerP be ! ToString(𝔽(lower)).
      4. Let lowerValue be ! Get(O, lowerP).
      5. Let upperValue be ! Get(O, upperP).
      6. Perform ! Set(O, lowerP, upperValue, true).
      7. Perform ! Set(O, upperP, lowerValue, true).
      8. Set lower to lower + 1.
    7. Return O.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

    +

    This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.

    +

    It performs the following steps when called:

    +
    1. Let target be the this value.
    2. NOTE: The following steps could be simplified by using ? ValidateTypedArray(target, seq-cst, write) and refactoring SetTypedArrayFromTypedArray and SetTypedArrayFromArrayLike to accept the result as input, but that would observably change the calls into user code and thrown error when IsTypedArrayOutOfBounds returns true and offset is negative. Regardless, such a change is still worth pursuing if possible.
    3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]).
    4. Assert: target has a [[ViewedArrayBuffer]] internal slot.
    5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    6. Let targetOffset be ? ToIntegerOrInfinity(offset).
    7. If targetOffset < 0, throw a RangeError exception.
    8. If source is an Object that has a [[TypedArrayName]] internal slot, then
      1. Perform ? SetTypedArrayFromTypedArray(target, targetOffset, source).
    9. Else,
      1. Perform ? SetTypedArrayFromArrayLike(target, targetOffset, source).
    10. Return undefined.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.27 %TypedArray%.prototype.slice ( start, end )

    +

    The interpretation and use of the arguments of this method are the same as for Array.prototype.slice as defined in 23.1.3.28.

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
    3. Let srcArrayLength be TypedArrayLength(taRecord).
    4. Let relativeStart be ? ToIntegerOrInfinity(start).
    5. If relativeStart = -∞, let startIndex be 0.
    6. Else if relativeStart < 0, let startIndex be max(srcArrayLength + relativeStart, 0).
    7. Else, let startIndex be min(relativeStart, srcArrayLength).
    8. If end is undefined, let relativeEnd be srcArrayLength; else let relativeEnd be ? ToIntegerOrInfinity(end).
    9. If relativeEnd = -∞, let endIndex be 0.
    10. Else if relativeEnd < 0, let endIndex be max(srcArrayLength + relativeEnd, 0).
    11. Else, let endIndex be min(relativeEnd, srcArrayLength).
    12. Let countBytes be max(endIndex - startIndex, 0).
    13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(countBytes) », write).
    14. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false.
    15. If countBytes > 0, then
      1. Set taRecord to MakeTypedArrayWithBufferWitnessRecord(O, seq-cst).
      2. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      3. Set endIndex to min(endIndex, TypedArrayLength(taRecord)).
      4. Set countBytes to max(endIndex - startIndex, 0).
      5. Let srcType be TypedArrayElementType(O).
      6. Let targetType be TypedArrayElementType(A).
      7. If srcType is targetType, then
        1. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
        2. Let srcBuffer be O.[[ViewedArrayBuffer]].
        3. Let targetBuffer be A.[[ViewedArrayBuffer]].
        4. Let elementSize be TypedArrayElementSize(O).
        5. Let srcByteOffset be O.[[ByteOffset]].
        6. Let srcByteIndex be (startIndex × elementSize) + srcByteOffset.
        7. Let targetByteIndex be A.[[ByteOffset]].
        8. Let endByteIndex be targetByteIndex + (countBytes × elementSize).
        9. Repeat, while targetByteIndex < endByteIndex,
          1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
          2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
          3. Set srcByteIndex to srcByteIndex + 1.
          4. Set targetByteIndex to targetByteIndex + 1.
      8. Else,
        1. Let n be 0.
        2. Let k be startIndex.
        3. Repeat, while k < endIndex,
          1. Let Pk be ! ToString(𝔽(k)).
          2. Let kValue be ! Get(O, Pk).
          3. Perform ! Set(A, ! ToString(𝔽(n)), kValue, true).
          4. Set k to k + 1.
          5. Set n to n + 1.
    16. Return A.
    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +
    + + +

    23.2.3.29 %TypedArray%.prototype.sort ( comparator )

    +

    This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. The implementation of this method may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.

    +

    This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.

    +

    It performs the following steps when called:

    +
    1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception.
    2. Let obj be the this value.
    3. Let taRecord be ? ValidateTypedArray(obj, seq-cst, write).
    4. Let len be TypedArrayLength(taRecord).
    5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30.
    6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called:
      1. Return ? CompareTypedArrayElements(x, y, comparator).
    7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, read-through-holes).
    8. Let j be 0.
    9. Repeat, while j < len,
      1. Perform ! Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
      2. Set j to j + 1.
    10. Return obj.
    + Note
    +

    Because NaN always compares greater than any other value (see CompareTypedArrayElements), NaN property values always sort to the end of the result when comparator is not provided.

    +
    +
    +
    + + +

    23.2.4 Abstract Operations for TypedArray Objects

    + + +

    23.2.4.1 TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] )

    +

    The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a TypedArray) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function that is derived from exemplar. Unlike ArraySpeciesCreate, which can create non-Array objects through the use of %Symbol.species%, this operation enforces that the constructor function creates an actual TypedArray. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73.
    3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
    4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode).
    5. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots.
    6. Assert: result has all of the internal slots of a TypedArray instance (23.2.8).
    7. If result.[[ContentType]] is not exemplar.[[ContentType]], throw a TypeError exception.
    8. Return result.
    +
    + + +

    23.2.4.2 TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] )

    +

    The abstract operation TypedArrayCreateFromConstructor takes arguments constructor (a constructor) and argumentList (a List of ECMAScript language values) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray or a throw completion. It is used to specify the creation of a new TypedArray using a constructor function. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Let newTypedArray be ? Construct(constructor, argumentList).
    3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode).
    4. If the number of elements in argumentList is 1 and argumentList[0] is a Number, then
      1. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
      2. Let length be TypedArrayLength(taRecord).
      3. If length < (argumentList[0]), throw a TypeError exception.
    5. Return newTypedArray.
    +
    + + +

    23.2.4.4 ValidateTypedArray ( O, order [ , accessMode ] )

    +

    The abstract operation ValidateTypedArray takes arguments O (an ECMAScript language value) and order (seq-cst or unordered) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
    3. Assert: O has a [[ViewedArrayBuffer]] internal slot.
    4. If accessMode is write and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    5. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, order).
    6. If IsTypedArrayOutOfBounds(taRecord) is true, throw a TypeError exception.
    7. Return taRecord.
    +
    +
    +
    +
    + + +

    25 Structured Data

    + + +

    25.1 ArrayBuffer Objects

    + + +

    25.1.3 Abstract Operations For ArrayBuffer Objects

    + + +

    25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )

    +

    The abstract operation AllocateArrayBuffer takes arguments constructor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer, or empty or either empty or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an ArrayBuffer.

    + Editor's Note
    The current name and domain of parameter maxByteLength is preserved for the benefit of diff readability, but both may be subject to change before acceptance into ECMA-262.
    +

    It performs the following steps when called:

    +
    1. Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
    2. If maxByteLength is present and maxByteLength is not empty an integer, let allocatingResizableBuffer be true; otherwise let allocatingResizableBuffer be false.
    3. If allocatingResizableBuffer is true, then
      1. If byteLength > maxByteLength, throw a RangeError exception.
      2. Append [[ArrayBufferMaxByteLength]] to slots.
    4. Else if maxByteLength is immutable, then
      1. Append [[ArrayBufferIsImmutable]] to slots.
    5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots).
    6. Let block be ? CreateByteDataBlock(byteLength).
    7. Set obj.[[ArrayBufferData]] to block.
    8. Set obj.[[ArrayBufferByteLength]] to byteLength.
    9. If allocatingResizableBuffer is true, then
      1. If it is not possible to create a Data Block block consisting of maxByteLength bytes, throw a RangeError exception.
      2. NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
      3. Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
    10. Return obj.
    +
    + + + + +

    25.1.3.2 AllocateImmutableArrayBuffer ( constructor, byteLength, fromBlock, fromIndex, count )

    +

    The abstract operation AllocateImmutableArrayBuffer takes arguments constructor (a constructor), byteLength (a non-negative integer), fromBlock (a Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns either a normal completion containing an ArrayBuffer or a throw completion. It is used to create an immutable ArrayBuffer (i.e., an ArrayBuffer with a an [[ArrayBufferIsImmutable]] slot) with contents from fromBlock. The contents of an immutable ArrayBuffer's Data Block are constrained to be permanently stable, and may not be modified by either ECMAScript code or by other activities inside an implementation or observable by it. It performs the following steps when called:

    +
    1. Assert: constructor is %ArrayBuffer%.
    2. Assert: countbyteLength.
    3. Let newBuffer be ? AllocateArrayBuffer(constructor, byteLength, immutable).
    4. Let toBlock be newBuffer.[[ArrayBufferData]].
    5. NOTE: This is the only step that can write into the Data Block of an immutable ArrayBuffer.
    6. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, fromIndex, count).
    7. Return newBuffer.
    + Note
    +

    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.

    +
    +
    +
    + + +

    25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )

    +

    The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an ECMAScript language value), newLength (an ECMAScript language value), and preserveResizability (preserve-resizability, fixed-length, or immutable) and returns either a normal completion containing an ArrayBuffer or a throw completion.

    + Editor's Note
    The current name of parameter preserveResizability is preserved for the benefit of diff readability, but may be subject to change (to e.g. mode) before acceptance into ECMA-262.
    +

    It performs the following steps when called:

    +
    1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
    2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
    3. If newLength is undefined, then
      1. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
    4. Else,
      1. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception.
    6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
    7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
    8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
    9. If preserveResizability is immutable, then
      1. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength).
    10. Else,
      1. If preserveResizability is preserve-resizability and IsFixedLengthArrayBuffer(arrayBuffer) is false, then
        1. Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
      2. Else,
        1. Let newMaxByteLength be empty.
      3. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception.
      4. Let newBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, newByteLength, newMaxByteLength).
      5. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]).
      6. Let fromBlock be arrayBuffer.[[ArrayBufferData]].
      7. Let toBlock be newBuffer.[[ArrayBufferData]].
      8. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength).
      9. 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.
    11. Perform ! DetachArrayBuffer(arrayBuffer).
    12. Return newBuffer.
    +
    + + + + +

    25.1.3.4 IsImmutableBuffer ( arrayBuffer )

    +

    The abstract operation IsImmutableBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:

    +
    1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true.
    2. Return false.
    +
    +
    + + +

    25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )

    +

    The abstract operation DetachArrayBuffer takes argument arrayBuffer (an ArrayBuffer) and optional argument key (anything) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

    +
    1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
    2. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception.
    3. If key is not present, set key to undefined.
    4. If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a TypeError exception.
    5. Set arrayBuffer.[[ArrayBufferData]] to null.
    6. Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
    7. Return unused.
    + Note
    +

    Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.

    +
    +
    + + +

    25.1.3.18 SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )

    +

    The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:

    +
    1. Assert: IsDetachedBuffer(arrayBuffer) is false.
    2. Assert: IsImmutableBuffer(arrayBuffer) is false.
    3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
    4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
    5. Let block be arrayBuffer.[[ArrayBufferData]].
    6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    7. If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
    9. If IsSharedArrayBuffer(arrayBuffer) is true, then
      1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
      2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
      3. If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false.
      4. Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
    10. Else,
      1. Store the individual bytes of rawBytes into block, starting at block[byteIndex].
    11. Return unused.
    +
    + + +

    25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )

    +

    The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or a SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), and op (a read-modify-write modification function) and returns a Number or a BigInt. It performs the following steps when called:

    +
    1. Assert: IsDetachedBuffer(arrayBuffer) is false.
    2. Assert: IsImmutableBuffer(arrayBuffer) is false.
    3. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.
    4. Assert: value is a BigInt if IsBigIntElementType(type) is true; otherwise, value is a Number.
    5. Let block be arrayBuffer.[[ArrayBufferData]].
    6. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    7. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    8. Let rawBytes be NumericToRawBytes(type, value, isLittleEndian).
    9. If IsSharedArrayBuffer(arrayBuffer) is true, then
      1. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
      2. Let eventsRecord be the Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
      3. Let rawBytesRead be a List of length elementSize whose elements are nondeterministically chosen byte values.
      4. NOTE: In implementations, rawBytesRead is the result of a load-link, of a load-exclusive, or of an operand of a read-modify-write instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency.
      5. Let rmwEvent be ReadModifyWriteSharedMemory { [[Order]]: seq-cst, [[NoTear]]: true, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }.
      6. Append rmwEvent to eventsRecord.[[EventList]].
      7. Append Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
    10. Else,
      1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex].
      2. Let rawBytesModified be op(rawBytesRead, rawBytes).
      3. Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
    11. Return RawBytesToNumeric(type, rawBytesRead, isLittleEndian).
    +
    +
    + + +

    25.1.6 Properties of the ArrayBuffer Prototype Object

    + + + + +

    25.1.6.1 get ArrayBuffer.prototype.immutable

    +

    ArrayBuffer.prototype.immutable is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Return IsImmutableBuffer(O).
    +
    +
    + + +

    25.1.6.6 ArrayBuffer.prototype.resize ( newLength )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. Let newByteLength be ? ToIndex(newLength).
    5. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    6. Assert: IsImmutableBuffer(O) is false.
    7. If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a RangeError exception.
    8. Let hostHandled be ? HostResizeArrayBuffer(O, newByteLength).
    9. If hostHandled is handled, return undefined.
    10. Let oldBlock be O.[[ArrayBufferData]].
    11. Let newBlock be ? CreateByteDataBlock(newByteLength).
    12. Let copyLength be min(newByteLength, O.[[ArrayBufferByteLength]]).
    13. Perform CopyDataBlockBytes(newBlock, 0, oldBlock, 0, copyLength).
    14. NOTE: Neither creation of the new Data Block nor copying from the old Data Block are observable. Implementations may implement this method as in-place growth or shrinkage.
    15. Set O.[[ArrayBufferData]] to newBlock.
    16. Set O.[[ArrayBufferByteLength]] to newByteLength.
    17. Return undefined.
    +
    + + +

    25.1.6.7 ArrayBuffer.prototype.slice ( start, end )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let relativeStart be ? ToIntegerOrInfinity(start).
    7. If relativeStart = -∞, let first be 0.
    8. Else if relativeStart < 0, let first be max(len + relativeStart, 0).
    9. Else, let first be min(relativeStart, len).
    10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
    11. If relativeEnd = -∞, let final be 0.
    12. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
    13. Else, let final be min(relativeEnd, len).
    14. Let bounds be ? ResolveBounds(len, start, end).
    15. Let first be bounds.[[From]].
    16. Let final be bounds.[[To]].
    17. Let newLen be max(final - first, 0).
    18. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
    19. Let new be ? Construct(ctor, « 𝔽(newLen) »).
    20. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
    21. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
    22. If IsDetachedBuffer(new) is true, throw a TypeError exception.
    23. If IsImmutableBuffer(new) is true, throw a TypeError exception.
    24. If SameValue(new, O) is true, throw a TypeError exception.
    25. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception.
    26. NOTE: Side-effects of the above steps may have detached or resized O.
    27. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    28. Let fromBuf be O.[[ArrayBufferData]].
    29. Let toBuf be new.[[ArrayBufferData]].
    30. Let currentLen be O.[[ArrayBufferByteLength]].
    31. If first < currentLen, then
      1. Let count be min(newLen, currentLen - first).
      2. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, count).
    32. Return new.
    +
    + + + + +

    25.1.6.8 ArrayBuffer.prototype.sliceToImmutable ( start, end )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
    3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
    4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    5. Let len be O.[[ArrayBufferByteLength]].
    6. Let bounds be ? ResolveBounds(len, start, end).
    7. Let first be bounds.[[From]].
    8. Let final be bounds.[[To]].
    9. Let newLen be max(final - first, 0).
    10. NOTE: Side-effects of the above steps may have detached or resized O.
    11. If IsDetachedBuffer(O) is true, throw a TypeError exception.
    12. Let fromBuf be O.[[ArrayBufferData]].
    13. Let currentLen be O.[[ArrayBufferByteLength]].
    14. If currentLen < final, throw a RangeError exception.
    15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen).
    16. Return newBuffer.
    +
    +
    + + + + +

    25.1.6.9 ArrayBuffer.prototype.transferToImmutable ( [ newLength ] )

    +

    This method performs the following steps when called:

    +
    1. Let O be the this value.
    2. Return ? ArrayBufferCopyAndDetach(O, newLength, immutable).
    +
    +
    +
    + + +

    25.1.7 Properties of ArrayBuffer Instances

    +

    ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot, an [[ArrayBufferByteLength]] internal slot, and an [[ArrayBufferDetachKey]] internal slot. ArrayBuffer instances which are resizable each have an [[ArrayBufferMaxByteLength]] internal slot, and ArrayBuffer instances which are immutable each have an [[ArrayBufferIsImmutable]] internal slot whose value is always undefined.

    +

    ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.

    +

    ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than undefined need to have all DetachArrayBuffer calls passing that same "detach key" as an argument, otherwise a TypeError will result. This internal slot is only ever set by certain embedding environments, not by algorithms in this specification.

    +
    +
    + + +

    25.3 DataView Objects

    + + +

    25.3.1 Abstract Operations For DataView Objects

    + + +

    25.3.1.6 SetViewValue ( view, requestIndex, isLittleEndian, type, value )

    +

    The abstract operation SetViewValue takes arguments view (an ECMAScript language value), requestIndex (an ECMAScript language value), isLittleEndian (an ECMAScript language value), type (a TypedArray element type), and value (an ECMAScript language value) and returns either a normal completion containing undefined or a throw completion. It is used by functions on DataView instances to store values into the view's buffer. It performs the following steps when called:

    +
    1. Perform ? RequireInternalSlot(view, [[DataView]]).
    2. Assert: view has a [[ViewedArrayBuffer]] internal slot.
    3. If IsImmutableBuffer(view.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
    4. Let getIndex be ? ToIndex(requestIndex).
    5. If IsBigIntElementType(type) is true, let numberValue be ? ToBigInt(value).
    6. Otherwise, let numberValue be ? ToNumber(value).
    7. Set isLittleEndian to ToBoolean(isLittleEndian).
    8. Let viewOffset be view.[[ByteOffset]].
    9. Let viewRecord be MakeDataViewWithBufferWitnessRecord(view, unordered).
    10. NOTE: Bounds checking is not a synchronizing operation when view's backing buffer is a growable SharedArrayBuffer.
    11. If IsViewOutOfBounds(viewRecord) is true, throw a TypeError exception.
    12. Let viewSize be GetViewByteLength(viewRecord).
    13. Let elementSize be the Element Size value specified in Table 73 for Element Type type.
    14. If getIndex + elementSize > viewSize, throw a RangeError exception.
    15. Let bufferIndex be getIndex + viewOffset.
    16. Perform SetValueInBuffer(view.[[ViewedArrayBuffer]], bufferIndex, type, numberValue, false, unordered, isLittleEndian).
    17. Return undefined.
    +
    +
    +
    + + +

    25.4 The Atomics Object

    + + +

    25.4.3 Abstract Operations for Atomics

    + + +

    25.4.3.1 ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] )

    +

    The abstract operation ValidateIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and waitable (a Boolean) and optional argument accessMode (read or write) and returns either a normal completion containing a TypedArray With Buffer Witness Record, or a throw completion. It performs the following steps when called:

    +
    1. If accessMode is not present, set accessMode to read.
    2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode).
    3. NOTE: Bounds checking is not a synchronizing operation when typedArray's backing buffer is a growable SharedArrayBuffer.
    4. If waitable is true, then
      1. If typedArray.[[TypedArrayName]] is neither "Int32Array" nor "BigInt64Array", throw a TypeError exception.
    5. Else,
      1. Let type be TypedArrayElementType(typedArray).
      2. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception.
    6. Return taRecord.
    +
    + + +

    25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] )

    +

    The abstract operation ValidateAtomicAccessOnIntegerTypedArray takes arguments typedArray (an ECMAScript language value) and requestIndex (an ECMAScript language value) and optional arguments waitable (a Boolean) and accessMode (read or write) and returns either a normal completion containing an integer or a throw completion. It performs the following steps when called:

    +
    1. If waitable is not present, set waitable to false.
    2. If accessMode is not present, set accessMode to read.
    3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode).
    4. Return ? ValidateAtomicAccess(taRecord, requestIndex).
    +
    + + +

    25.4.3.17 AtomicReadModifyWrite ( typedArray, index, value, op )

    +

    The abstract operation AtomicReadModifyWrite takes arguments typedArray (an ECMAScript language value), index (an ECMAScript language value), value (an ECMAScript language value), and op (a read-modify-write modification function) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. op takes two List of byte values arguments and returns a List of byte values. This operation atomically loads a value, combines it with another value, and stores the combination. It returns the loaded value. It performs the following steps when called:

    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Return GetModifySetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, op).
    +
    +
    + + +

    25.4.6 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )

    +

    This function performs the following steps when called:

    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. Let buffer be typedArray.[[ViewedArrayBuffer]].
    3. Let block be buffer.[[ArrayBufferData]].
    4. If typedArray.[[ContentType]] is bigint, then
      1. Let expected be ? ToBigInt(expectedValue).
      2. Let replacement be ? ToBigInt(replacementValue).
    5. Else,
      1. Let expected be 𝔽(? ToIntegerOrInfinity(expectedValue)).
      2. Let replacement be 𝔽(? ToIntegerOrInfinity(replacementValue)).
    6. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    7. Let elementType be TypedArrayElementType(typedArray).
    8. Let elementSize be TypedArrayElementSize(typedArray).
    9. Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
    10. Let expectedBytes be NumericToRawBytes(elementType, expected, isLittleEndian).
    11. Let replacementBytes be NumericToRawBytes(elementType, replacement, isLittleEndian).
    12. If IsSharedArrayBuffer(buffer) is true, then
      1. Let rawBytesRead be AtomicCompareExchangeInSharedBlock(block, byteIndexInBuffer, elementSize, expectedBytes, replacementBytes).
    13. Else,
      1. Let rawBytesRead be a List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndexInBuffer].
      2. If ByteListEqual(rawBytesRead, expectedBytes) is true, then
        1. Store the individual bytes of replacementBytes into block, starting at block[byteIndexInBuffer].
    14. Return RawBytesToNumeric(elementType, rawBytesRead, isLittleEndian).
    +
    + + +

    25.4.11 Atomics.store ( typedArray, index, value )

    +

    This function performs the following steps when called:

    +
    1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, write).
    2. If typedArray.[[ContentType]] is bigint, let v be ? ToBigInt(value).
    3. Otherwise, let v be 𝔽(? ToIntegerOrInfinity(value)).
    4. Perform ? RevalidateAtomicAccess(typedArray, byteIndexInBuffer).
    5. Let buffer be typedArray.[[ViewedArrayBuffer]].
    6. Let elementType be TypedArrayElementType(typedArray).
    7. Perform SetValueInBuffer(buffer, byteIndexInBuffer, elementType, v, true, seq-cst).
    8. Return v.
    +
    +
    +
    +

    Copyright & Software License

    + + +

    Software License

    +

    All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

    + +

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    + +
      +
    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    2. +
    3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    4. +
    5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
    6. +
    + +

    THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    + +
    +
    \ No newline at end of file From 5c32b5f6e28958c2ed579c484d696bc606f66861 Mon Sep 17 00:00:00 2001 From: gibson042 Date: Sat, 20 Sep 2025 18:23:39 +0000 Subject: [PATCH 95/95] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc?= =?UTF-8?q?39/proposal-immutable-arraybuffer@1b01ac2ff172d21751364b778bd45?= =?UTF-8?q?fcaeecc7bcf=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/index.html b/index.html index bc3219b..cb6da5c 100644 --- a/index.html +++ b/index.html @@ -870,7 +870,7 @@ this.$pane.appendChild(this.$tableContainer); if (menu != null) { - menu.$specContainer.after(this.$container); + menu.$specContainer.appendChild(this.$container); } }, @@ -1202,9 +1202,6 @@ document.documentElement.classList.toggle('show-ao-annotations'); } else if (e.key === '?') { document.getElementById('shortcuts-help').classList.toggle('active'); - } else if (e.key === ';') { - let el = document.getElementById('bd75b99add5f'); - if (el != null) el.remove(); } } @@ -2252,7 +2249,7 @@ } emu-nt { - display: inline-block; + display: inline; font-style: italic; white-space: nowrap; text-indent: 0; @@ -2592,7 +2589,7 @@ } emu-table td { - background: transparent; + background: var(--background-color); } td[colspan]:not([colspan="1"]), th[colspan]:not([colspan="1"]) { @@ -2699,7 +2696,7 @@ height: 100vh; max-width: 500px; box-sizing: border-box; - background: var(--control-background-color); + background-color: var(--control-background-color); overflow: hidden; transition: opacity 0.1s linear; padding: 0 5px; @@ -3140,7 +3137,7 @@ .toolbox::after { border-color: var(--toolbox-tail-background-outside-color); - border-top-color: var(--control-border-color); + border-top-color: var(--control-background-color); border-width: 10px; margin-left: -10px; } @@ -3157,7 +3154,7 @@ left: 0; right: 0; display: none; - background: var(--control-background-color); + background-color: var(--control-background-color); z-index: 1; } @@ -3198,17 +3195,6 @@ padding-right: 5px; } -emu-normative-optional { - display: block; -} - -emu-normative-optional::before { - display: block; - color: var(--attributes-tag-foreground-color); - content: "NORMATIVE OPTIONAL"; -} - -emu-normative-optional, [normative-optional], [deprecated], [legacy] { @@ -3241,7 +3227,7 @@ outline: solid 10000px var(--control-dialog-fade-color); border-radius: 5px; border-width: 1px 1px 0 1px; - background: var(--control-background-color); + background-color: var(--control-background-color); display: none; } @@ -3547,18 +3533,6 @@ break-after: initial; /* it's okay to break after the last item in a list, even if it's also the first item in the list */ } -emu-normative-optional { - break-inside: avoid; -} - -emu-normative-optional emu-clause[id] { - margin-top: 0; -} - -emu-normative-optional emu-alg > ol { - margin-bottom: 0; -} - emu-note { gap: initial; justify-content: space-between; @@ -3990,7 +3964,7 @@

    Proposal proposal-immutable-arraybuffer

    Stage 2 Draft / July 28, 2025

    Immutable ArrayBuffers

    +

    Proposal proposal-immutable-arraybuffer

    Stage 2.7 Draft / September 20, 2025

    Immutable ArrayBuffers

    6 ECMAScript Data Types and Values