notify-with-no-agents-waiting.js (1179B)
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 agents waiting. 9 includes: [atomicsHelper.js] 10 features: [Atomics, SharedArrayBuffer, TypedArray] 11 ---*/ 12 13 const RUNNING = 1; 14 15 $262.agent.start(` 16 $262.agent.receiveBroadcast(function(sab) { 17 const i32a = new Int32Array(sab); 18 Atomics.add(i32a, ${RUNNING}, 1); 19 // THIS WILL NEVER WAIT. 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 agents waiting to notify... 32 assert.sameValue(Atomics.notify(i32a, 0, 1), 0, 'Atomics.notify(i32a, 0, 1) returns 0'); 33 34 reportCompare(0, 0);