notify-renotify-noop.js (1498B)
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 on awoken waiter is a noop. 9 includes: [atomicsHelper.js] 10 features: [Atomics, SharedArrayBuffer, TypedArray] 11 ---*/ 12 13 const RUNNING = 1; 14 const TIMEOUT = $262.agent.timeouts.long; 15 16 $262.agent.start(` 17 $262.agent.receiveBroadcast(function(sab) { 18 const i32a = new Int32Array(sab); 19 Atomics.add(i32a, ${RUNNING}, 1); 20 21 $262.agent.report(Atomics.wait(i32a, 0, 0, ${TIMEOUT})); 22 $262.agent.leaving(); 23 }); 24 `); 25 26 const i32a = new Int32Array( 27 new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2) 28 ); 29 30 $262.agent.safeBroadcast(i32a); 31 32 $262.agent.waitUntil(i32a, RUNNING, 1); 33 34 // Try to yield control to ensure the agent actually started to wait. 35 $262.agent.tryYield(); 36 37 assert.sameValue(Atomics.notify(i32a, 0, 1), 1, 'Atomics.notify(i32a, 0, 1) returns 1'); 38 39 assert.sameValue($262.agent.getReport(), 'ok', '$262.agent.getReport() returns "ok"'); 40 41 // Already notified, this should be a noop 42 assert.sameValue(Atomics.notify(i32a, 0, 1), 0, 'Atomics.notify(i32a, 0, 1) returns 0'); 43 44 reportCompare(0, 0);