notify-with-no-matching-agents-waiting.js (1175B)
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. 4 5 /*--- 6 esid: sec-atomics.notify 7 description: > 8 Test that Atomics.notify notifies zero waiters if there are no waiters 9 at the index specified. 10 includes: [atomicsHelper.js] 11 features: [Atomics, SharedArrayBuffer, TypedArray] 12 ---*/ 13 14 const RUNNING = 0; 15 16 $262.agent.start(` 17 $262.agent.receiveBroadcast(function(sab) { 18 const i32a = new Int32Array(sab); 19 Atomics.add(i32a, ${RUNNING}, 1); 20 $262.agent.leaving(); 21 }); 22 `); 23 24 const i32a = new Int32Array( 25 new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2) 26 ); 27 28 $262.agent.safeBroadcast(i32a); 29 $262.agent.waitUntil(i32a, RUNNING, 1); 30 31 // There are ZERO matching agents waiting on index 1 32 assert.sameValue(Atomics.notify(i32a, 1, 1), 0, 'Atomics.notify(i32a, 1, 1) returns 0'); 33 34 reportCompare(0, 0);