mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Atomics.waitAsync: BigInt (#2642)
* Atomics.waitAsync: BigInt * Atomics.waitAsync: check for function to avoid false positives
This commit is contained in:
parent
f2ab5b6ca1
commit
f89ea8758b
@ -19,6 +19,7 @@ info: |
|
|||||||
includes: [testAtomics.js]
|
includes: [testAtomics.js]
|
||||||
features: [Atomics.waitAsync, Atomics, SharedArrayBuffer, ArrayBuffer, DataView, Symbol, TypedArray]
|
features: [Atomics.waitAsync, Atomics, SharedArrayBuffer, ArrayBuffer, DataView, Symbol, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 8)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 8)
|
||||||
);
|
);
|
||||||
|
28
test/built-ins/Atomics/waitAsync/bigint/bad-range.js
Normal file
28
test/built-ins/Atomics/waitAsync/bigint/bad-range.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Test range checking of Atomics.waitAsync on arrays that allow atomic operations
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Let i be ? ValidateAtomicAccess(typedArray, index).
|
||||||
|
...
|
||||||
|
|
||||||
|
includes: [testAtomics.js]
|
||||||
|
features: [Atomics.waitAsync, Atomics, SharedArrayBuffer, ArrayBuffer, DataView, Symbol, TypedArray, BigInt]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8));
|
||||||
|
|
||||||
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
|
assert.throws(RangeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, IdxGen(i64a), 0n, 0);
|
||||||
|
}, '`Atomics.waitAsync(i64a, IdxGen(i64a), 0n, 0)` throws RangeError');
|
||||||
|
});
|
@ -0,0 +1,91 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
False timeout arg should result in an +0 timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, false).value);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, valueOf).value);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value);
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n, false).value);
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n, valueOf).value);
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, false).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, valueOf).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, false).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, valueOf).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
60
test/built-ins/Atomics/waitAsync/bigint/false-for-timeout.js
Normal file
60
test/built-ins/Atomics/waitAsync/bigint/false-for-timeout.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
False timeout arg should result in an +0 timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, false).value,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, false).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, false).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, false).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, false).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value
|
||||||
|
]).then(outcomes => {
|
||||||
|
assert.sameValue(outcomes[0], 'timed-out');
|
||||||
|
assert.sameValue(outcomes[1], 'timed-out');
|
||||||
|
assert.sameValue(outcomes[2], 'timed-out');
|
||||||
|
}, $DONE).then($DONE, $DONE);
|
72
test/built-ins/Atomics/waitAsync/bigint/good-views.js
Normal file
72
test/built-ins/Atomics/waitAsync/bigint/good-views.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Test Atomics.waitAsync on arrays that allow atomic operations
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, Atomics, BigInt]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
(async () => {
|
||||||
|
var sab = new SharedArrayBuffer(2048);
|
||||||
|
var good_indices = [ (view) => 0/-1, // -0
|
||||||
|
(view) => '-0',
|
||||||
|
(view) => view.length - 1,
|
||||||
|
(view) => ({ valueOf: () => 0 }),
|
||||||
|
(view) => ({ toString: () => '0', valueOf: false }) // non-callable valueOf triggers invocation of toString
|
||||||
|
];
|
||||||
|
|
||||||
|
var view = new BigInt64Array(sab, 32, 20);
|
||||||
|
|
||||||
|
view[0] = 0n;
|
||||||
|
$262.agent.report("A " + (await Atomics.waitAsync(view, 0, 0n, 0).value))
|
||||||
|
$262.agent.report("B " + (await Atomics.waitAsync(view, 0, 37n, 0).value));
|
||||||
|
|
||||||
|
const results = [];
|
||||||
|
// In-bounds boundary cases for indexing
|
||||||
|
for ( let IdxGen of good_indices ) {
|
||||||
|
let Idx = IdxGen(view);
|
||||||
|
view.fill(0n);
|
||||||
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
|
// Atomics operations, not quite like view[Idx].
|
||||||
|
Atomics.store(view, Idx, 37n);
|
||||||
|
results.push(await Atomics.waitAsync(view, Idx, 0n).value);
|
||||||
|
}
|
||||||
|
$262.agent.report("C " + results.join(","));
|
||||||
|
|
||||||
|
$262.agent.leaving();
|
||||||
|
})();
|
||||||
|
`);
|
||||||
|
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
$262.agent.getReportAsync(),
|
||||||
|
$262.agent.getReportAsync(),
|
||||||
|
$262.agent.getReportAsync(),
|
||||||
|
]).then(outcomes => {
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
outcomes[0],
|
||||||
|
'A timed-out',
|
||||||
|
'"A " + (await Atomics.waitAsync(view, 0, 0n, 0).value resolves to "A timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
outcomes[1],
|
||||||
|
'B not-equal',
|
||||||
|
'"B " + (await Atomics.waitAsync(view, 0, 37n, 0).value resolves to "B not-equal"'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
outcomes[2],
|
||||||
|
'C not-equal,not-equal,not-equal,not-equal,not-equal',
|
||||||
|
'All C values are not equal'
|
||||||
|
);
|
||||||
|
}, $DONE).then($DONE, $DONE);
|
||||||
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
NaN timeout arg should result in an infinite timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, NaN).value); // NaN => +Infinity
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 1, 'Atomics.notify(i64a, 0) returns 1');
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'ok',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, NaN).value resolves to "ok"'
|
||||||
|
);
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a RangeError is index < 0
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||||
|
2. Let i be ? ValidateAtomicAccess(typedArray, index).
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(
|
||||||
|
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
|
||||||
|
);
|
||||||
|
|
||||||
|
const poisoned = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(RangeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, -Infinity, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(i64a, -Infinity, poisoned, poisoned)` throws RangeError');
|
||||||
|
assert.throws(RangeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, -7.999, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(i64a, -7.999, poisoned, poisoned)` throws RangeError');
|
||||||
|
assert.throws(RangeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, -1, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(i64a, -1, poisoned, poisoned)` throws RangeError');
|
||||||
|
assert.throws(RangeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, -300, poisoned, poisoned);
|
||||||
|
}, '`Atomics.wait(i64a, -300, poisoned, poisoned)` throws RangeError');
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Test that Atomics.waitAsync times out with a negative timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
var i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, -5).value); // -5 => 0
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, -5).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
28
test/built-ins/Atomics/waitAsync/bigint/negative-timeout.js
Normal file
28
test/built-ins/Atomics/waitAsync/bigint/negative-timeout.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Test that Atomics.waitAsync times out with a negative timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, destructuring-binding, arrow-function]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
Promise.all([Atomics.waitAsync(i64a, 0, 0n, -1).value]).then(([outcome]) => {
|
||||||
|
assert.sameValue(
|
||||||
|
outcome,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, -1).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
}, $DONE).then($DONE, $DONE);
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Test that Atomics.waitAsync returns the right result when it timed out and that
|
||||||
|
the time to time out is reasonable.
|
||||||
|
info: |
|
||||||
|
AddWaiter ( WL, waiterRecord )
|
||||||
|
|
||||||
|
5. Append waiterRecord as the last element of WL.[[Waiters]]
|
||||||
|
6. If waiterRecord.[[Timeout]] is finite, then in parallel,
|
||||||
|
a. Wait waiterRecord.[[Timeout]] milliseconds.
|
||||||
|
b. Perform TriggerTimeout(WL, waiterRecord).
|
||||||
|
|
||||||
|
TriggerTimeout( WL, waiterRecord )
|
||||||
|
|
||||||
|
3. If waiterRecord is in WL.[[Waiters]], then
|
||||||
|
a. Set waiterRecord.[[Result]] to "timed-out".
|
||||||
|
b. Perform RemoveWaiter(WL, waiterRecord).
|
||||||
|
c. Perform NotifyWaiter(WL, waiterRecord).
|
||||||
|
4. Perform LeaveCriticalSection(WL).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.small;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse >= TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Waiter does not spuriously notify on index which is subject to Add operation
|
||||||
|
info: |
|
||||||
|
AddWaiter ( WL, waiterRecord )
|
||||||
|
|
||||||
|
5. Append waiterRecord as the last element of WL.[[Waiters]]
|
||||||
|
6. If waiterRecord.[[Timeout]] is finite, then in parallel,
|
||||||
|
a. Wait waiterRecord.[[Timeout]] milliseconds.
|
||||||
|
b. Perform TriggerTimeout(WL, waiterRecord).
|
||||||
|
|
||||||
|
TriggerTimeout( WL, waiterRecord )
|
||||||
|
|
||||||
|
3. If waiterRecord is in WL.[[Waiters]], then
|
||||||
|
a. Set waiterRecord.[[Result]] to "timed-out".
|
||||||
|
b. Perform RemoveWaiter(WL, waiterRecord).
|
||||||
|
c. Perform NotifyWaiter(WL, waiterRecord).
|
||||||
|
4. Perform LeaveCriticalSection(WL).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.small;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
Atomics.add(i64a, 0, 1n);
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse >= TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Waiter does not spuriously notify on index which is subject to And operation
|
||||||
|
info: |
|
||||||
|
AddWaiter ( WL, waiterRecord )
|
||||||
|
|
||||||
|
5. Append waiterRecord as the last element of WL.[[Waiters]]
|
||||||
|
6. If waiterRecord.[[Timeout]] is finite, then in parallel,
|
||||||
|
a. Wait waiterRecord.[[Timeout]] milliseconds.
|
||||||
|
b. Perform TriggerTimeout(WL, waiterRecord).
|
||||||
|
|
||||||
|
TriggerTimeout( WL, waiterRecord )
|
||||||
|
|
||||||
|
3. If waiterRecord is in WL.[[Waiters]], then
|
||||||
|
a. Set waiterRecord.[[Result]] to "timed-out".
|
||||||
|
b. Perform RemoveWaiter(WL, waiterRecord).
|
||||||
|
c. Perform NotifyWaiter(WL, waiterRecord).
|
||||||
|
4. Perform LeaveCriticalSection(WL).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.small;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
Atomics.and(i64a, 0, 1n);
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse >= TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Waiter does not spuriously notify on index which is subject to compareExchange operation
|
||||||
|
info: |
|
||||||
|
AddWaiter ( WL, waiterRecord )
|
||||||
|
|
||||||
|
5. Append waiterRecord as the last element of WL.[[Waiters]]
|
||||||
|
6. If waiterRecord.[[Timeout]] is finite, then in parallel,
|
||||||
|
a. Wait waiterRecord.[[Timeout]] milliseconds.
|
||||||
|
b. Perform TriggerTimeout(WL, waiterRecord).
|
||||||
|
|
||||||
|
TriggerTimeout( WL, waiterRecord )
|
||||||
|
|
||||||
|
3. If waiterRecord is in WL.[[Waiters]], then
|
||||||
|
a. Set waiterRecord.[[Result]] to "timed-out".
|
||||||
|
b. Perform RemoveWaiter(WL, waiterRecord).
|
||||||
|
c. Perform NotifyWaiter(WL, waiterRecord).
|
||||||
|
4. Perform LeaveCriticalSection(WL).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.small;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
Atomics.compareExchange(i64a, 0, 0n, 1n);
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse >= TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Waiter does not spuriously notify on index which is subject to exchange operation
|
||||||
|
info: |
|
||||||
|
AddWaiter ( WL, waiterRecord )
|
||||||
|
|
||||||
|
5. Append waiterRecord as the last element of WL.[[Waiters]]
|
||||||
|
6. If waiterRecord.[[Timeout]] is finite, then in parallel,
|
||||||
|
a. Wait waiterRecord.[[Timeout]] milliseconds.
|
||||||
|
b. Perform TriggerTimeout(WL, waiterRecord).
|
||||||
|
|
||||||
|
TriggerTimeout( WL, waiterRecord )
|
||||||
|
|
||||||
|
3. If waiterRecord is in WL.[[Waiters]], then
|
||||||
|
a. Set waiterRecord.[[Result]] to "timed-out".
|
||||||
|
b. Perform RemoveWaiter(WL, waiterRecord).
|
||||||
|
c. Perform NotifyWaiter(WL, waiterRecord).
|
||||||
|
4. Perform LeaveCriticalSection(WL).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.small;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
Atomics.exchange(i64a, 0, 1n);
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse >= TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Waiter does not spuriously notify on index which is subject to Or operation
|
||||||
|
info: |
|
||||||
|
AddWaiter ( WL, waiterRecord )
|
||||||
|
|
||||||
|
5. Append waiterRecord as the last element of WL.[[Waiters]]
|
||||||
|
6. If waiterRecord.[[Timeout]] is finite, then in parallel,
|
||||||
|
a. Wait waiterRecord.[[Timeout]] milliseconds.
|
||||||
|
b. Perform TriggerTimeout(WL, waiterRecord).
|
||||||
|
|
||||||
|
TriggerTimeout( WL, waiterRecord )
|
||||||
|
|
||||||
|
3. If waiterRecord is in WL.[[Waiters]], then
|
||||||
|
a. Set waiterRecord.[[Result]] to "timed-out".
|
||||||
|
b. Perform RemoveWaiter(WL, waiterRecord).
|
||||||
|
c. Perform NotifyWaiter(WL, waiterRecord).
|
||||||
|
4. Perform LeaveCriticalSection(WL).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.small;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
Atomics.or(i64a, 0, 1n);
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse >= TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Waiter does not spuriously notify on index which is subject to Store operation
|
||||||
|
info: |
|
||||||
|
AddWaiter ( WL, waiterRecord )
|
||||||
|
|
||||||
|
5. Append waiterRecord as the last element of WL.[[Waiters]]
|
||||||
|
6. If waiterRecord.[[Timeout]] is finite, then in parallel,
|
||||||
|
a. Wait waiterRecord.[[Timeout]] milliseconds.
|
||||||
|
b. Perform TriggerTimeout(WL, waiterRecord).
|
||||||
|
|
||||||
|
TriggerTimeout( WL, waiterRecord )
|
||||||
|
|
||||||
|
3. If waiterRecord is in WL.[[Waiters]], then
|
||||||
|
a. Set waiterRecord.[[Result]] to "timed-out".
|
||||||
|
b. Perform RemoveWaiter(WL, waiterRecord).
|
||||||
|
c. Perform NotifyWaiter(WL, waiterRecord).
|
||||||
|
4. Perform LeaveCriticalSection(WL).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.small;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
Atomics.store(i64a, 0, 0b1010n);
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse >= TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Waiter does not spuriously notify on index which is subject to Sub operation
|
||||||
|
info: |
|
||||||
|
AddWaiter ( WL, waiterRecord )
|
||||||
|
|
||||||
|
5. Append waiterRecord as the last element of WL.[[Waiters]]
|
||||||
|
6. If waiterRecord.[[Timeout]] is finite, then in parallel,
|
||||||
|
a. Wait waiterRecord.[[Timeout]] milliseconds.
|
||||||
|
b. Perform TriggerTimeout(WL, waiterRecord).
|
||||||
|
|
||||||
|
TriggerTimeout( WL, waiterRecord )
|
||||||
|
|
||||||
|
3. If waiterRecord is in WL.[[Waiters]], then
|
||||||
|
a. Set waiterRecord.[[Result]] to "timed-out".
|
||||||
|
b. Perform RemoveWaiter(WL, waiterRecord).
|
||||||
|
c. Perform NotifyWaiter(WL, waiterRecord).
|
||||||
|
4. Perform LeaveCriticalSection(WL).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.small;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
Atomics.sub(i64a, 0, 1n);
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse >= TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Waiter does not spuriously notify on index which is subject to xor operation
|
||||||
|
info: |
|
||||||
|
AddWaiter ( WL, waiterRecord )
|
||||||
|
|
||||||
|
5. Append waiterRecord as the last element of WL.[[Waiters]]
|
||||||
|
6. If waiterRecord.[[Timeout]] is finite, then in parallel,
|
||||||
|
a. Wait waiterRecord.[[Timeout]] milliseconds.
|
||||||
|
b. Perform TriggerTimeout(WL, waiterRecord).
|
||||||
|
|
||||||
|
TriggerTimeout( WL, waiterRecord )
|
||||||
|
|
||||||
|
3. If waiterRecord is in WL.[[Waiters]], then
|
||||||
|
a. Set waiterRecord.[[Result]] to "timed-out".
|
||||||
|
b. Perform RemoveWaiter(WL, waiterRecord).
|
||||||
|
c. Perform NotifyWaiter(WL, waiterRecord).
|
||||||
|
4. Perform LeaveCriticalSection(WL).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.small;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
Atomics.xor(i64a, 0, 1n);
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse >= TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if typedArray arg is not an BigInt64Array
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||||
|
|
||||||
|
ValidateSharedIntegerTypedArray ( typedArray [ , waitable ] )
|
||||||
|
|
||||||
|
5. If waitable is true, then
|
||||||
|
a. If typeName is not "Int32Array" or "BigInt64Array", throw a TypeError exception.
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray, arrow-function, SharedArrayBuffer, Atomics]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const poisoned = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
const view = new BigUint64Array(new SharedArrayBuffer(BigUint64Array.BYTES_PER_ELEMENT * 8));
|
||||||
|
Atomics.waitAsync(view, poisoned, poisoned, poisoned);
|
||||||
|
}, '`const view = new BigUint64Array(new SharedArrayBuffer(BigUint64Array.BYTES_PER_ELEMENT * 8)); Atomics.waitAsync(view, poisoned, poisoned, poisoned);` throws TypeError');
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if typedArray.buffer is not a SharedArrayBuffer
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||||
|
|
||||||
|
ValidateSharedIntegerTypedArray ( typedArray [ , waitable ] )
|
||||||
|
|
||||||
|
5. If waitable is true, then
|
||||||
|
a. If typeName is not "BigInt64Array" or "BigInt64Array", throw a TypeError exception.
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, ArrayBuffer, Atomics, TypedArray, BigInt, arrow-function]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
const poisoned = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, 0);
|
||||||
|
}, '`Atomics.waitAsync(i64a, 0, 0n, 0)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync(i64a, poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(i64a, poisoned, poisoned, poisoned)` throws TypeError');
|
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if the typedArray arg is not a TypedArray object
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||||
|
|
||||||
|
ValidateSharedIntegerTypedArray ( typedArray [ , waitable ] )
|
||||||
|
|
||||||
|
2. Perform ? RequireInternalSlot(typedArray, [[TypedArrayName]]).
|
||||||
|
|
||||||
|
RequireInternalSlot ( O, internalSlot )
|
||||||
|
|
||||||
|
1. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
2. If O does not have an internalSlot internal slot, throw a TypeError exception.
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, arrow-function, Atomics]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const poisoned = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync({}, 0, 0n, 0);
|
||||||
|
}, '`Atomics.waitAsync({}, 0, 0n, 0)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync({}, poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync({}, poisoned, poisoned, poisoned)` throws TypeError');
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if typedArray arg is not an Object
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||||
|
|
||||||
|
ValidateSharedIntegerTypedArray ( typedArray [ , waitable ] )
|
||||||
|
|
||||||
|
2. Perform ? RequireInternalSlot(typedArray, [[TypedArrayName]]).
|
||||||
|
|
||||||
|
RequireInternalSlot ( O, internalSlot )
|
||||||
|
|
||||||
|
1. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
2. If O does not have an internalSlot internal slot, throw a TypeError exception.
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, Symbol, arrow-function, Atomics]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const poisoned = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync(null, poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(null, poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync(undefined, poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(undefined, poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync(true, poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(true, poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync(false, poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(false, poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync('***string***', poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(\'***string***\', poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync(Number.NEGATIVE_INFINITY, poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(Number.NEGATIVE_INFINITY, poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Atomics.waitAsync(Symbol('***symbol***'), poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(Symbol(\'***symbol***\'), poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
A null value for bufferData throws a TypeError
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||||
|
|
||||||
|
ValidateSharedIntegerTypedArray ( typedArray [ , waitable ] )
|
||||||
|
|
||||||
|
2. Perform ? RequireInternalSlot(typedArray, [[TypedArrayName]]).
|
||||||
|
|
||||||
|
RequireInternalSlot ( O, internalSlot )
|
||||||
|
|
||||||
|
1. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
2. If O does not have an internalSlot internal slot, throw a TypeError exception.
|
||||||
|
|
||||||
|
includes: [detachArrayBuffer.js]
|
||||||
|
features: [Atomics.waitAsync, ArrayBuffer, Atomics, TypedArray, BigInt]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(
|
||||||
|
new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
|
||||||
|
);
|
||||||
|
|
||||||
|
const poisoned = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
$DETACHBUFFER(i64a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
|
||||||
|
} catch (error) {
|
||||||
|
$ERROR(`An unexpected error occurred when detaching ArrayBuffer: ${error.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, poisoned, poisoned, poisoned);
|
||||||
|
}, '`Atomics.waitAsync(i64a, poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
|
@ -0,0 +1,93 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
null timeout arg should result in an +0 timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
Null -> Return +0.
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, null).value);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, valueOf).value);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value);
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n, null).value);
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n, valueOf).value);
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, null).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, valueOf).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, null).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, valueOf).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
62
test/built-ins/Atomics/waitAsync/bigint/null-for-timeout.js
Normal file
62
test/built-ins/Atomics/waitAsync/bigint/null-for-timeout.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
null timeout arg should result in an +0 timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
Null -> Return +0.
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt, arrow-function]
|
||||||
|
flags: [async]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, null).value,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, null).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, valueOf).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, null).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value
|
||||||
|
]).then(outcomes => {
|
||||||
|
assert.sameValue(outcomes[0], 'timed-out');
|
||||||
|
assert.sameValue(outcomes[1], 'timed-out');
|
||||||
|
assert.sameValue(outcomes[2], 'timed-out');
|
||||||
|
}, $DONE).then($DONE, $DONE);
|
@ -0,0 +1,102 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Object valueOf, toString, toPrimitive Zero timeout arg should result in an +0 timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
Object -> Apply the following steps:
|
||||||
|
|
||||||
|
Let primValue be ? ToPrimitive(argument, hint Number).
|
||||||
|
Return ? ToNumber(primValue).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toString = {
|
||||||
|
toString() {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, valueOf).value);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, toString).value);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value);
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n, valueOf).value);
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n, toString).value);
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, valueOf).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, toString).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, valueOf).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, toString).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,71 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Object valueOf, toString, toPrimitive Zero timeout arg should result in an +0 timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
Object -> Apply the following steps:
|
||||||
|
|
||||||
|
Let primValue be ? ToPrimitive(argument, hint Number).
|
||||||
|
Return ? ToNumber(primValue).
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt, arrow-function]
|
||||||
|
flags: [async]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toString = {
|
||||||
|
toString() {
|
||||||
|
return '0';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, valueOf).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toString).value,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, toString).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value,
|
||||||
|
'timed-out',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toString).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value
|
||||||
|
]).then(outcomes => {
|
||||||
|
assert.sameValue(outcomes[0], 'timed-out');
|
||||||
|
assert.sameValue(outcomes[1], 'timed-out');
|
||||||
|
assert.sameValue(outcomes[2], 'timed-out');
|
||||||
|
}, $DONE).then($DONE, $DONE);
|
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a RangeError if value of index arg is out of range
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
2. Let i be ? ValidateAtomicAccess(typedArray, index).
|
||||||
|
|
||||||
|
...
|
||||||
|
2.Let accessIndex be ? ToIndex(requestIndex).
|
||||||
|
...
|
||||||
|
5. If accessIndex ≥ length, throw a RangeError exception.
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(
|
||||||
|
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
|
||||||
|
);
|
||||||
|
|
||||||
|
const poisoned = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(RangeError, function() {
|
||||||
|
Atomics.wait(i64a, Infinity, poisoned, poisoned);
|
||||||
|
}, '`Atomics.wait(i64a, Infinity, poisoned, poisoned)` throws RangeError');
|
||||||
|
assert.throws(RangeError, function() {
|
||||||
|
Atomics.wait(i64a, -1, poisoned, poisoned);
|
||||||
|
}, '`Atomics.wait(i64a, -1, poisoned, poisoned)` throws RangeError');
|
||||||
|
assert.throws(RangeError, function() {
|
||||||
|
Atomics.wait(i64a, 4, poisoned, poisoned);
|
||||||
|
}, '`Atomics.wait(i64a, 4, poisoned, poisoned)` throws RangeError');
|
||||||
|
assert.throws(RangeError, function() {
|
||||||
|
Atomics.wait(i64a, 200, poisoned, poisoned);
|
||||||
|
}, '`Atomics.wait(i64a, 200, poisoned, poisoned)` throws RangeError');
|
||||||
|
|
@ -0,0 +1,81 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
False timeout arg should result in an +0 timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
Let primValue be ? ToPrimitive(argument, hint Number).
|
||||||
|
Return ? ToNumber(primValue).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
const poisonedValueOf = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const poisonedToPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
throw new Error('passing a poisoned object using @@ToPrimitive');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
let status1 = '';
|
||||||
|
let status2 = '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
Atomics.wait(i64a, 0, 0n, poisonedValueOf);
|
||||||
|
} catch (error) {
|
||||||
|
status1 = 'poisonedValueOf';
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Atomics.wait(i64a, 0, 0n, poisonedToPrimitive);
|
||||||
|
} catch (error) {
|
||||||
|
status2 = 'poisonedToPrimitive';
|
||||||
|
}
|
||||||
|
|
||||||
|
$262.agent.report(status1);
|
||||||
|
$262.agent.report(status2);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'poisonedValueOf',
|
||||||
|
'Atomics.wait(i64a, 0, 0n, poisonedValueOf) throws'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'poisonedToPrimitive',
|
||||||
|
'Atomics.wait(i64a, 0, 0n, poisonedToPrimitive) throws'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if index arg can not be converted to an Integer
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
Let primValue be ? ToPrimitive(argument, hint Number).
|
||||||
|
Return ? ToNumber(primValue).
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
const poisonedValueOf = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const poisonedToPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
throw new Test262Error('passing a poisoned object using @@ToPrimitive');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Atomics.wait(i64a, 0, 0n, poisonedValueOf);
|
||||||
|
}, '`Atomics.wait(i64a, 0, 0n, poisonedValueOf)` throws Test262Error');
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Atomics.wait(i64a, 0, 0n, poisonedToPrimitive);
|
||||||
|
}, '`Atomics.wait(i64a, 0, 0n, poisonedToPrimitive)` throws Test262Error');
|
@ -0,0 +1,93 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if index arg can not be converted to an Integer
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
2. Let i be ? ValidateAtomicAccess(typedArray, index).
|
||||||
|
|
||||||
|
ValidateAtomicAccess( typedArray, requestIndex )
|
||||||
|
|
||||||
|
2. Let accessIndex be ? ToIndex(requestIndex).
|
||||||
|
|
||||||
|
ToIndex ( value )
|
||||||
|
|
||||||
|
2. Else,
|
||||||
|
a. Let integerIndex be ? ToInteger(value).
|
||||||
|
|
||||||
|
ToInteger(value)
|
||||||
|
|
||||||
|
1. Let number be ? ToNumber(argument).
|
||||||
|
|
||||||
|
Symbol --> Throw a TypeError exception.
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
const poisonedValueOf = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const poisonedToPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
let status1 = '';
|
||||||
|
let status2 = '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
Atomics.waitAsync(i64a, Symbol('1'), poisonedValueOf, poisonedValueOf);
|
||||||
|
} catch (error) {
|
||||||
|
status1 = 'A ' + error.name;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Atomics.waitAsync(i64a, Symbol('2'), poisonedToPrimitive, poisonedToPrimitive);
|
||||||
|
} catch (error) {
|
||||||
|
status2 = 'B ' + error.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$262.agent.report(status1);
|
||||||
|
$262.agent.report(status2);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'A TypeError',
|
||||||
|
'Atomics.waitAsync(i64a, Symbol("1"), ..., ...) throws TypeError'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'B TypeError',
|
||||||
|
'Atomics.waitAsync(i64a, Symbol("2"), ..., ...) throws TypeError'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,68 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if index arg can not be converted to an Integer
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
2. Let i be ? ValidateAtomicAccess(typedArray, index).
|
||||||
|
|
||||||
|
ValidateAtomicAccess( typedArray, requestIndex )
|
||||||
|
|
||||||
|
2. Let accessIndex be ? ToIndex(requestIndex).
|
||||||
|
|
||||||
|
ToIndex ( value )
|
||||||
|
|
||||||
|
2. Else,
|
||||||
|
a. Let integerIndex be ? ToInteger(value).
|
||||||
|
|
||||||
|
ToInteger(value)
|
||||||
|
|
||||||
|
1. Let number be ? ToNumber(argument).
|
||||||
|
|
||||||
|
Symbol --> Throw a TypeError exception.
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(
|
||||||
|
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
|
||||||
|
);
|
||||||
|
|
||||||
|
const poisonedValueOf = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const poisonedToPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Atomics.waitAsync(i64a, poisonedValueOf, poisonedValueOf, poisonedValueOf);
|
||||||
|
}, '`Atomics.waitAsync(i64a, poisonedValueOf, poisonedValueOf, poisonedValueOf)` throws Test262Error');
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Atomics.waitAsync(i64a, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive);
|
||||||
|
}, '`Atomics.waitAsync(i64a, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive)` throws Test262Error');
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, Symbol('1'), poisonedValueOf, poisonedValueOf);
|
||||||
|
}, '`Atomics.waitAsync(i64a, Symbol("1"), poisonedValueOf, poisonedValueOf)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, Symbol('2'), poisonedToPrimitive, poisonedToPrimitive);
|
||||||
|
}, '`Atomics.waitAsync(i64a, Symbol("2"), poisonedToPrimitive, poisonedToPrimitive)` throws TypeError');
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if index arg can not be converted to an Integer
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
Symbol --> Throw a TypeError exception.
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
let status1 = '';
|
||||||
|
let status2 = '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, Symbol('1'));
|
||||||
|
} catch (error) {
|
||||||
|
status1 = 'A ' + error.name;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, Symbol('2'));
|
||||||
|
} catch (error) {
|
||||||
|
status2 = 'B ' + error.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$262.agent.report(status1);
|
||||||
|
$262.agent.report(status2);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'A TypeError',
|
||||||
|
'Atomics.wait(i64a, 0, 0n, Symbol("1")) throws TypeError'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'B TypeError',
|
||||||
|
'Atomics.wait(i64a, 0, 0n, Symbol("2")) throws TypeError'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if index arg can not be converted to an Integer
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
Symbol --> Throw a TypeError exception.
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
const poisonedValueOf = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const poisonedToPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
throw new Test262Error('passing a poisoned object using @@ToPrimitive');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, poisonedValueOf);
|
||||||
|
}, '`Atomics.waitAsync(i64a, 0, 0n, poisonedValueOf)` throws Test262Error');
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, poisonedToPrimitive);
|
||||||
|
}, '`Atomics.waitAsync(i64a, 0, 0n, poisonedToPrimitive)` throws Test262Error');
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, Symbol('foo'));
|
||||||
|
}, '`Atomics.waitAsync(i64a, 0, 0n, Symbol("foo"))` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, Symbol('foo'));
|
||||||
|
}, '`Atomics.waitAsync(i64a, 0, 0n, Symbol("foo"))` throws TypeError');
|
@ -0,0 +1,84 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if value arg is a Symbol
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
5. Otherwise, let v be ? ToInt32(value).
|
||||||
|
|
||||||
|
ToInt32(value)
|
||||||
|
|
||||||
|
1.Let number be ? ToNumber(argument).
|
||||||
|
|
||||||
|
Symbol --> Throw a TypeError exception.
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
const poisonedValueOf = {
|
||||||
|
valueOf: function() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const poisonedToPrimitive = {
|
||||||
|
[Symbol.toPrimitive]: function() {
|
||||||
|
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
let status1 = "";
|
||||||
|
let status2 = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
Atomics.waitAsync(i64a, 0, Symbol("1"), poisonedValueOf);
|
||||||
|
} catch (error) {
|
||||||
|
status1 = 'A ' + error.name;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Atomics.waitAsync(i64a, 0, Symbol("2"), poisonedToPrimitive);
|
||||||
|
} catch (error) {
|
||||||
|
status2 = 'B ' + error.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$262.agent.report(status1);
|
||||||
|
$262.agent.report(status2);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'A TypeError',
|
||||||
|
'Atomics.waitAsync(i64a, 0, Symbol("1"), ...) throws TypeError'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'B TypeError',
|
||||||
|
'Atomics.waitAsync(i64a, 0, Symbol("2"), ...) throws TypeError'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -0,0 +1,57 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if value arg is a Symbol
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
5. Otherwise, let v be ? ToInt32(value).
|
||||||
|
|
||||||
|
ToInt32(value)
|
||||||
|
|
||||||
|
1.Let number be ? ToNumber(argument).
|
||||||
|
|
||||||
|
Symbol --> Throw a TypeError exception.
|
||||||
|
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(
|
||||||
|
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
|
||||||
|
);
|
||||||
|
|
||||||
|
const poisonedValueOf = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const poisonedToPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Atomics.waitAsync(i64a, 0, poisonedValueOf, poisonedValueOf);
|
||||||
|
}, '`Atomics.waitAsync(i64a, 0, poisonedValueOf, poisonedValueOf)` throws Test262Error');
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Atomics.waitAsync(i64a, 0, poisonedToPrimitive, poisonedToPrimitive);
|
||||||
|
}, '`Atomics.waitAsync(i64a, 0, poisonedToPrimitive, poisonedToPrimitive)` throws Test262Error');
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, 0, Symbol("foo"), poisonedValueOf);
|
||||||
|
}, '`Atomics.waitAsync(i64a, 0, Symbol("foo"), poisonedValueOf)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Atomics.waitAsync(i64a, 0, Symbol("foo"), poisonedToPrimitive);
|
||||||
|
}, '`Atomics.waitAsync(i64a, 0, Symbol("foo"), poisonedToPrimitive)` throws TypeError');
|
||||||
|
|
@ -0,0 +1,70 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
True timeout arg should result in an +0 timeout
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, true).value);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, valueOf).value);
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, false).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, valueOf).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'timed-out',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value resolves to "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
44
test/built-ins/Atomics/waitAsync/bigint/true-for-timeout.js
Normal file
44
test/built-ins/Atomics/waitAsync/bigint/true-for-timeout.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if index arg can not be converted to an Integer
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
|
||||||
|
Boolean -> If argument is true, return 1. If argument is false, return +0.
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, true).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value
|
||||||
|
]).then(outcomes => {
|
||||||
|
assert.sameValue(outcomes[0], 'timed-out');
|
||||||
|
assert.sameValue(outcomes[1], 'timed-out');
|
||||||
|
assert.sameValue(outcomes[2], 'timed-out');
|
||||||
|
}, $DONE).then($DONE, $DONE);
|
@ -0,0 +1,77 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Undefined timeout arg is coerced to zero
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
...
|
||||||
|
Undefined Return NaN.
|
||||||
|
|
||||||
|
5.If q is NaN, let t be +∞, else let t be max(q, 0)
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
|
||||||
|
const WAIT_INDEX = 0;
|
||||||
|
const RUNNING = 1;
|
||||||
|
const NUMAGENT = 2;
|
||||||
|
const NOTIFYCOUNT = 2;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
var i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
// undefined => NaN => +Infinity
|
||||||
|
$262.agent.report("A " + (await Atomics.waitAsync(i64a, 0, 0n, undefined).value));
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
var i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
// undefined timeout arg => NaN => +Infinity
|
||||||
|
$262.agent.report("B " + (await Atomics.waitAsync(i64a, 0, 0n).value));
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(
|
||||||
|
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
|
||||||
|
);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, BigInt(NUMAGENT)).then(async (agentCount) => {
|
||||||
|
|
||||||
|
assert.sameValue(agentCount, BigInt(NUMAGENT));
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.notify(i64a, WAIT_INDEX, NOTIFYCOUNT),
|
||||||
|
NOTIFYCOUNT,
|
||||||
|
'Atomics.notify(i64a, WAIT_INDEX, NOTIFYCOUNT) returns the value of `NOTIFYCOUNT` (2)'
|
||||||
|
);
|
||||||
|
|
||||||
|
const reports = [
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
];
|
||||||
|
|
||||||
|
reports.sort();
|
||||||
|
assert.sameValue(reports[0], 'A ok', 'The value of reports[0] is "A ok"');
|
||||||
|
assert.sameValue(reports[1], 'B ok', 'The value of reports[1] is "B ok"');
|
||||||
|
}).then($DONE, $DONE);
|
||||||
|
|
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Undefined timeout arg is coerced to zero
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
6. Let q be ? ToNumber(timeout).
|
||||||
|
...
|
||||||
|
Undefined Return NaN.
|
||||||
|
|
||||||
|
5.If q is NaN, let t be +∞, else let t be max(q, 0)
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
var i64a = new BigInt64Array(sab);
|
||||||
|
$262.agent.sleep(1000);
|
||||||
|
Atomics.notify(i64a, 0, 4);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcast(i64a);
|
||||||
|
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, undefined).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
|
||||||
|
Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value
|
||||||
|
]).then(outcomes => {
|
||||||
|
assert.sameValue(outcomes[0], 'ok');
|
||||||
|
assert.sameValue(outcomes[1], 'ok');
|
||||||
|
assert.sameValue(outcomes[2], 'ok');
|
||||||
|
assert.sameValue(outcomes[3], 'ok');
|
||||||
|
}, $DONE).then($DONE, $DONE);
|
@ -0,0 +1,79 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Undefined index arg is coerced to zero
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, 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.
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
|
||||||
|
const WAIT_INDEX = 0;
|
||||||
|
const RUNNING = 1;
|
||||||
|
const NUMAGENT = 2;
|
||||||
|
const NOTIFYCOUNT = 2;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
var i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
$262.agent.report("A " + (await Atomics.waitAsync(i64a, undefined, 0n).value));
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
var i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
$262.agent.report("B " + (await Atomics.waitAsync(i64a, undefined, 0n).value));
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(
|
||||||
|
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
|
||||||
|
);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, BigInt(NUMAGENT)).then(async (agentCount) => {
|
||||||
|
|
||||||
|
assert.sameValue(agentCount, BigInt(NUMAGENT));
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.notify(i64a, WAIT_INDEX, NOTIFYCOUNT),
|
||||||
|
NOTIFYCOUNT,
|
||||||
|
'Atomics.notify(i64a, WAIT_INDEX, NOTIFYCOUNT) returns the value of `NOTIFYCOUNT` (2)'
|
||||||
|
);
|
||||||
|
|
||||||
|
const reports = [
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
];
|
||||||
|
|
||||||
|
reports.sort();
|
||||||
|
assert.sameValue(reports[0], 'A ok', 'The value of reports[0] is "A ok"');
|
||||||
|
assert.sameValue(reports[1], 'B ok', 'The value of reports[1] is "B ok"');
|
||||||
|
}).then($DONE, $DONE);
|
||||||
|
|
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Returns "not-equal" when value arg does not match an index in the typedArray
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
16. Let w be ! AtomicLoad(typedArray, i).
|
||||||
|
17. If v is not equal to w, then
|
||||||
|
a. Perform LeaveCriticalSection(WL).
|
||||||
|
b. If mode is sync, then
|
||||||
|
i. Return the String "not-equal".
|
||||||
|
c. Perform ! Call(capability.[[Resolve]], undefined, « "not-equal" »).
|
||||||
|
d. Return promiseCapability.[[Promise]].
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const value = 42n;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
$262.agent.report(Atomics.store(i64a, 0, 42n));
|
||||||
|
$262.agent.report(Atomics.waitAsync(i64a, 0, 0n).value);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
value.toString(),
|
||||||
|
'Atomics.store(i64a, 0, 42n) returns 42'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'not-equal',
|
||||||
|
'Atomics.waitAsync(i64a, 0, 0n).value resolves to "not-equal"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.notify(i64a, 0, 1),
|
||||||
|
0,
|
||||||
|
'Atomics.notify(i64a, 0, 1) returns 0 (nothing to notify)'
|
||||||
|
);
|
||||||
|
}).then($DONE, $DONE);
|
43
test/built-ins/Atomics/waitAsync/bigint/value-not-equal.js
Normal file
43
test/built-ins/Atomics/waitAsync/bigint/value-not-equal.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Returns "not-equal" when value arg does not match an index in the typedArray
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
16. Let w be ! AtomicLoad(typedArray, i).
|
||||||
|
17. If v is not equal to w, then
|
||||||
|
a. Perform LeaveCriticalSection(WL).
|
||||||
|
b. If mode is sync, then
|
||||||
|
i. Return the String "not-equal".
|
||||||
|
c. Perform ! Call(capability.[[Resolve]], undefined, « "not-equal" »).
|
||||||
|
d. Return promiseCapability.[[Promise]].
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, BigInt, computed-property-names, Symbol, Symbol.toPrimitive, Atomics, arrow-function]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
const valueOf = {
|
||||||
|
valueOf() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toPrimitive = {
|
||||||
|
[Symbol.toPrimitive]() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.all([Atomics.store(i64a, 0, 42n), Atomics.waitAsync(i64a, 0, 0n).value]).then(outcomes => {
|
||||||
|
assert.sameValue(outcomes[0], 42n);
|
||||||
|
assert.sameValue(outcomes[1], 'not-equal');
|
||||||
|
}, $DONE).then($DONE, $DONE);
|
@ -0,0 +1,85 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Get the correct WaiterList
|
||||||
|
info: |
|
||||||
|
Atomics.waitAsync( typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
1. Return DoWait(async, typedArray, index, value, timeout).
|
||||||
|
|
||||||
|
DoWait ( mode, typedArray, index, value, timeout )
|
||||||
|
|
||||||
|
11. Let indexedPosition be (i × 4) + offset.
|
||||||
|
12. Let WL be GetWaiterList(block, indexedPosition).
|
||||||
|
|
||||||
|
GetWaiterList( block, i )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Return the WaiterList that is referenced by the pair (block, i).
|
||||||
|
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
|
||||||
|
const NUMAGENT = 2;
|
||||||
|
const RUNNING = 4;
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
// Wait on index 0
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 0, 0n, Infinity).value);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
// Wait on index 2
|
||||||
|
$262.agent.report(await Atomics.waitAsync(i64a, 2, 0n, Infinity).value);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(
|
||||||
|
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 5)
|
||||||
|
);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, BigInt(NUMAGENT)).then(async (agentCount) => {
|
||||||
|
|
||||||
|
assert.sameValue(agentCount, BigInt(NUMAGENT));
|
||||||
|
|
||||||
|
// Notify index 1, notifies nothing
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 1), 0, 'Atomics.notify(i64a, 1) returns 0');
|
||||||
|
|
||||||
|
// Notify index 3, notifies nothing
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 3), 0, 'Atomics.notify(i64a, 3) returns 0');
|
||||||
|
|
||||||
|
// Notify index 2, notifies 1
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 2), 1, 'Atomics.notify(i64a, 2) returns 1');
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'ok',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, Infinity).value resolves to "ok"'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Notify index 0, notifies 1
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 1, 'Atomics.notify(i64a, 0) returns 1');
|
||||||
|
assert.sameValue(
|
||||||
|
await $262.agent.getReportAsync(),
|
||||||
|
'ok',
|
||||||
|
'await Atomics.waitAsync(i64a, 2, 0n, Infinity).value resolves to "ok"'
|
||||||
|
);
|
||||||
|
|
||||||
|
}).then($DONE, $DONE);
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.waitasync
|
||||||
|
description: >
|
||||||
|
Test that Atomics.waitAsync returns the right result when it was awoken before
|
||||||
|
a timeout
|
||||||
|
flags: [async]
|
||||||
|
includes: [atomicsHelper.js]
|
||||||
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, arrow-function, async-functions]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
const RUNNING = 1;
|
||||||
|
const TIMEOUT = $262.agent.timeouts.huge;
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
|
||||||
|
|
||||||
|
$262.agent.start(`
|
||||||
|
$262.agent.receiveBroadcast(async (sab) => {
|
||||||
|
const i64a = new BigInt64Array(sab);
|
||||||
|
Atomics.add(i64a, ${RUNNING}, 1n);
|
||||||
|
|
||||||
|
const before = $262.agent.monotonicNow();
|
||||||
|
const unpark = await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value;
|
||||||
|
const duration = $262.agent.monotonicNow() - before;
|
||||||
|
|
||||||
|
$262.agent.report(duration);
|
||||||
|
$262.agent.report(unpark);
|
||||||
|
$262.agent.leaving();
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
$262.agent.safeBroadcastAsync(i64a, RUNNING, 1n).then(async agentCount => {
|
||||||
|
assert.sameValue(agentCount, 1n);
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 1, 'Atomics.notify(i64a, 0) returns 1');
|
||||||
|
const lapse = await $262.agent.getReportAsync();
|
||||||
|
assert(lapse < TIMEOUT, 'The result of `(lapse >= TIMEOUT)` is true');
|
||||||
|
const result = await $262.agent.getReportAsync();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result,
|
||||||
|
'ok',
|
||||||
|
'await Atomics.waitAsync(i64a, 0, 0n, ${TIMEOUT}).value resolves to "ok"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
|
||||||
|
}).then($DONE, $DONE);
|
@ -17,6 +17,7 @@ info: |
|
|||||||
flags: [async]
|
flags: [async]
|
||||||
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -5,16 +5,16 @@
|
|||||||
esid: sec-atomics.waitasync
|
esid: sec-atomics.waitasync
|
||||||
description: >
|
description: >
|
||||||
Test Atomics.waitAsync on arrays that allow atomic operations
|
Test Atomics.waitAsync on arrays that allow atomic operations
|
||||||
|
flags: [async]
|
||||||
includes: [atomicsHelper.js]
|
includes: [atomicsHelper.js]
|
||||||
features: [Atomics.waitAsync, Atomics]
|
features: [Atomics.waitAsync, Atomics]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
|
|
||||||
|
|
||||||
$262.agent.start(`
|
$262.agent.start(`
|
||||||
(async () => {
|
(async () => {
|
||||||
var sab = new SharedArrayBuffer(1024);
|
var sab = new SharedArrayBuffer(1024);
|
||||||
var ab = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
var good_indices = [ (view) => 0/-1, // -0
|
var good_indices = [ (view) => 0/-1, // -0
|
||||||
(view) => '-0',
|
(view) => '-0',
|
||||||
(view) => view.length - 1,
|
(view) => view.length - 1,
|
||||||
@ -28,6 +28,7 @@ $262.agent.start(`
|
|||||||
$262.agent.report("A " + (await Atomics.waitAsync(view, 0, 0, 0).value))
|
$262.agent.report("A " + (await Atomics.waitAsync(view, 0, 0, 0).value))
|
||||||
$262.agent.report("B " + (await Atomics.waitAsync(view, 0, 37, 0).value));
|
$262.agent.report("B " + (await Atomics.waitAsync(view, 0, 37, 0).value));
|
||||||
|
|
||||||
|
const results = [];
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
for ( let IdxGen of good_indices ) {
|
for ( let IdxGen of good_indices ) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
@ -35,30 +36,35 @@ $262.agent.start(`
|
|||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
$262.agent.report("C " + (await Atomics.waitAsync(view, Idx, 0).value));
|
results.push(await Atomics.waitAsync(view, Idx, 0).value);
|
||||||
}
|
}
|
||||||
$262.agent.report("done");
|
$262.agent.report("C " + results.join(","));
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
})();
|
})();
|
||||||
`);
|
`);
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
$262.agent.getReport(),
|
Promise.all([
|
||||||
|
$262.agent.getReportAsync(),
|
||||||
|
$262.agent.getReportAsync(),
|
||||||
|
$262.agent.getReportAsync(),
|
||||||
|
]).then(outcomes => {
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
outcomes[0],
|
||||||
'A timed-out',
|
'A timed-out',
|
||||||
'"A " + (await Atomics.waitAsync(view, 0, 0, 0).value resolves to "A timed-out"'
|
'"A " + (await Atomics.waitAsync(view, 0, 0, 0).value resolves to "A timed-out"'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
$262.agent.getReport(),
|
outcomes[1],
|
||||||
'B not-equal',
|
'B not-equal',
|
||||||
'"B " + (await Atomics.waitAsync(view, 0, 37, 0).value resolves to "B not-equal"'
|
'"B " + (await Atomics.waitAsync(view, 0, 37, 0).value resolves to "B not-equal"'
|
||||||
);
|
|
||||||
|
|
||||||
var r;
|
|
||||||
while ((r = $262.agent.getReport()) !== "done") {
|
|
||||||
assert.sameValue(
|
|
||||||
r,
|
|
||||||
'C not-equal',
|
|
||||||
'"C " + (await Atomics.waitAsync(view, Idx, 0).value resolves to "C not-equal"'
|
|
||||||
);
|
);
|
||||||
}
|
assert.sameValue(
|
||||||
|
outcomes[2],
|
||||||
|
'C not-equal,not-equal,not-equal,not-equal,not-equal',
|
||||||
|
'All C values are not equal'
|
||||||
|
);
|
||||||
|
}, $DONE).then($DONE, $DONE);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ info: |
|
|||||||
|
|
||||||
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics]
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -17,6 +17,7 @@ info: |
|
|||||||
flags: [async]
|
flags: [async]
|
||||||
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, destructuring-binding, arrow-function]
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, destructuring-binding, arrow-function]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -21,6 +21,7 @@ info: |
|
|||||||
|
|
||||||
features: [Atomics.waitAsync, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray, arrow-function, SharedArrayBuffer, Atomics]
|
features: [Atomics.waitAsync, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray, arrow-function, SharedArrayBuffer, Atomics]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const poisoned = {
|
const poisoned = {
|
||||||
valueOf() {
|
valueOf() {
|
||||||
throw new Test262Error('should not evaluate this code');
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
@ -20,6 +20,7 @@ info: |
|
|||||||
|
|
||||||
features: [Atomics.waitAsync, ArrayBuffer, Atomics, TypedArray, arrow-function]
|
features: [Atomics.waitAsync, ArrayBuffer, Atomics, TypedArray, arrow-function]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
@ -31,9 +32,9 @@ const poisoned = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
assert.throws(TypeError, () => {
|
||||||
Atomics.wait(i32a, 0, 0, 0);
|
Atomics.waitAsync(i32a, 0, 0, 0);
|
||||||
}, '`Atomics.wait(i32a, 0, 0, 0)` throws TypeError');
|
}, '`Atomics.waitAsync(i32a, 0, 0, 0)` throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
assert.throws(TypeError, () => {
|
||||||
Atomics.wait(i32a, poisoned, poisoned, poisoned);
|
Atomics.waitAsync(i32a, poisoned, poisoned, poisoned);
|
||||||
}, '`Atomics.wait(i32a, poisoned, poisoned, poisoned)` throws TypeError');
|
}, '`Atomics.waitAsync(i32a, poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
@ -24,6 +24,7 @@ info: |
|
|||||||
|
|
||||||
features: [Atomics.waitAsync, arrow-function, Atomics]
|
features: [Atomics.waitAsync, arrow-function, Atomics]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const poisoned = {
|
const poisoned = {
|
||||||
valueOf() {
|
valueOf() {
|
||||||
throw new Test262Error('should not evaluate this code');
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
@ -24,6 +24,7 @@ info: |
|
|||||||
|
|
||||||
features: [Atomics.waitAsync, Symbol, arrow-function, Atomics]
|
features: [Atomics.waitAsync, Symbol, arrow-function, Atomics]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const poisoned = {
|
const poisoned = {
|
||||||
valueOf() {
|
valueOf() {
|
||||||
throw new Test262Error('should not evaluate this code');
|
throw new Test262Error('should not evaluate this code');
|
||||||
|
@ -25,6 +25,7 @@ info: |
|
|||||||
includes: [detachArrayBuffer.js]
|
includes: [detachArrayBuffer.js]
|
||||||
features: [Atomics.waitAsync, ArrayBuffer, Atomics, TypedArray]
|
features: [Atomics.waitAsync, ArrayBuffer, Atomics, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -22,6 +22,7 @@ info: |
|
|||||||
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, arrow-function]
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, arrow-function]
|
||||||
flags: [async]
|
flags: [async]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -20,6 +20,7 @@ info: |
|
|||||||
5. If accessIndex ≥ length, throw a RangeError exception.
|
5. If accessIndex ≥ length, throw a RangeError exception.
|
||||||
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics]
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -18,6 +18,7 @@ info: |
|
|||||||
|
|
||||||
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics]
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -22,6 +22,7 @@ info: |
|
|||||||
|
|
||||||
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics]
|
features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -19,6 +19,7 @@ info: |
|
|||||||
flags: [async]
|
flags: [async]
|
||||||
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -22,6 +22,7 @@ flags: [async]
|
|||||||
includes: [atomicsHelper.js]
|
includes: [atomicsHelper.js]
|
||||||
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
@ -23,6 +23,7 @@ info: |
|
|||||||
flags: [async]
|
flags: [async]
|
||||||
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, computed-property-names, Symbol, Symbol.toPrimitive, Atomics, arrow-function]
|
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, computed-property-names, Symbol, Symbol.toPrimitive, Atomics, arrow-function]
|
||||||
---*/
|
---*/
|
||||||
|
assert.sameValue(typeof Atomics.waitAsync, 'function');
|
||||||
const i32a = new Int32Array(
|
const i32a = new Int32Array(
|
||||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user