1 // |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics
2 // Copyright (C) 2018 Rick Waldron. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
8 Atomics.and returns the value that existed at the
9 index prior to the operation.
11 Atomics.sub( typedArray, index, value )
13 1. Return ? AtomicReadModifyWrite(typedArray, index, value, subtract).
15 AtomicReadModifyWrite( typedArray, index, value, op )
18 9. Return GetModifySetValueInBuffer(buffer, indexedPosition,
22 GetModifySetValueInBuffer( arrayBuffer,
23 byteIndex, type, value, op [ , isLittleEndian ] )
26 16. Return RawBytesToNumber(type, rawBytesRead, isLittleEndian).
28 features: [Atomics, SharedArrayBuffer, TypedArray]
31 const i32a = new Int32Array(
32 new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
34 const update = 0b00000001000000001000000010000001;
39 Atomics.sub(i32a, 0, update),
41 'Atomics.sub(i32a, 0, update) returns the value of `update` (0b00000001000000001000000010000001)'
43 assert.sameValue(i32a[0], 0, 'The value of i32a[0] is 0');