25.1 ArrayBuffer Objects
25.1.1 Notation
The descriptions below in this section,
A read-modify-write modification function is a mathematical function that is notationally represented as an abstract closure that takes two
- They perform all their algorithm steps atomically.
- Their individual algorithm steps are not observable.
To aid verifying that a read-modify-write modification function's algorithm steps constitute a pure, mathematical function, the following editorial conventions are recommended:
- They do not access, directly or transitively via invoked
abstract operations and abstract closures, any language or specification values except their parameters and captured values. - They do not return
Completion Records .
25.1.2 Fixed-length and Resizable ArrayBuffer Objects
A fixed-length ArrayBuffer is an ArrayBuffer whose byte length cannot change after creation.
A resizable ArrayBuffer is an ArrayBuffer whose byte length may change after creation via calls to
The kind of ArrayBuffer object that is created depends on the arguments passed to
25.1.3 Abstract Operations For ArrayBuffer Objects
25.1.3.1 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )
The abstract operation AllocateArrayBuffer takes arguments constructor (a
- Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
- If maxByteLength is present and maxByteLength is not
empty , let allocatingResizableBuffer betrue ; otherwise let allocatingResizableBuffer befalse . - If allocatingResizableBuffer is
true , then- If byteLength > maxByteLength, throw a
RangeError exception. - Append [[ArrayBufferMaxByteLength]] to slots.
- If byteLength > maxByteLength, throw a
- Let obj be ?
OrdinaryCreateFromConstructor (constructor,"%ArrayBuffer.prototype%" , slots). - Let block be ?
CreateByteDataBlock (byteLength). - Set obj.[[ArrayBufferData]] to block.
- Set obj.[[ArrayBufferByteLength]] to byteLength.
- If allocatingResizableBuffer is
true , then- If it is not possible to create a
Data Block block consisting of maxByteLength bytes, throw aRangeError exception. - 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.
- Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
- If it is not possible to create a
- Return obj.
25.1.3.2 ArrayBufferByteLength ( arrayBuffer, order )
The abstract operation ArrayBufferByteLength takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer) and order (
- If
IsSharedArrayBuffer (arrayBuffer) istrue and arrayBuffer has an [[ArrayBufferByteLengthData]] internal slot, then- Let bufferByteLengthBlock be arrayBuffer.[[ArrayBufferByteLengthData]].
- Let rawLength be
GetRawBytesFromSharedBlock (bufferByteLengthBlock, 0,biguint64 ,true , order). - Let isLittleEndian be the value of the [[LittleEndian]] field of the
surrounding agent 'sAgent Record . - Return
ℝ (RawBytesToNumeric (biguint64 , rawLength, isLittleEndian)).
Assert :IsDetachedBuffer (arrayBuffer) isfalse .- Return arrayBuffer.[[ArrayBufferByteLength]].
25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability )
The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (an
- Perform ?
RequireInternalSlot (arrayBuffer, [[ArrayBufferData]]). - If
IsSharedArrayBuffer (arrayBuffer) istrue , throw aTypeError exception. - If newLength is
undefined , then- Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]].
- Else,
- Let newByteLength be ?
ToIndex (newLength).
- Let newByteLength be ?
- If
IsDetachedBuffer (arrayBuffer) istrue , throw aTypeError exception. - If preserveResizability is
preserve-resizability andIsFixedLengthArrayBuffer (arrayBuffer) isfalse , then- Let newMaxByteLength be arrayBuffer.[[ArrayBufferMaxByteLength]].
- Else,
- Let newMaxByteLength be
empty .
- Let newMaxByteLength be
- If arrayBuffer.[[ArrayBufferDetachKey]] is not
undefined , throw aTypeError exception. - Let newBuffer be ?
AllocateArrayBuffer (%ArrayBuffer% , newByteLength, newMaxByteLength). - Let copyLength be
min (newByteLength, arrayBuffer.[[ArrayBufferByteLength]]). - Let fromBlock be arrayBuffer.[[ArrayBufferData]].
- Let toBlock be newBuffer.[[ArrayBufferData]].
- Perform
CopyDataBlockBytes (toBlock, 0, fromBlock, 0, copyLength). - NOTE: Neither creation of the new
Data Block nor copying from the oldData Block are observable. Implementations may implement this method as a zero-copy move or arealloc
. - Perform !
DetachArrayBuffer (arrayBuffer). - Return newBuffer.
25.1.3.4 IsDetachedBuffer ( arrayBuffer )
The abstract operation IsDetachedBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:
- If arrayBuffer.[[ArrayBufferData]] is
null , returntrue . - 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
Assert :IsSharedArrayBuffer (arrayBuffer) isfalse .- If key is not present, set key to
undefined . - If arrayBuffer.[[ArrayBufferDetachKey]] is not key, throw a
TypeError exception. - Set arrayBuffer.[[ArrayBufferData]] to
null . - Set arrayBuffer.[[ArrayBufferByteLength]] to 0.
- Return
unused .
Detaching an ArrayBuffer instance disassociates the
25.1.3.6 CloneArrayBuffer ( srcBuffer, srcByteOffset, srcLength )
The abstract operation CloneArrayBuffer takes arguments srcBuffer (an ArrayBuffer or a SharedArrayBuffer), srcByteOffset (a non-negative
Assert :IsDetachedBuffer (srcBuffer) isfalse .- Let targetBuffer be ?
AllocateArrayBuffer (%ArrayBuffer% , srcLength). - Let srcBlock be srcBuffer.[[ArrayBufferData]].
- Let targetBlock be targetBuffer.[[ArrayBufferData]].
- Perform
CopyDataBlockBytes (targetBlock, 0, srcBlock, srcByteOffset, srcLength). - Return targetBuffer.
25.1.3.7 GetArrayBufferMaxByteLengthOption ( options )
The abstract operation GetArrayBufferMaxByteLengthOption takes argument options (an
- If options
is not an Object , returnempty . - Let maxByteLength be ?
Get (options,"maxByteLength" ). - If maxByteLength is
undefined , returnempty . - Return ?
ToIndex (maxByteLength).
25.1.3.8 HostResizeArrayBuffer ( buffer, newByteLength )
The
The implementation of HostResizeArrayBuffer must conform to the following requirements:
- The abstract operation does not detach buffer.
- If the abstract operation completes normally with
handled , buffer.[[ArrayBufferByteLength]] is newByteLength.
The default implementation of HostResizeArrayBuffer is to return
25.1.3.9 IsFixedLengthArrayBuffer ( arrayBuffer )
The abstract operation IsFixedLengthArrayBuffer takes argument arrayBuffer (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. It performs the following steps when called:
- If arrayBuffer has an [[ArrayBufferMaxByteLength]] internal slot, return
false . - Return
true .
25.1.3.10 IsUnsignedElementType ( type )
The abstract operation IsUnsignedElementType takes argument type (a
- If type is one of
uint8 ,uint8clamped ,uint16 ,uint32 , orbiguint64 , returntrue . - Return
false .
25.1.3.11 IsUnclampedIntegerElementType ( type )
The abstract operation IsUnclampedIntegerElementType takes argument type (a
- If type is one of
int8 ,uint8 ,int16 ,uint16 ,int32 , oruint32 , returntrue . - Return
false .
25.1.3.12 IsBigIntElementType ( type )
The abstract operation IsBigIntElementType takes argument type (a
- If type is either
biguint64 orbigint64 , returntrue . - Return
false .
25.1.3.13 IsNoTearConfiguration ( type, order )
The abstract operation IsNoTearConfiguration takes arguments type (a
- If
IsUnclampedIntegerElementType (type) istrue , returntrue . - If
IsBigIntElementType (type) istrue and order is neitherinit norunordered , returntrue . - Return
false .
25.1.3.14 RawBytesToNumeric ( type, rawBytes, isLittleEndian )
The abstract operation RawBytesToNumeric takes arguments type (a
- Let elementSize be the Element Size value specified in
Table 71 for Element Type type. - If isLittleEndian is
false , reverse the order of the elements of rawBytes. - If type is
float32 , then- Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an
IEEE 754-2019 binary32 value. - If value is an
IEEE 754-2019 binary32 NaN value, return theNaN Number value. - Return the Number value that corresponds to value.
- Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an
- If type is
float64 , then- Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an
IEEE 754-2019 binary64 value. - If value is an
IEEE 754-2019 binary64 NaN value, return theNaN Number value. - Return the Number value that corresponds to value.
- Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an
- If
IsUnsignedElementType (type) istrue , then- Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of an unsigned little-endian binary number.
- Else,
- Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of a binary little-endian two's complement number of bit length elementSize × 8.
- If
IsBigIntElementType (type) istrue , return the BigInt value that corresponds to intValue. - Otherwise, return the Number value that corresponds to intValue.
25.1.3.15 GetRawBytesFromSharedBlock ( block, byteIndex, type, isTypedArray, order )
The abstract operation GetRawBytesFromSharedBlock takes arguments block (a
- Let elementSize be the Element Size value specified in
Table 71 for Element Type type. - Let execution be the [[CandidateExecution]] field of the
surrounding agent 'sAgent Record . - Let eventsRecord be the
Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] isAgentSignifier (). - If isTypedArray is
true andIsNoTearConfiguration (type, order) istrue , let noTear betrue ; otherwise let noTear befalse . - Let rawValue be a
List of length elementSize whose elements are nondeterministically chosenbyte values . - NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the
memory model to describe observable behaviour of hardware with weak consistency. - Let readEvent be
ReadSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. - Append readEvent to eventsRecord.[[EventList]].
- Append
Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. - Return rawValue.
25.1.3.16 GetValueFromBuffer ( arrayBuffer, byteIndex, type, isTypedArray, order [ , isLittleEndian ] )
The abstract operation GetValueFromBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative
Assert :IsDetachedBuffer (arrayBuffer) isfalse .Assert : There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.- Let block be arrayBuffer.[[ArrayBufferData]].
- Let elementSize be the Element Size value specified in
Table 71 for Element Type type. - If
IsSharedArrayBuffer (arrayBuffer) istrue , thenAssert : block is aShared Data Block .- Let rawValue be
GetRawBytesFromSharedBlock (block, byteIndex, type, isTypedArray, order).
- Else,
Assert : The number of elements in rawValue is elementSize.- If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the
surrounding agent 'sAgent Record . - Return
RawBytesToNumeric (type, rawValue, isLittleEndian).
25.1.3.17 NumericToRawBytes ( type, value, isLittleEndian )
The abstract operation NumericToRawBytes takes arguments type (a
- If type is
float32 , then- Let rawBytes be a
List whose elements are the 4 bytes that are the result of converting value toIEEE 754-2019 binary32 format using roundTiesToEven mode. The bytes are arranged in little endian order. If value isNaN , rawBytes may be set to any implementation chosenIEEE 754-2019 binary32 format Not-a-Number encoding. An implementation must always choose the same encoding for each implementation distinguishableNaN value.
- Let rawBytes be a
- Else if type is
float64 , then- Let rawBytes be a
List whose elements are the 8 bytes that are theIEEE 754-2019 binary64 format encoding of value. The bytes are arranged in little endian order. If value isNaN , rawBytes may be set to any implementation chosenIEEE 754-2019 binary64 format Not-a-Number encoding. An implementation must always choose the same encoding for each implementation distinguishableNaN value.
- Let rawBytes be a
- Else,
- Let n be the Element Size value specified in
Table 71 for Element Type type. - Let convOp be the abstract operation named in the Conversion Operation column in
Table 71 for Element Type type. - Let intValue be
ℝ (convOp(value)). - If intValue ≥ 0, then
- Let rawBytes be a
List whose elements are the n-byte binary encoding of intValue. The bytes are ordered in little endian order.
- Let rawBytes be a
- Else,
- Let rawBytes be a
List whose elements are the n-byte binary two's complement encoding of intValue. The bytes are ordered in little endian order.
- Let rawBytes be a
- Let n be the Element Size value specified in
- If isLittleEndian is
false , reverse the order of the elements of rawBytes. - Return rawBytes.
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
Assert :IsDetachedBuffer (arrayBuffer) isfalse .Assert : There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.Assert : valueis a BigInt ifIsBigIntElementType (type) istrue ; otherwise, valueis a Number .- Let block be arrayBuffer.[[ArrayBufferData]].
- Let elementSize be the Element Size value specified in
Table 71 for Element Type type. - If isLittleEndian is not present, set isLittleEndian to the value of the [[LittleEndian]] field of the
surrounding agent 'sAgent Record . - Let rawBytes be
NumericToRawBytes (type, value, isLittleEndian). - If
IsSharedArrayBuffer (arrayBuffer) istrue , then- Let execution be the [[CandidateExecution]] field of the
surrounding agent 'sAgent Record . - Let eventsRecord be the
Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] isAgentSignifier (). - If isTypedArray is
true andIsNoTearConfiguration (type, order) istrue , let noTear betrue ; otherwise let noTear befalse . - Append
WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventsRecord.[[EventList]].
- Let execution be the [[CandidateExecution]] field of the
- Else,
- Store the individual bytes of rawBytes into block, starting at block[byteIndex].
- 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
Assert :IsDetachedBuffer (arrayBuffer) isfalse .Assert : There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type.Assert : valueis a BigInt ifIsBigIntElementType (type) istrue ; otherwise, valueis a Number .- Let block be arrayBuffer.[[ArrayBufferData]].
- Let elementSize be the Element Size value specified in
Table 71 for Element Type type. - Let isLittleEndian be the value of the [[LittleEndian]] field of the
surrounding agent 'sAgent Record . - Let rawBytes be
NumericToRawBytes (type, value, isLittleEndian). - If
IsSharedArrayBuffer (arrayBuffer) istrue , then- Let execution be the [[CandidateExecution]] field of the
surrounding agent 'sAgent Record . - Let eventsRecord be the
Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] isAgentSignifier (). - Let rawBytesRead be a
List of length elementSize whose elements are nondeterministically chosenbyte values . - 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. - Let rmwEvent be
ReadModifyWriteSharedMemory { [[Order]]:seq-cst , [[NoTear]]:true , [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes, [[ModifyOp]]: op }. - Append rmwEvent to eventsRecord.[[EventList]].
- Append
Chosen Value Record { [[Event]]: rmwEvent, [[ChosenValue]]: rawBytesRead } to execution.[[ChosenValues]].
- Let execution be the [[CandidateExecution]] field of the
- Else,
- Let rawBytesRead be a
List of length elementSize whose elements are the sequence of elementSize bytes starting with block[byteIndex]. - Let rawBytesModified be op(rawBytesRead, rawBytes).
- Store the individual bytes of rawBytesModified into block, starting at block[byteIndex].
- Let rawBytesRead be a
- Return
RawBytesToNumeric (type, rawBytesRead, isLittleEndian).
25.1.4 The ArrayBuffer Constructor
The ArrayBuffer
- is %ArrayBuffer%.
- is the initial value of the
"ArrayBuffer" property of theglobal object . - creates and initializes a new ArrayBuffer when called as a
constructor . - is not intended to be called as a function and will throw an exception when called in that manner.
- may be used as the value of an
extends
clause of a class definition. Subclassconstructors that intend to inherit the specified ArrayBuffer behaviour must include asuper
call to the ArrayBufferconstructor to create and initialize subclass instances with the internal state necessary to support theArrayBuffer.prototype
built-in methods.
25.1.4.1 ArrayBuffer ( length [ , options ] )
This function performs the following steps when called:
- If NewTarget is
undefined , throw aTypeError exception. - Let byteLength be ?
ToIndex (length). - Let requestedMaxByteLength be ?
GetArrayBufferMaxByteLengthOption (options). - Return ?
AllocateArrayBuffer (NewTarget, byteLength, requestedMaxByteLength).
25.1.5 Properties of the ArrayBuffer Constructor
The ArrayBuffer
- has a [[Prototype]] internal slot whose value is
%Function.prototype% . - has the following properties:
25.1.5.1 ArrayBuffer.isView ( arg )
This function performs the following steps when called:
- If arg
is not an Object , returnfalse . - If arg has a [[ViewedArrayBuffer]] internal slot, return
true . - Return
false .
25.1.5.2 ArrayBuffer.prototype
The initial value of ArrayBuffer.prototype
is the
This property has the attributes { [[Writable]]:
25.1.5.3 get ArrayBuffer [ @@species ]
ArrayBuffer[@@species]
is an
- Return the
this value.
The value of the
25.1.6 Properties of the ArrayBuffer Prototype Object
The ArrayBuffer prototype object:
- is %ArrayBuffer.prototype%.
- has a [[Prototype]] internal slot whose value is
%Object.prototype% . - is an
ordinary object . - does not have an [[ArrayBufferData]] or [[ArrayBufferByteLength]] internal slot.
25.1.6.1 get ArrayBuffer.prototype.byteLength
ArrayBuffer.prototype.byteLength
is an
- Let O be the
this value. - Perform ?
RequireInternalSlot (O, [[ArrayBufferData]]). - If
IsSharedArrayBuffer (O) istrue , throw aTypeError exception. - If
IsDetachedBuffer (O) istrue , return+0 𝔽. - Let length be O.[[ArrayBufferByteLength]].
- Return
𝔽 (length).
25.1.6.2 ArrayBuffer.prototype.constructor
The initial value of ArrayBuffer.prototype.constructor
is
25.1.6.3 get ArrayBuffer.prototype.detached
ArrayBuffer.prototype.detached
is an
- Let O be the
this value. - Perform ?
RequireInternalSlot (O, [[ArrayBufferData]]). - If
IsSharedArrayBuffer (O) istrue , throw aTypeError exception. - Return
IsDetachedBuffer (O).
25.1.6.4 get ArrayBuffer.prototype.maxByteLength
ArrayBuffer.prototype.maxByteLength
is an
- Let O be the
this value. - Perform ?
RequireInternalSlot (O, [[ArrayBufferData]]). - If
IsSharedArrayBuffer (O) istrue , throw aTypeError exception. - If
IsDetachedBuffer (O) istrue , return+0 𝔽. - If
IsFixedLengthArrayBuffer (O) istrue , then- Let length be O.[[ArrayBufferByteLength]].
- Else,
- Let length be O.[[ArrayBufferMaxByteLength]].
- Return
𝔽 (length).
25.1.6.5 get ArrayBuffer.prototype.resizable
ArrayBuffer.prototype.resizable
is an
- Let O be the
this value. - Perform ?
RequireInternalSlot (O, [[ArrayBufferData]]). - If
IsSharedArrayBuffer (O) istrue , throw aTypeError exception. - If
IsFixedLengthArrayBuffer (O) isfalse , returntrue ; otherwise returnfalse .
25.1.6.6 ArrayBuffer.prototype.resize ( newLength )
This method performs the following steps when called:
- Let O be the
this value. - Perform ?
RequireInternalSlot (O, [[ArrayBufferMaxByteLength]]). - If
IsSharedArrayBuffer (O) istrue , throw aTypeError exception. - Let newByteLength be ?
ToIndex (newLength). - If
IsDetachedBuffer (O) istrue , throw aTypeError exception. - If newByteLength > O.[[ArrayBufferMaxByteLength]], throw a
RangeError exception. - Let hostHandled be ?
HostResizeArrayBuffer (O, newByteLength). - If hostHandled is
handled , returnundefined . - Let oldBlock be O.[[ArrayBufferData]].
- Let newBlock be ?
CreateByteDataBlock (newByteLength). - Let copyLength be
min (newByteLength, O.[[ArrayBufferByteLength]]). - Perform
CopyDataBlockBytes (newBlock, 0, oldBlock, 0, copyLength). - NOTE: Neither creation of the new
Data Block nor copying from the oldData Block are observable. Implementations may implement this method as in-place growth or shrinkage. - Set O.[[ArrayBufferData]] to newBlock.
- Set O.[[ArrayBufferByteLength]] to newByteLength.
- Return
undefined .
25.1.6.7 ArrayBuffer.prototype.slice ( start, end )
This method performs the following steps when called:
- Let O be the
this value. - Perform ?
RequireInternalSlot (O, [[ArrayBufferData]]). - If
IsSharedArrayBuffer (O) istrue , throw aTypeError exception. - If
IsDetachedBuffer (O) istrue , throw aTypeError exception. - Let len be O.[[ArrayBufferByteLength]].
- Let relativeStart be ?
ToIntegerOrInfinity (start). - If relativeStart = -∞, let first be 0.
- Else if relativeStart < 0, let first be
max (len + relativeStart, 0). - Else, let first be
min (relativeStart, len). - If end is
undefined , let relativeEnd be len; else let relativeEnd be ?ToIntegerOrInfinity (end). - If relativeEnd = -∞, let final be 0.
- Else if relativeEnd < 0, let final be
max (len + relativeEnd, 0). - Else, let final be
min (relativeEnd, len). - Let newLen be
max (final - first, 0). - Let ctor be ?
SpeciesConstructor (O,%ArrayBuffer% ). - Let new be ?
Construct (ctor, «𝔽 (newLen) »). - Perform ?
RequireInternalSlot (new, [[ArrayBufferData]]). - If
IsSharedArrayBuffer (new) istrue , throw aTypeError exception. - If
IsDetachedBuffer (new) istrue , throw aTypeError exception. - If
SameValue (new, O) istrue , throw aTypeError exception. - If new.[[ArrayBufferByteLength]] < newLen, throw a
TypeError exception. - NOTE: Side-effects of the above steps may have detached or resized O.
- If
IsDetachedBuffer (O) istrue , throw aTypeError exception. - Let fromBuf be O.[[ArrayBufferData]].
- Let toBuf be new.[[ArrayBufferData]].
- Let currentLen be O.[[ArrayBufferByteLength]].
- If first < currentLen, then
- Let count be
min (newLen, currentLen - first). - Perform
CopyDataBlockBytes (toBuf, 0, fromBuf, first, count).
- Let count be
- Return new.
25.1.6.8 ArrayBuffer.prototype.transfer ( [ newLength ] )
This method performs the following steps when called:
- Let O be the
this value. - Return ?
ArrayBufferCopyAndDetach (O, newLength,preserve-resizability ).
25.1.6.9 ArrayBuffer.prototype.transferToFixedLength ( [ newLength ] )
This method performs the following steps when called:
- Let O be the
this value. - Return ?
ArrayBufferCopyAndDetach (O, newLength,fixed-length ).
25.1.6.10 ArrayBuffer.prototype [ @@toStringTag ]
The initial value of the
This property has the attributes { [[Writable]]:
25.1.7 Properties of ArrayBuffer Instances
ArrayBuffer instances inherit properties from the
ArrayBuffer instances whose [[ArrayBufferData]] is
ArrayBuffer instances whose [[ArrayBufferDetachKey]] is set to a value other than
25.1.8 Resizable ArrayBuffer Guidelines
The following are guidelines for ECMAScript programmers working with
We recommend that programs be tested in their deployment environments where possible. The amount of available physical memory differs greatly between hardware devices. Similarly, virtual memory subsystems also differ greatly between hardware devices as well as operating systems. An application that runs without out-of-memory errors on a 64-bit desktop web browser could run out of memory on a 32-bit mobile web browser.
When choosing a value for the
Please note that successfully constructing a
The following are guidelines for ECMAScript implementers implementing
If a
If a