2018-03-13 22:22:10 +01:00
|
|
|
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
|
|
esid: sec-atomics.wait
|
2018-03-20 00:50:28 +01:00
|
|
|
description: >
|
2018-03-13 22:22:10 +01:00
|
|
|
An undefined index arg should translate to 0
|
|
|
|
info: |
|
|
|
|
Atomics.wait( typedArray, index, value, timeout )
|
|
|
|
|
|
|
|
2.Let i be ? ValidateAtomicAccess(typedArray, index).
|
|
|
|
...
|
|
|
|
2.Let accessIndex be ? ToIndex(requestIndex).
|
|
|
|
|
|
|
|
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
|
|
|
|
...
|
|
|
|
3.If bufferData is a Data Block, return false
|
|
|
|
|
|
|
|
If value is undefined, then
|
|
|
|
Let index be 0.
|
2018-05-21 20:23:15 +02:00
|
|
|
|
|
|
|
includes: [atomicsHelper.js]
|
2018-04-19 16:11:50 +02:00
|
|
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
2018-03-13 22:22:10 +01:00
|
|
|
---*/
|
|
|
|
|
2018-04-25 23:29:53 +02:00
|
|
|
$262.agent.start(`
|
2018-05-21 20:23:15 +02:00
|
|
|
$262.agent.receiveBroadcast(function(sab) {
|
|
|
|
const i32a = new Int32Array(sab);
|
|
|
|
$262.agent.report(Atomics.wait(i32a, undefined, 0, 1000)); // undefined index => 0
|
|
|
|
$262.agent.leaving();
|
|
|
|
});
|
2018-03-13 22:22:10 +01:00
|
|
|
`);
|
|
|
|
|
2018-05-21 20:23:15 +02:00
|
|
|
const i32a = new Int32Array(
|
2018-06-25 21:17:45 +02:00
|
|
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
2018-05-21 20:23:15 +02:00
|
|
|
);
|
2018-03-13 22:22:10 +01:00
|
|
|
|
2018-04-25 23:29:53 +02:00
|
|
|
$262.agent.broadcast(i32a.buffer);
|
2018-03-20 01:06:53 +01:00
|
|
|
$262.agent.sleep(150);
|
2018-03-13 22:22:10 +01:00
|
|
|
|
2018-04-25 23:29:53 +02:00
|
|
|
assert.sameValue(Atomics.wake(i32a, 0), 1); // wake at index 0
|
|
|
|
assert.sameValue(Atomics.wake(i32a, 0), 0); // wake again at index 0, and 0 agents should be woken
|
2018-06-27 17:13:23 +02:00
|
|
|
assert.sameValue($262.agent.getReport(), 'ok');
|