Atomics: moves getReport and waitUntil into atomicsHelper.js; broad updates to all Atomics.wait tests

This commit is contained in:
Rick Waldron 2018-05-21 14:23:15 -04:00
parent daa9af846d
commit 7f3a1c1be9
111 changed files with 1215 additions and 1529 deletions

View File

@ -1,9 +1,50 @@
// Copyright (C) 2017 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: |
The amount of slack allowed for testing time-related Atomics methods (i.e.
wait and wake). The absolute value of the difference of the observed time
and the expected time must be epsilon-close.
description: >
Collection of functions used to interact with Atomics.* operations across agent boundaries.
---*/
var helper = helper || {};
/**
* The amount of slack allowed for testing time-related Atomics methods (i.e. wait and wake).
* The absolute value of the difference of the observed time and the expected time must
* be epsilon-close.
*/
var $ATOMICS_MAX_TIME_EPSILON = 100;
/**
*
* @return {[type]} [description]
*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
/**
* With a given Int32Array, wait until the expected number of agents have reported themselves by
* calling:
*
* Atomics.add(i32a, index, 1);
*
* @param {Int32Array} i32a An Int32Array with a SharedArrayBuffer
* @param {Number} index The index of which all agents will report.
* @param {Number} expected The number of agents that are expected to report as active.
*/
function waitUntil(i32a, index, expected ) {
var i = 0;
while (Atomics.load(i32a, index) !== expected && i < 15) {
$262.agent.sleep(10);
i++;
}
const agents = Atomics.load(i32a, index);
assert.sameValue(agents, expected , `'agents' equals the value of expected (${expected })`);
}
helper.getReport = getReport;
helper.waitUntil = waitUntil;

View File

@ -1,3 +1,4 @@
atomicsHelper: [Atomics]
typeCoercion.js: [Symbol.toPrimitive, BigInt]
testAtomics.js: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, arrow-function, let, for-of]
testBigIntTypedArray.js: [BigInt, TypedArray]

View File

@ -17,7 +17,7 @@ function testWithAtomicsOutOfBoundsIndices(f) {
var bad_indices = [
(view) => -1,
(view) => view.length,
(view) => view.length*2,
(view) => view.length * 2,
(view) => Number.POSITIVE_INFINITY,
(view) => Number.NEGATIVE_INFINITY,
(view) => ({ valueOf: () => 125 }),
@ -28,7 +28,7 @@ function testWithAtomicsOutOfBoundsIndices(f) {
try {
f(IdxGen);
} catch (e) {
e.message += " (Testing with index gen " + IdxGen + ".)";
e.message += ' (Testing with index gen ' + IdxGen + '.)';
throw e;
}
}
@ -52,7 +52,7 @@ function testWithAtomicsInBoundsIndices(f) {
(view) => 0.5,
(view) => '0.5',
(view) => -0.9,
(view) => ({ password: "qumquat" }),
(view) => ({ password: 'qumquat' }),
(view) => view.length - 1,
(view) => ({ valueOf: () => 0 }),
(view) => ({ toString: () => '0', valueOf: false }) // non-callable valueOf triggers invocation of toString
@ -62,7 +62,7 @@ function testWithAtomicsInBoundsIndices(f) {
try {
f(IdxGen);
} catch (e) {
e.message += " (Testing with index gen " + IdxGen + ".)";
e.message += ' (Testing with index gen ' + IdxGen + '.)';
throw e;
}
}
@ -85,21 +85,21 @@ function testWithAtomicsNonViewValues(f) {
10,
3.14,
new Number(4),
"Hi there",
'Hi there',
new Date,
/a*utomaton/g,
{ password: "qumquat" },
{ password: 'qumquat' },
new DataView(new ArrayBuffer(10)),
new ArrayBuffer(128),
new SharedArrayBuffer(128),
new Error("Ouch"),
new Error('Ouch'),
[1,1,2,3,5,8],
((x) => -x),
new Map(),
new Set(),
new WeakMap(),
new WeakSet(),
Symbol("halleluja"),
Symbol('halleluja'),
// TODO: Proxy?
Object,
Int32Array,
@ -112,8 +112,9 @@ function testWithAtomicsNonViewValues(f) {
try {
f(nonView);
} catch (e) {
e.message += " (Testing with non-view value " + nonView + ".)";
e.message += ' (Testing with non-view value ' + nonView + '.)';
throw e;
}
}
}

View File

@ -15,8 +15,9 @@ includes: [testAtomics.js]
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/
var sab = new SharedArrayBuffer(8);
let i32a = new Int32Array(sab);
var i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
assert.throws(RangeError, function() {

View File

@ -2,9 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wake
esid: sec-atomics.wait
description: >
Test range checking of Atomics.wake on arrays that allow atomic operations
Test range checking of Atomics.wait on arrays that allow atomic operations
info: |
Atomics.wait( typedArray, index, value, timeout )
@ -15,8 +15,9 @@ includes: [testAtomics.js]
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/
var sab = new SharedArrayBuffer(8);
let i64a = new BigInt64Array(sab);
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
assert.throws(RangeError, function() {

View File

@ -18,8 +18,9 @@ features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
flags: [CanBlockIsFalse]
---*/
var buffer = new SharedArrayBuffer(8);
var i64a = new BigInt64Array(buffer);
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
);
assert.throws(TypeError, function() {
Atomics.wait(i64a, 0, 0, 0);

View File

@ -12,37 +12,30 @@ info: |
Boolean -> If argument is true, return 1. If argument is false, return +0.
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
var valueOf = {
const valueOf = {
valueOf: function() {
return false;
}
};
var toPrimitive = {
const toPrimitive = {
[Symbol.toPrimitive]: function() {
return false;
}
};
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
var start = $262.agent.monotonicNow();
const i64a = new BigInt64Array(sab);
const before = $262.agent.monotonicNow();
$262.agent.report(Atomics.wait(i64a, 0, 0, false));
$262.agent.report(Atomics.wait(i64a, 0, 0, valueOf));
$262.agent.report(Atomics.wait(i64a, 0, 0, toPrimitive));
$262.agent.report($262.agent.monotonicNow() - start);
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.leaving();
});
`);
@ -58,11 +51,14 @@ assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
var lapse = getReport();
assert(lapse >= 0, 'timeout should be a min of 0ms');
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
const lapse = getReport();
assert(
lapse >= 0,
`${lapse} should be greater than, or equal to 0`
);
assert(
lapse <= $ATOMICS_MAX_TIME_EPSILON,
`${lapse} should be less than ${$ATOMICS_MAX_TIME_EPSILON}`
);
assert.sameValue(Atomics.wake(i64a, 0), 0);

View File

@ -16,16 +16,17 @@ features: [Atomics, BigInt, SharedArrayBuffer, Symbol, Symbol.toPrimitive, Typed
flags: [CanBlockIsFalse]
---*/
var buffer = new SharedArrayBuffer(1024);
var i64a = new BigInt64Array(buffer);
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
);
var valueOf = {
const valueOf = {
valueOf: function() {
return false;
}
};
var toPrimitive = {
const toPrimitive = {
[Symbol.toPrimitive]: function() {
return false;
}

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wait
description: >
Test Atomics.wait on arrays that allow atomic operations,
in an Agent that is allowed to wait.
includes: [atomicsHelper.js]
features: [Atomics, BigInt]
---*/
@ -13,17 +14,17 @@ features: [Atomics, BigInt]
// even in the shell.
$262.agent.start(`
var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16);
const sab = new SharedArrayBuffer(1024);
const ab = new ArrayBuffer(16);
var good_indices = [ (view) => 0/-1, // -0
const 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);
const view = new BigInt64Array(sab, 32, 20);
view[0] = 0;
$262.agent.report("A " + Atomics.wait(view, 0, 0, 0))
@ -45,15 +46,8 @@ $262.agent.start(`
assert.sameValue(getReport(), "A timed-out");
assert.sameValue(getReport(), "B not-equal"); // Even with zero timeout
var r;
while ((r = getReport()) != "done") {
assert.sameValue(r, "C not-equal");
}
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}

View File

@ -13,20 +13,13 @@ info: |
Undefined Return NaN.
5.If q is NaN, let t be +, else let t be max(q, 0)
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
const i64a = new BigInt64Array(sab);
$262.agent.report(Atomics.wait(i64a, 0, 0, NaN)); // NaN => +Infinity
$262.agent.leaving();
});
@ -39,4 +32,4 @@ const i64a = new BigInt64Array(
$262.agent.broadcast(i64a.buffer);
$262.agent.sleep(100);
assert.sameValue(Atomics.wake(i64a, 0), 1);
assert.sameValue(getReport(), "ok");
assert.sameValue(getReport(), 'ok');

View File

@ -21,7 +21,7 @@ const i64a = new BigInt64Array(
);
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};

View File

@ -5,21 +5,14 @@
esid: sec-atomics.wait
description: >
Test that Atomics.wait times out with a negative timeout
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab, id) {
var ia = new BigInt64Array(sab);
$262.agent.report(Atomics.wait(ia, 0, 0, -5)); // -5 => 0
const i64a = new BigInt64Array(sab);
$262.agent.report(Atomics.wait(i64a, 0, 0, -5)); // -5 => 0
$262.agent.leaving();
});
`);
@ -29,5 +22,6 @@ const i64a = new BigInt64Array(
);
$262.agent.broadcast(i64a.buffer);
assert.sameValue(getReport(), "timed-out");
$262.agent.sleep(10);
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(Atomics.wake(i64a, 0), 0);

View File

@ -1,4 +1,4 @@
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
@ -12,23 +12,18 @@ description: >
a. Assert: W is not on the list of waiters in WL.
19. Else,
a.Perform RemoveWaiter(WL, W).
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 500;
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab, id) {
const i64a = new BigInt64Array(sab);
const then = $262.agent.monotonicNow();
$262.agent.report(Atomics.wait(i64a, 0, 0, 500)); // Timeout 500ms
$262.agent.report($262.agent.monotonicNow() - then); // Actual time can be more than 500ms
const before = $262.agent.monotonicNow();
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.report(unpark);
$262.agent.leaving();
});
`);
@ -39,6 +34,13 @@ const i64a = new BigInt64Array(
$262.agent.broadcast(i64a.buffer);
$262.agent.sleep(100);
assert.sameValue(getReport(), "timed-out");
assert.sameValue((getReport() | 0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true);
// NO OPERATION OCCURS HERE!
const lapse = getReport();
assert(
lapse >= TIMEOUT,
`${lapse} should be at least ${TIMEOUT}`
);
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(Atomics.wake(i64a, 0), 0);

View File

@ -4,16 +4,10 @@
/*---
esid: sec-atomics.wait
description: >
Demonstrates that Atomics.store(...) is causing a waiting
features: [Atomics, SharedArrayBuffer, TypedArray]
Waiter does not spuriously wake on index which is subject to Add operation
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i64a = new BigInt64Array(
@ -22,9 +16,9 @@ const i64a = new BigInt64Array(
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
var before = $262.agent.monotonicNow();
var unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
const i64a = new BigInt64Array(sab);
const before = $262.agent.monotonicNow();
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.report(unpark);
$262.agent.leaving();

View File

@ -5,16 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to And operation
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [testAtomics.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)

View File

@ -5,16 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to compareExchange operation
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [testAtomics.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)

View File

@ -5,16 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to exchange operation
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [testAtomics.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)

View File

@ -5,16 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to Or operation
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [testAtomics.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)

View File

@ -5,16 +5,9 @@
esid: sec-atomics.wait
description: >
Demonstrates that Atomics.store(...) is causing a waiting
includes: [testAtomics.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)

View File

@ -5,16 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to Sub operation
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [testAtomics.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)

View File

@ -5,16 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to xor operation
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [testAtomics.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)

View File

@ -2,27 +2,42 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
esid: sec-validatesharedintegertypedarray
description: >
Throws a TypeError if typedArray arg is not an BigInt64Array
Throws a TypeError if typedArray arg is not a BigInt64Array
info: |
Atomics.wait( typedArray, index, value, timeout )
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
...
5.If onlyBigInt64 is true, then
If typeName is not "BigInt64Array" or "BigInt64Array", throw a TypeError exception.
features: [Atomics, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray]
ValidateSharedIntegerTypedArray(typedArray [ , waitable ] )
...
5. If waitable is true, then
a. If typeName is not "Int32Array" or "BigInt64Array",
throw a TypeError exception.
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
includes: [testAtomics.js, testBigIntTypedArray.js]
---*/
var poisoned = {
const i64a = new BigUint64Array(
new SharedArrayBuffer(BigUint64Array.BYTES_PER_ELEMENT)
);
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.wait(new BigUint64Array(), poisoned, poisoned, poisoned);
Atomics.wait(i64a, 0, 0, 0);
}, 'BigUint64Array');
assert.throws(TypeError, function() {
Atomics.wait(i64a, poisoned, poisoned, poisoned);
}, 'BigUint64Array');

View File

@ -15,17 +15,20 @@ info: |
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
var i64a = new BigInt64Array(new ArrayBuffer(4));
var poisoned = {
const i64a = new BigInt64Array(
new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
);
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.wait(i64a, 0, 0, 0);
});
}, 'Atomics.wait(i64a, 0, 0, 0) on ArrayBuffer throws TypeError');
assert.throws(TypeError, function() {
Atomics.wait(i64a, poisoned, poisoned, poisoned);
});
}, 'Atomics.wait(i64a, poisoned, poisoned, poisoned) on ArrayBuffer throws TypeError');

View File

@ -8,23 +8,38 @@ info: |
Atomics.wait( typedArray, index, value, timeout )
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
...
ValidateSharedIntegerTypedArray(typedArray [ , onlyInt32 ] )
...
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
IsSharedArrayBuffer( obj )
...
3.If bufferData is null, return false.
includes: [detachArrayBuffer.js]
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
var i64a = new BigInt64Array(new ArrayBuffer(1024));
var poisoned = {
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
);
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
$DETACHBUFFER(i64a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
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.wait(i64a, poisoned, poisoned, poisoned);
});
}, 'Atomics.wait(i64a, poisoned, poisoned, poisoned) on detached buffer throwes TypeError');

View File

@ -22,7 +22,7 @@ const i64a = new BigInt64Array(
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};

View File

@ -14,22 +14,15 @@ info: |
a.Perform LeaveCriticalSection(WL).
b. Return the String "not-equal".
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
var value = 42;
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
const i64a = new BigInt64Array(sab);
$262.agent.report(Atomics.store(i64a, 0, ${value}));
$262.agent.report(Atomics.wait(i64a, 0, 0));

View File

@ -18,19 +18,13 @@ info: |
...
4. Return the WaiterList that is referenced by the pair (block, i).
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
const i64a = new BigInt64Array(sab);
// Wait on index 0
Atomics.wait(i64a, 0, 0, 200);
@ -41,7 +35,7 @@ $262.agent.start(`
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
const i64a = new BigInt64Array(sab);
// Wait on index 2
Atomics.wait(i64a, 2, 0, 200);
@ -59,9 +53,9 @@ $262.agent.sleep(10);
// Wake index 2
Atomics.wake(i64a, 2, 1);
assert.sameValue(getReport(), "2");
assert.sameValue(getReport(), '2');
// Wake index 0
Atomics.wake(i64a, 2, 1);
assert.sameValue(getReport(), "0");
Atomics.wake(i64a, 0, 1);
assert.sameValue(getReport(), '0');

View File

@ -12,78 +12,66 @@ info: |
...
3.Add W to the end of the list of waiters in WL.
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
var agent1 = '1';
var agent2 = '2';
var agent3 = '3';
const agent1 = '1';
const agent2 = '2';
const agent3 = '3';
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i64a = new BigInt64Array(sab);
$262.agent.report(${agent1});
Atomics.wait(i64a, 0, 0);
$262.agent.report(Atomics.wait(i64a, 1, 0));
$262.agent.report(${agent1});
$262.agent.leaving();
})
});
`);
$262.agent.start(
`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
const i64a = new BigInt64Array(sab);
$262.agent.report(${agent2});
Atomics.wait(i64a, 0, 0);
$262.agent.report(Atomics.wait(i64a, 2, 0));
$262.agent.report(${agent2});
$262.agent.leaving();
})
});
`);
$262.agent.start(
`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
const i64a = new BigInt64Array(sab);
$262.agent.report(${agent3});
Atomics.wait(i64a, 0, 0);
$262.agent.report(Atomics.wait(i64a, 3, 0));
$262.agent.report(${agent3});
$262.agent.leaving();
})
});
`);
var i64a = new BigInt64Array(new SharedArrayBuffer(4));
const i64a = new BigInt64Array(
new SharedArrayBuffer(4 * BigInt64Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i64a.buffer);
$262.agent.sleep(500);
var orderWhichAgentsWereStarted = getReport() + getReport() + getReport(); // can be started in any order
// Agents may be started in any order...
const started = [getReport(), getReport(), getReport()];
assert.sameValue(Atomics.wake(i64a, 0, 1), 1);
// Agents must wake in the order they waited
assert.sameValue(Atomics.wake(i64a, 1, 1), 1);
assert.sameValue(getReport(), 'ok');
assert.sameValue(getReport(), started[0]);
var orderAgentsWereWoken = getReport();
assert.sameValue(Atomics.wake(i64a, 2, 1), 1);
assert.sameValue(getReport(), 'ok');
assert.sameValue(getReport(), started[1]);
assert.sameValue(Atomics.wake(i64a, 0, 1), 1);
orderAgentsWereWoken += getReport();
assert.sameValue(Atomics.wake(i64a, 0, 1), 1);
orderAgentsWereWoken += getReport();
assert.sameValue(orderWhichAgentsWereStarted, orderAgentsWereWoken); // agents should wake in the same order as they were started FIFO
assert.sameValue(Atomics.wake(i64a, 3, 1), 1);
assert.sameValue(getReport(), 'ok');
assert.sameValue(getReport(), started[2]);

View File

@ -18,38 +18,39 @@ info: |
If value is undefined, then
Let index be 0.
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
var sleeping = 10;
var timeout = 20000;
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
sleeping += 10;
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
$262.agent.report(Atomics.wait(i64a, 0, 0, ${timeout}));
$262.agent.receiveBroadcast(function(sab) {
const i64a = new BigInt64Array(sab);
const before = $262.agent.monotonicNow();
const unpark = Atomics.wait(i64a, 0, 0, ${timeout});
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.report(unpark);
$262.agent.leaving();
});
});
`);
var sab = new SharedArrayBuffer(4);
var i64a = new BigInt64Array(sab);
const i64a = new BigInt64Array(
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i64a.buffer);
$262.agent.sleep(sleeping);
assert.sameValue(Atomics.wake(i64a, 0), 1);
assert.sameValue(getReport(), "ok");
assert(sleeping < timeout, "this test assumes it won't last for more than 20 seconds");
const lapse = getReport();
assert(
sleeping + lapse < timeout,
`${sleeping + lapse} should be less than ${timeout}`
);
assert.sameValue(getReport(), 'ok');

View File

@ -1,32 +0,0 @@
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
Test that Atomics.wait returns the right result when it was awoken.
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab, id) {
var i64a = new BigInt64Array(sab);
$262.agent.report(Atomics.wait(i64a, 0, 0)); // No timeout => Infinity
$262.agent.leaving();
});
`);
var i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(i64a.buffer);
$262.agent.sleep(50); // Give the agent a chance to wait
Atomics.wake(i64a, 0);
assert.sameValue(getReport(), "ok");

View File

@ -18,8 +18,9 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
flags: [CanBlockIsFalse]
---*/
var buffer = new SharedArrayBuffer(4);
var i32a = new Int32Array(buffer);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
assert.throws(TypeError, function() {
Atomics.wait(i32a, 0, 0, 0);

View File

@ -1,42 +0,0 @@
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
Test that Atomics.wait returns the right result when it timed out and that
the time to time out is reasonable.
info: |
17. Let awoken be Suspend(WL, W, t).
18. If awoken is true, then
a. Assert: W is not on the list of waiters in WL.
19. Else,
a.Perform RemoveWaiter(WL, W).
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab, id) {
var i32a = new Int32Array(sab);
var before = $262.agent.monotonicNow();
$262.agent.report(Atomics.wait(i32a, 0, 0, 500)); // Timeout 500ms
$262.agent.report($262.agent.monotonicNow() - before); // Actual time can be more than 500ms
$262.agent.leaving();
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(i32a.buffer);
assert.sameValue(getReport(), "timed-out");
assert.sameValue((getReport() | 0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true);

View File

@ -12,40 +12,32 @@ info: |
Boolean -> If argument is true, return 1. If argument is false, return +0.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
var valueOf = {
const valueOf = {
valueOf: function() {
return false;
}
};
};
var toPrimitive = {
const toPrimitive = {
[Symbol.toPrimitive]: function() {
return false;
}
};
};
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
var before = $262.agent.monotonicNow();
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
const before = $262.agent.monotonicNow();
$262.agent.report(Atomics.wait(i32a, 0, 0, false));
$262.agent.report(Atomics.wait(i32a, 0, 0, valueOf));
$262.agent.report(Atomics.wait(i32a, 0, 0, toPrimitive));
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.leaving();
});
});
`);
const i32a = new Int32Array(

View File

@ -32,7 +32,7 @@ const toPrimitive = {
}
};
assert.sameValue(Atomics.wait(i32a, 0, 0, false), "timed-out");
assert.sameValue(Atomics.wait(i32a, 0, 0, valueOf), "timed-out");
assert.sameValue(Atomics.wait(i32a, 0, 0, toPrimitive), "timed-out");
assert.sameValue(Atomics.wait(i32a, 0, 0, false), 'timed-out');
assert.sameValue(Atomics.wait(i32a, 0, 0, valueOf), 'timed-out');
assert.sameValue(Atomics.wait(i32a, 0, 0, toPrimitive), 'timed-out');

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wait
description: >
Test Atomics.wait on arrays that allow atomic operations,
in an Agent that is allowed to wait.
includes: [atomicsHelper.js]
features: [Atomics]
---*/
@ -13,47 +14,40 @@ features: [Atomics]
// even in the shell.
$262.agent.start(`
var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16);
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) => view.length - 1,
(view) => ({ valueOf: () => 0 }),
(view) => ({ toString: () => '0', valueOf: false }) // non-callable valueOf triggers invocation of toString
];
var view = new Int32Array(sab, 32, 20);
var view = new Int32Array(sab, 32, 20);
view[0] = 0;
$262.agent.report("A " + Atomics.wait(view, 0, 0, 0))
$262.agent.report("B " + Atomics.wait(view, 0, 37, 0));
view[0] = 0;
$262.agent.report("A " + Atomics.wait(view, 0, 0, 0))
$262.agent.report("B " + Atomics.wait(view, 0, 37, 0));
// In-bounds boundary cases for indexing
for ( let IdxGen of good_indices ) {
// In-bounds boundary cases for indexing
for ( let IdxGen of good_indices ) {
let Idx = IdxGen(view);
view.fill(0);
// Atomics.store() computes an index from Idx in the same way as other
// Atomics operations, not quite like view[Idx].
Atomics.store(view, Idx, 37);
$262.agent.report("C " + Atomics.wait(view, Idx, 0));
}
}
$262.agent.report("done");
$262.agent.leaving();
$262.agent.report("done");
$262.agent.leaving();
`);
assert.sameValue(getReport(), "A timed-out");
assert.sameValue(getReport(), "B not-equal"); // Even with zero timeout
assert.sameValue(getReport(), 'A timed-out');
assert.sameValue(getReport(), 'B not-equal'); // Even with zero timeout
var r;
while ((r = getReport()) != "done") {
assert.sameValue(r, "C not-equal");
}
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}

View File

@ -13,26 +13,21 @@ info: |
Undefined Return NaN.
5.If q is NaN, let t be +, else let t be max(q, 0)
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(i32a, 0, 0, NaN)); // NaN => +Infinity
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(500); // Ample time

View File

@ -13,14 +13,18 @@ info: |
2.Let accessIndex be ? ToIndex(requestIndex).
...
2.b If integerIndex < 0, throw a RangeError exception
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);
var i32a = new Int32Array(sab);
var poisoned = {
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};

View File

@ -5,28 +5,24 @@
esid: sec-atomics.wait
description: >
Test that Atomics.wait times out with a negative timeout
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab, id) {
var ia = new Int32Array(sab);
$262.agent.report(Atomics.wait(ia, 0, 0, -5)); // -5 => 0
$262.agent.receiveBroadcast(function(sab, id) {
var i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(i32a, 0, 0, -5)); // -5 => 0
$262.agent.leaving();
})
});
`);
var buffer = new SharedArrayBuffer(1024);
var i32a = new Int32Array(buffer);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
assert.sameValue(getReport(), "timed-out");
$262.agent.sleep(100);
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(Atomics.wake(i32a, 0), 0);

View File

@ -9,7 +9,8 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
flags: [CanBlockIsFalse]
---*/
var buffer = new SharedArrayBuffer(1024);
var i32a = new Int32Array(buffer);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
assert.sameValue(Atomics.wait(i32a, 0, 0, -1), "timed-out");

View File

@ -5,15 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to Add operation
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i32a = new Int32Array(
@ -22,9 +16,9 @@ const i32a = new Int32Array(
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
var before = $262.agent.monotonicNow();
var unpark = Atomics.wait(i32a, 0, 0, ${TIMEOUT});
const i32a = new Int32Array(sab);
const before = $262.agent.monotonicNow();
const unpark = Atomics.wait(i32a, 0, 0, ${TIMEOUT});
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.report(unpark);
$262.agent.leaving();

View File

@ -5,15 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to And operation
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i32a = new Int32Array(

View File

@ -5,15 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to compareExchange operation
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i32a = new Int32Array(

View File

@ -5,15 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to exchange operation
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i32a = new Int32Array(

View File

@ -5,15 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to Or operation
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i32a = new Int32Array(

View File

@ -5,15 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to Store operation
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i32a = new Int32Array(

View File

@ -5,15 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to Sub operation
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i32a = new Int32Array(

View File

@ -5,15 +5,9 @@
esid: sec-atomics.wait
description: >
Waiter does not spuriously wake on index which is subject to xor operation
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const TIMEOUT = 2000;
const i32a = new Int32Array(

View File

@ -15,40 +15,64 @@ info: |
features: [Atomics, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray]
---*/
var poisoned = {
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.wait(new Float64Array(), poisoned, poisoned, poisoned);
const view = new Float64Array(
new SharedArrayBuffer(Float64Array.BYTES_PER_ELEMENT)
);
Atomics.wait(view, poisoned, poisoned, poisoned);
}, 'Float64Array');
assert.throws(TypeError, function() {
Atomics.wait(new Float32Array(), poisoned, poisoned, poisoned);
const view = new Float32Array(
new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT)
);
Atomics.wait(view, poisoned, poisoned, poisoned);
}, 'Float32Array');
assert.throws(TypeError, function() {
Atomics.wait(new Int16Array(), poisoned, poisoned, poisoned);
const view = new Int16Array(
new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT)
);
Atomics.wait(view, poisoned, poisoned, poisoned);
}, 'Int16Array');
assert.throws(TypeError, function() {
Atomics.wait(new Int8Array(), poisoned, poisoned, poisoned);
const view = new Int8Array(
new SharedArrayBuffer(Int8Array.BYTES_PER_ELEMENT)
);
Atomics.wait(view, poisoned, poisoned, poisoned);
}, 'Int8Array');
assert.throws(TypeError, function() {
Atomics.wait(new Uint32Array(), poisoned, poisoned, poisoned);
const view = new Uint32Array(
new SharedArrayBuffer(Uint32Array.BYTES_PER_ELEMENT)
);
Atomics.wait(view, poisoned, poisoned, poisoned);
}, 'Uint32Array');
assert.throws(TypeError, function() {
Atomics.wait(new Uint16Array(), poisoned, poisoned, poisoned);
const view = new Uint16Array(
new SharedArrayBuffer(Uint16Array.BYTES_PER_ELEMENT)
);
Atomics.wait(view, poisoned, poisoned, poisoned);
}, 'Uint16Array');
assert.throws(TypeError, function() {
Atomics.wait(new Uint8Array(), poisoned, poisoned, poisoned);
const view = new Uint8Array(
new SharedArrayBuffer(Uint8Array.BYTES_PER_ELEMENT)
);
Atomics.wait(view, poisoned, poisoned, poisoned);
}, 'Uint8Array');
assert.throws(TypeError, function() {
Atomics.wait(new Uint8ClampedArray(), poisoned, poisoned, poisoned);
const view = new Uint8ClampedArray(
new SharedArrayBuffer(Uint8ClampedArray.BYTES_PER_ELEMENT)
);
Atomics.wait(view, poisoned, poisoned, poisoned);
}, 'Uint8ClampedArray');

View File

@ -15,10 +15,13 @@ info: |
features: [ArrayBuffer, Atomics, TypedArray]
---*/
var i32a = new Int32Array(new ArrayBuffer(4));
var poisoned = {
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};

View File

@ -16,7 +16,7 @@ features: [Atomics]
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};

View File

@ -15,7 +15,7 @@ features: [Atomics, Symbol]
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
@ -41,7 +41,7 @@ assert.throws(TypeError, function() {
assert.throws(TypeError, function() {
Atomics.wait(Number.NEGATIVE_INFINITY, poisoned, poisoned, poisoned);
}, '-Infinity');
}, 'Number.NEGATIVE_INFINITY');
assert.throws(TypeError, function() {
Atomics.wait(Symbol('***symbol***'), poisoned, poisoned, poisoned);

View File

@ -16,14 +16,21 @@ includes: [detachArrayBuffer.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
var i32a = new Int32Array(new ArrayBuffer(1024));
var poisoned = {
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
$DETACHBUFFER(i32a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
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.wait(i32a, poisoned, poisoned, poisoned);

View File

@ -12,44 +12,37 @@ info: |
Null -> Return +0.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(
`
var valueOf = {
$262.agent.start(`
const valueOf = {
valueOf: function() {
return null;
}
};
};
var toPrimitive = {
const toPrimitive = {
[Symbol.toPrimitive]: function() {
return null;
}
};
};
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
var before = $262.agent.monotonicNow();
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
const before = $262.agent.monotonicNow();
$262.agent.report(Atomics.wait(i32a, 0, 0, null));
$262.agent.report(Atomics.wait(i32a, 0, 0, valueOf));
$262.agent.report(Atomics.wait(i32a, 0, 0, toPrimitive));
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(150);
@ -58,11 +51,11 @@ assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
var timeDiffReport = getReport();
const lapse = getReport();
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
assert(lapse >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $ATOMICS_MAX_TIME_EPSILON');
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(i32a, 0), 0);

View File

@ -16,16 +16,17 @@ features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
flags: [CanBlockIsFalse]
---*/
var buffer = new SharedArrayBuffer(1024);
var i32a = new Int32Array(buffer);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
var valueOf = {
const valueOf = {
valueOf: function() {
return null;
}
};
var toPrimitive = {
const toPrimitive = {
[Symbol.toPrimitive]: function() {
return null;
}

View File

@ -12,51 +12,42 @@ info: |
Null -> Return +0.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(
`
var valueOf = {
$262.agent.start(`
const valueOf = {
valueOf: function() {
return 0;
}
};
};
var toString = {
const toString = {
toString: function() {
return "0";
}
};
};
var toPrimitive = {
const toPrimitive = {
[Symbol.toPrimitive]: function() {
return 0;
}
};
};
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
var start = $262.agent.monotonicNow();
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
const before = $262.agent.monotonicNow();
$262.agent.report(Atomics.wait(i32a, 0, 0, valueOf));
$262.agent.report(Atomics.wait(i32a, 0, 0, toString));
$262.agent.report(Atomics.wait(i32a, 0, 0, toPrimitive));
$262.agent.report($262.agent.monotonicNow() - start);
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(150);
@ -65,11 +56,11 @@ assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
var timeDiffReport = getReport();
var lapse = getReport();
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
assert(lapse >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(i32a, 0), 0);

View File

@ -15,31 +15,33 @@ info: |
Let primValue be ? ToPrimitive(argument, hint Number).
Return ? ToNumber(primValue).
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
flags: [CanBlockIsFalse]
---*/
var buffer = new SharedArrayBuffer(1024);
var i32a = new Int32Array(buffer);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
var valueOf = {
const valueOf = {
valueOf: function() {
return 0;
}
};
var toString = {
const toString = {
toString: function() {
return "0";
}
};
var toPrimitive = {
const toPrimitive = {
[Symbol.toPrimitive]: function() {
return 0;
}
};
assert.sameValue(Atomics.wait(i32a, 0, 0, valueOf), "timed-out");
assert.sameValue(Atomics.wait(i32a, 0, 0, toString), "timed-out");
assert.sameValue(Atomics.wait(i32a, 0, 0, toPrimitive), "timed-out");
assert.sameValue(Atomics.wait(i32a, 0, 0, valueOf), 'timed-out');
assert.sameValue(Atomics.wait(i32a, 0, 0, toString), 'timed-out');
assert.sameValue(Atomics.wait(i32a, 0, 0, toPrimitive), 'timed-out');

View File

@ -16,11 +16,13 @@ info: |
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
var i32a = new Int32Array(new SharedArrayBuffer(4));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
var poisoned = {
const poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};

View File

@ -12,35 +12,26 @@ info: |
Null -> Return +0.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(
`
var poisonedValueOf = {
$262.agent.start(`
const poisonedValueOf = {
valueOf: function() {
throw new Error("should not evaluate this code");
}
};
};
var poisonedToPrimitive = {
const poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Error("passing a poisoned object using @@ToPrimitive");
}
};
};
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
var start = $262.agent.monotonicNow();
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
const start = $262.agent.monotonicNow();
try {
Atomics.wait(i32a, 0, 0, poisonedValueOf);
} catch (error) {
@ -53,22 +44,24 @@ $262.agent.receiveBroadcast(function(sab) {
}
$262.agent.report($262.agent.monotonicNow() - start);
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(150);
assert.sameValue(getReport(), "poisonedValueOf");
assert.sameValue(getReport(), "poisonedToPrimitive");
assert.sameValue(getReport(), 'poisonedValueOf');
assert.sameValue(getReport(), 'poisonedToPrimitive');
var timeDiffReport = getReport();
const lapse = getReport();
assert(timeDiffReport >= 0, "timeout should be a min of 0ms");
assert(lapse >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, "timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON");
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(i32a, 0), 0);

View File

@ -18,16 +18,17 @@ info: |
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
---*/
var buffer = new SharedArrayBuffer(1024);
var i32a = new Int32Array(buffer);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
var poisonedValueOf = {
const poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
var poisonedToPrimitive = {
const poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
}

View File

@ -25,35 +25,26 @@ info: |
Symbol --> Throw a TypeError exception.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(
`
var poisonedValueOf = {
$262.agent.start(`
const poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
};
var poisonedToPrimitive = {
const poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
}
};
};
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
var start = $262.agent.monotonicNow();
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
const start = $262.agent.monotonicNow();
try {
Atomics.wait(i32a, Symbol("1"), poisonedValueOf, poisonedValueOf);
} catch (error) {
@ -66,10 +57,12 @@ $262.agent.receiveBroadcast(function(sab) {
}
$262.agent.report($262.agent.monotonicNow() - start);
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(150);
@ -77,10 +70,10 @@ $262.agent.sleep(150);
assert.sameValue(getReport(), 'Symbol("1")');
assert.sameValue(getReport(), 'Symbol("2")');
var timeDiffReport = getReport();
const lapse = getReport();
assert(timeDiffReport >= 0, "timeout should be a min of 0ms");
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, "timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON");
assert(lapse >= 0, 'timeout should be a min of 0ms');
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(i32a, 0), 0);

View File

@ -28,18 +28,19 @@ info: |
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
---*/
var buffer = new SharedArrayBuffer(1024);
var i32a = new Int32Array(buffer);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
var poisonedValueOf = {
const poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
var poisonedToPrimitive = {
const poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
throw new Test262Error('should not evaluate this code');
}
};
@ -52,9 +53,9 @@ assert.throws(Test262Error, function() {
});
assert.throws(TypeError, function() {
Atomics.wait(i32a, Symbol("foo"), poisonedValueOf, poisonedValueOf);
Atomics.wait(i32a, Symbol('foo'), poisonedValueOf, poisonedValueOf);
});
assert.throws(TypeError, function() {
Atomics.wait(i32a, Symbol("foo"), poisonedToPrimitive, poisonedToPrimitive);
Atomics.wait(i32a, Symbol('foo'), poisonedToPrimitive, poisonedToPrimitive);
});

View File

@ -12,21 +12,13 @@ info: |
Symbol --> Throw a TypeError exception.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
var start = $262.agent.monotonicNow();
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
const start = $262.agent.monotonicNow();
try {
Atomics.wait(i32a, 0, 0, Symbol("1"));
} catch (error) {
@ -39,10 +31,15 @@ $262.agent.receiveBroadcast(function(sab) {
}
$262.agent.report($262.agent.monotonicNow() - start);
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(150);
@ -50,9 +47,9 @@ $262.agent.sleep(150);
assert.sameValue(getReport(), 'Symbol("1")');
assert.sameValue(getReport(), 'Symbol("2")');
var timeDiffReport = getReport();
const lapse = getReport();
assert(timeDiffReport >= 0, "timeout should be a min of 0ms");
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, "timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON");
assert(lapse >= 0, 'timeout should be a min of 0ms');
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(i32a, 0), 0);

View File

@ -20,13 +20,13 @@ var i32a = new Int32Array(buffer);
var poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
var poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
throw new Test262Error('passing a poisoned object using @@ToPrimitive');
}
};

View File

@ -16,34 +16,26 @@ info: |
Symbol --> Throw a TypeError exception.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
var poisonedValueOf = {
const poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
};
var poisonedToPrimitive = {
const poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
}
};
};
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
var start = $262.agent.monotonicNow();
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
const before = $262.agent.monotonicNow();
try {
Atomics.wait(i32a, 0, Symbol("1"), poisonedValueOf);
} catch (error) {
@ -54,12 +46,14 @@ $262.agent.receiveBroadcast(function(sab) {
} catch (error) {
$262.agent.report('Symbol("2")');
}
$262.agent.report($262.agent.monotonicNow() - start);
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(150);
@ -67,9 +61,9 @@ $262.agent.sleep(150);
assert.sameValue(getReport(), 'Symbol("1")');
assert.sameValue(getReport(), 'Symbol("2")');
var timeDiffReport = getReport();
const lapse = getReport();
assert(timeDiffReport >= 0, "timeout should be a min of 0ms");
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, "timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON");
assert(lapse >= 0, 'timeout should be a min of 0ms');
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(i32a, 0), 0);

View File

@ -19,16 +19,17 @@ info: |
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
---*/
var buffer = new SharedArrayBuffer(1024);
var i32a = new Int32Array(buffer);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
var poisonedValueOf = {
const poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
var poisonedToPrimitive = {
const poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
}

View File

@ -12,44 +12,37 @@ info: |
Boolean -> If argument is true, return 1. If argument is false, return +0.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(
`
var valueOf = {
$262.agent.start(`
const valueOf = {
valueOf: function() {
return true;
}
};
};
var toPrimitive = {
const toPrimitive = {
[Symbol.toPrimitive]: function() {
return true;
}
};
};
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
var start = $262.agent.monotonicNow();
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
const start = $262.agent.monotonicNow();
$262.agent.report(Atomics.wait(i32a, 0, 0, true));
$262.agent.report(Atomics.wait(i32a, 0, 0, valueOf));
$262.agent.report(Atomics.wait(i32a, 0, 0, toPrimitive));
$262.agent.report($262.agent.monotonicNow() - start);
$262.agent.leaving();
})
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(150);
@ -58,11 +51,11 @@ assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
var timeDiffReport = getReport();
const lapse = getReport();
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
assert(lapse >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(i32a, 0), 0);

View File

@ -16,22 +16,23 @@ features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
flags: [CanBlockIsFalse]
---*/
var buffer = new SharedArrayBuffer(1024);
var i32a = new Int32Array(buffer);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
var valueOf = {
const valueOf = {
valueOf: function() {
return true;
}
};
var toPrimitive = {
const toPrimitive = {
[Symbol.toPrimitive]: function() {
return true;
}
};
assert.sameValue(Atomics.wait(i32a, 0, 0, true), "timed-out");
assert.sameValue(Atomics.wait(i32a, 0, 0, valueOf), "timed-out");
assert.sameValue(Atomics.wait(i32a, 0, 0, toPrimitive), "timed-out");
assert.sameValue(Atomics.wait(i32a, 0, 0, true), 'timed-out');
assert.sameValue(Atomics.wait(i32a, 0, 0, valueOf), 'timed-out');
assert.sameValue(Atomics.wait(i32a, 0, 0, toPrimitive), 'timed-out');

View File

@ -12,53 +12,49 @@ info: |
...
Undefined Return NaN.
5.If q is NaN, let t be +, else let t be max(q, 0)
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
var NUMAGENT = 2; // Total number of agents started
var WAKEUP = 0; // Index all agents are waiting on
var WAKECOUNT = 2; // Total number of agents to wake up
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const NUMAGENT = 2; // Total number of agents started
const WAKEUP = 0; // Index all agents are waiting on
const WAKECOUNT = 2; // Total number of agents to wake up
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.report("A " + Atomics.wait(i32a, 0, 0, undefined)); // undefined => NaN => +Infinity
$262.agent.leaving();
})
});
`);
$262.agent.start(
`
$262.agent.receiveBroadcast(function(sab) {
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.report("B " + Atomics.wait(i32a, 0, 0)); // undefined timeout arg => NaN => +Infinity
$262.agent.leaving();
})
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(500); // Ample time
assert.sameValue($262.agent.getReport(), null);
// No Reports made before wait
assert.sameValue(getReport(), null);
assert.sameValue(Atomics.wake(i32a, WAKEUP, WAKECOUNT), WAKECOUNT);
var sortedReports = [];
const sortedReports = [];
for (var i = 0; i < NUMAGENT; i++) {
sortedReports.push(getReport());
}
sortedReports.sort();
assert.sameValue(sortedReports[0], "A ok");
assert.sameValue(sortedReports[1], "B ok");
assert.sameValue(sortedReports[0], 'A ok');
assert.sameValue(sortedReports[1], 'B ok');

View File

@ -17,33 +17,26 @@ info: |
If value is undefined, then
Let index be 0.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(i32a, undefined, 0, 1000)); // undefined index => 0
$262.agent.leaving();
})
});
`);
var sab = new SharedArrayBuffer(4);
var i32a = new Int32Array(sab);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(150);
assert.sameValue(Atomics.wake(i32a, 0), 1); // wake at index 0
assert.sameValue(Atomics.wake(i32a, 0), 0); // wake again at index 0, and 0 agents should be woken
assert.sameValue(getReport(), "ok");
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
assert.sameValue(getReport(), 'ok');

View File

@ -14,34 +14,28 @@ info: |
a.Perform LeaveCriticalSection(WL).
b. Return the String "not-equal".
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
var value = 42;
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report(Atomics.store(i32a, 0, ${value}));
$262.agent.report(Atomics.wait(i32a, 0, 0));
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(100);
assert.sameValue(getReport(), value.toString());
assert.sameValue(getReport(), "not-equal");
assert.sameValue(getReport(), 'not-equal');

View File

@ -12,35 +12,27 @@ info: |
a.Perform LeaveCriticalSection(WL).
b. Return the String "not-equal".
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(i32a, 0, 44, 1000));
$262.agent.report(Atomics.wait(i32a, 0, 251.4, 1000));
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(1024));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(100);
$262.agent.sleep(200);
assert.sameValue(getReport(), "not-equal");
assert.sameValue(getReport(), "not-equal");
assert.sameValue(getReport(), 'not-equal');
assert.sameValue(getReport(), 'not-equal');
assert.sameValue(Atomics.wake(i32a, 0), 0);

View File

@ -18,19 +18,13 @@ info: |
...
4. Return the WaiterList that is referenced by the pair (block, i).
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
const i32a = new Int32Array(sab);
// Wait on index 0
Atomics.wait(i32a, 0, 0, 200);
@ -41,17 +35,18 @@ $262.agent.start(`
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
const i32a = new Int32Array(sab);
// Wait on index 2
Atomics.wait(i32a, 2, 0, 200);
$262.agent.report(0);
$262.agent.report(2);
$262.agent.leaving();
});
`);
var length = 4 * Int32Array.BYTES_PER_ELEMENT;
var i32a = new Int32Array(new SharedArrayBuffer(length));
const i32a = new Int32Array(
new SharedArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(10);
@ -61,5 +56,5 @@ Atomics.wake(i32a, 2, 1);
assert.sameValue(getReport(), '2');
// Wake index 0
Atomics.wake(i32a, 2, 1);
Atomics.wake(i32a, 0, 1);
assert.sameValue(getReport(), '0');

View File

@ -12,27 +12,20 @@ info: |
...
3.Add W to the end of the list of waiters in WL.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const agent1 = '1';
const agent2 = '2';
const agent3 = '3';
var agent1 = '1';
var agent2 = '2';
var agent3 = '3';
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report(${agent1});
Atomics.wait(i32a, 0, 0);
$262.agent.report(Atomics.wait(i32a, 1, 0));
$262.agent.report(${agent1});
$262.agent.leaving();
});
@ -43,7 +36,7 @@ $262.agent.start(`
const i32a = new Int32Array(sab);
$262.agent.report(${agent2});
Atomics.wait(i32a, 0, 0);
$262.agent.report(Atomics.wait(i32a, 2, 0));
$262.agent.report(${agent2});
$262.agent.leaving();
});
@ -54,29 +47,32 @@ $262.agent.start(`
const i32a = new Int32Array(sab);
$262.agent.report(${agent3});
Atomics.wait(i32a, 0, 0);
$262.agent.report(Atomics.wait(i32a, 3, 0));
$262.agent.report(${agent3});
$262.agent.leaving();
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(4));
const i32a = new Int32Array(
new SharedArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(500);
var orderAgentsStarted = getReport() + getReport() + getReport(); // can be started in any order
// Agents may be started in any order...
const started = [getReport(), getReport(), getReport()];
assert.sameValue(Atomics.wake(i32a, 0, 1), 1);
// Agents must wake in the order they waited
assert.sameValue(Atomics.wake(i32a, 1, 1), 1);
assert.sameValue(getReport(), 'ok');
assert.sameValue(getReport(), started[0]);
var orderAgentsWereWoken = getReport();
assert.sameValue(Atomics.wake(i32a, 2, 1), 1);
assert.sameValue(getReport(), 'ok');
assert.sameValue(getReport(), started[1]);
assert.sameValue(Atomics.wake(i32a, 0, 1), 1);
orderAgentsWereWoken += getReport();
assert.sameValue(Atomics.wake(i32a, 0, 1), 1);
orderAgentsWereWoken += getReport();
assert.sameValue(orderAgentsStarted, orderAgentsWereWoken); // agents should wake in the same order as they were started FIFO
assert.sameValue(Atomics.wake(i32a, 3, 1), 1);
assert.sameValue(getReport(), 'ok');
assert.sameValue(getReport(), started[2]);

View File

@ -18,38 +18,39 @@ info: |
If value is undefined, then
Let index be 0.
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
var sleeping = 100;
var sleeping = 10;
var timeout = 20000;
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
sleeping += 100;
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(i32a, 0, 0, ${timeout}));
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
const before = $262.agent.monotonicNow();
const unpark = Atomics.wait(i32a, 0, 0, ${timeout});
$262.agent.report($262.agent.monotonicNow() - before);
$262.agent.report(unpark);
$262.agent.leaving();
});
});
`);
var sab = new SharedArrayBuffer(4);
var i32a = new Int32Array(sab);
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(sleeping);
assert.sameValue(Atomics.wake(i32a, 0), 1);
assert.sameValue(getReport(), "ok");
assert(sleeping < timeout, "this test assumes it won't last for more than 20 seconds");
const lapse = getReport();
assert(
sleeping + lapse < timeout,
`${sleeping + lapse} should be less than ${timeout}`
);
assert.sameValue(getReport(), 'ok');

View File

@ -1,32 +0,0 @@
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
Test that Atomics.wait returns the right result when it was awoken.
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab, id) {
var i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(i32a, 0, 0)); // No timeout => Infinity
$262.agent.leaving();
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(500); // Give the agent a chance to wait
Atomics.wake(i32a, 0);
assert.sameValue(getReport(), "ok");

View File

@ -23,6 +23,6 @@ testWithTypedArrayConstructors(function(TA) {
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
assert.throws(RangeError, function() {
Atomics.wake(view, IdxGen(view), 0);
}, 'Atomics.wake(view, IdxGen(view), 0) throws RangeError'); // Even with waking zero
}, '`Atomics.wake(view, IdxGen(view), 0)` throws RangeError'); // Even with waking zero
});
}, views);

View File

@ -21,5 +21,5 @@ let i64a = new BigInt64Array(sab);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
assert.throws(RangeError, function() {
Atomics.wake(view, IdxGen(i64a), 0);
}, 'Atomics.wake(view, IdxGen(i64a), 0) throws RangeError');
}, '`Atomics.wake(view, IdxGen(i64a), 0)` throws RangeError');
});

View File

@ -17,10 +17,10 @@ features: [Atomics, BigInt, TypedArray]
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.wake(new BigUint64Array(), poisoned, poisoned);
}, 'BigUint64Array');
}, '`Atomics.wake(new BigUint64Array(), poisoned, poisoned)` throws TypeError');

View File

@ -18,14 +18,14 @@ features: [ArrayBuffer, Atomics, BigInt, TypedArray]
var i64a = new BigInt64Array(new ArrayBuffer(4));
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.wake(i64a, 0, 0);
});
}, '`Atomics.wake(i64a, 0, 0)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(i64a, poisoned, poisoned);
});
}, '`Atomics.wake(i64a, poisoned, poisoned)` throws TypeError');

View File

@ -19,7 +19,7 @@ features: [ArrayBuffer, Atomics, BigInt, TypedArray]
var i64a = new BigInt64Array(new ArrayBuffer(1024));
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
@ -28,4 +28,4 @@ $DETACHBUFFER(i64a.buffer);
assert.throws(TypeError, function() {
Atomics.wake(i64a, poisoned, poisoned);
});
}, '`Atomics.wake(i64a, poisoned, poisoned)` throws TypeError');

View File

@ -6,29 +6,30 @@ esid: sec-atomics.wake
description: >
Test that Atomics.wake wakes all waiters on a location, but does not
wake waiters on other locations.
includes: [atomicsHelper.js]
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/
var WAKEUP = 0; // Waiters on this will be woken
var DUMMY = 1; // Waiters on this will not be woken
var RUNNING = 2; // Accounting of live agents
var NUMELEM = 3;
var NUMAGENT = 3;
const WAKEUP = 0; // Waiters on this will be woken
const DUMMY = 1; // Waiters on this will not be woken
const RUNNING = 2; // Accounting of live agents
const NUMELEM = 3;
const NUMAGENT = 3;
for (var i = 0; i < NUMAGENT; i++) {
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
const i64a = new BigInt64Array(sab);
Atomics.add(i64a, ${RUNNING}, 1);
$262.agent.report("A " + Atomics.wait(i64a, ${WAKEUP}, 0));
$262.agent.leaving();
});
`);
});
`);
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i64a = new BigInt64Array(sab);
const i64a = new BigInt64Array(sab);
Atomics.add(i64a, ${RUNNING}, 1);
// This will always time out.
$262.agent.report("B " + Atomics.wait(i64a, ${DUMMY}, 0, 10));
@ -36,7 +37,9 @@ $262.agent.receiveBroadcast(function(sab) {
});
`);
var i64a = new BigInt64Array(new SharedArrayBuffer(NUMELEM * BigInt64Array.BYTES_PER_ELEMENT));
const i64a = new BigInt64Array(
new SharedArrayBuffer(NUMELEM * BigInt64Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i64a.buffer);
// Wait for agents to be running.
@ -47,7 +50,11 @@ waitUntil(i64a, RUNNING, NUMAGENT + 1);
$262.agent.sleep(50);
// Wake all waiting on WAKEUP, should be 3 always, they won't time out.
assert.sameValue(Atomics.wake(i64a, WAKEUP), NUMAGENT);
assert.sameValue(
Atomics.wake(i64a, WAKEUP),
NUMAGENT,
'Atomics.wake(i64a, WAKEUP) equals the value of `NUMAGENT` (3)'
);
var rs = [];
for (var i = 0; i < NUMAGENT + 1; i++) {
@ -56,23 +63,7 @@ for (var i = 0; i < NUMAGENT + 1; i++) {
rs.sort();
for (var i = 0; i < NUMAGENT; i++) {
assert.sameValue(rs[i], "A ok");
assert.sameValue(rs[i], "A ok", 'The value of rs[i] is "A ok"');
}
assert.sameValue(rs[NUMAGENT], "B timed-out");
assert.sameValue(rs[NUMAGENT], "B timed-out", 'The value of rs[NUMAGENT] is "B timed-out"');
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
function waitUntil(i64a, k, value) {
var i = 0;
while (Atomics.load(i64a, k) !== value && i < 15) {
$262.agent.sleep(10);
i++;
}
assert.sameValue(Atomics.load(i64a, k), value, "All agents are running");
}

View File

@ -28,9 +28,21 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
var sab = new SharedArrayBuffer(4);
var view = new Int32Array(sab);
assert.sameValue(Atomics.wake(view, 0, -3), 0);
assert.sameValue(Atomics.wake(view, 0, Number.POSITIVE_INFINITY), 0);
assert.sameValue(Atomics.wake(view, 0, undefined), 0);
assert.sameValue(Atomics.wake(view, 0, "33"), 0);
assert.sameValue(Atomics.wake(view, 0, { valueOf: 8 }), 0);
assert.sameValue(Atomics.wake(view, 0), 0);
assert.sameValue(Atomics.wake(view, 0, -3), 0, 'Atomics.wake(view, 0, -3) returns 0');
assert.sameValue(
Atomics.wake(view, 0, Number.POSITIVE_INFINITY),
0,
'Atomics.wake(view, 0, Number.POSITIVE_INFINITY) returns 0'
);
assert.sameValue(
Atomics.wake(view, 0, undefined),
0,
'Atomics.wake(view, 0, undefined) returns 0'
);
assert.sameValue(Atomics.wake(view, 0, "33"), 0, 'Atomics.wake(view, 0, "33") returns 0');
assert.sameValue(
Atomics.wake(view, 0, { valueOf: 8 }),
0,
'Atomics.wake(view, 0, {valueOf: 8}) returns 0'
);
assert.sameValue(Atomics.wake(view, 0), 0, 'Atomics.wake(view, 0) returns 0');

View File

@ -12,6 +12,7 @@ info: |
3. If count is undefined, let c be +.
...
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
@ -27,44 +28,49 @@ function getReport() {
}
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report("A " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving();
});
});
`);
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report("B " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving();
});
});
`);
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report("C " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving();
});
});
`);
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report("D " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(20);
assert.sameValue(Atomics.wake(i32a, WAKEUP /*, count missing */), NUMAGENT);
assert.sameValue(
Atomics.wake(i32a, WAKEUP /*, count missing */),
NUMAGENT,
'Atomics.wake(i32a, WAKEUP /*, count missing */) equals the value of `NUMAGENT` (4)'
);
var sortedReports = [];
for (var i = 0; i < NUMAGENT; i++) {
@ -72,7 +78,7 @@ for (var i = 0; i < NUMAGENT; i++) {
}
sortedReports.sort();
assert.sameValue(sortedReports[0], "A ok");
assert.sameValue(sortedReports[1], "B ok");
assert.sameValue(sortedReports[2], "C ok");
assert.sameValue(sortedReports[3], "D ok");
assert.sameValue(sortedReports[0], "A ok", 'The value of sortedReports[0] is "A ok"');
assert.sameValue(sortedReports[1], "B ok", 'The value of sortedReports[1] is "B ok"');
assert.sameValue(sortedReports[2], "C ok", 'The value of sortedReports[2] is "C ok"');
assert.sameValue(sortedReports[3], "D ok", 'The value of sortedReports[3] is "D ok"');

View File

@ -10,61 +10,60 @@ info: |
3.If count is undefined, let c be +.
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
var NUMAGENT = 4; // Total number of agents started
var WAKEUP = 0; // Index all agents are waiting on
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}
const NUMAGENT = 4; // Total number of agents started
const WAKEUP = 0; // Index all agents are waiting on
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report("A " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving();
});
});
`);
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report("B " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving();
});
});
`);
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report("C " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving();
});
});
`);
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.receiveBroadcast(function(sab) {
const i32a = new Int32Array(sab);
$262.agent.report("D " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving();
});
});
`);
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(20); // half of timeout
assert.sameValue(Atomics.wake(i32a, WAKEUP, undefined), NUMAGENT);
assert.sameValue(
Atomics.wake(i32a, WAKEUP, undefined),
NUMAGENT,
'Atomics.wake(i32a, WAKEUP, undefined) equals the value of `NUMAGENT` (4)'
);
var sortedReports = [];
for (var i = 0; i < NUMAGENT; i++) {
@ -72,7 +71,7 @@ for (var i = 0; i < NUMAGENT; i++) {
}
sortedReports.sort();
assert.sameValue(sortedReports[0], "A ok");
assert.sameValue(sortedReports[1], "B ok");
assert.sameValue(sortedReports[2], "C ok");
assert.sameValue(sortedReports[3], "D ok");
assert.sameValue(sortedReports[0], "A ok", 'The value of sortedReports[0] is "A ok"');
assert.sameValue(sortedReports[1], "B ok", 'The value of sortedReports[1] is "B ok"');
assert.sameValue(sortedReports[2], "C ok", 'The value of sortedReports[2] is "C ok"');
assert.sameValue(sortedReports[3], "D ok", 'The value of sortedReports[3] is "D ok"');

View File

@ -28,5 +28,5 @@ var sab = new SharedArrayBuffer(4);
var view = new Int32Array(sab);
NaNs.forEach(nan => {
assert.sameValue(Atomics.wake(view, 0, nan), 0);
assert.sameValue(Atomics.wake(view, 0, nan), 0, 'Atomics.wake(view, 0, nan) returns 0');
});

View File

@ -22,4 +22,4 @@ var view = new Int32Array(sab);
assert.throws(TypeError, function() {
Atomics.wake(view, 0, Symbol());
});
}, '`Atomics.wake(view, 0, Symbol())` throws TypeError');

View File

@ -21,10 +21,10 @@ var sab = new SharedArrayBuffer(4);
var view = new Int32Array(sab);
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(Test262Error, function() {
Atomics.wake(view, 0, poisoned);
});
}, '`Atomics.wake(view, 0, poisoned)` throws Test262Error');

View File

@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
var view = new Int32Array(sab, 32, 20);
view[0] = 0;
assert.sameValue(Atomics.wake(view, 0, 1), 0);
assert.sameValue(Atomics.wake(view, 0, 1), 0, 'Atomics.wake(view, 0, 1) returns 0');
// In-bounds boundary cases for indexing
testWithAtomicsInBoundsIndices(function(IdxGen) {
@ -23,5 +23,5 @@ testWithAtomicsInBoundsIndices(function(IdxGen) {
// Atomics.store() computes an index from Idx in the same way as other
// Atomics operations, not quite like view[Idx].
Atomics.store(view, Idx, 37);
assert.sameValue(Atomics.wake(view, Idx, 1), 0);
assert.sameValue(Atomics.wake(view, Idx, 1), 0, 'Atomics.wake(view, Idx, 1) returns 0');
});

View File

@ -5,28 +5,24 @@
esid: sec-atomics.wake
description: >
Test that Atomics.wake wakes zero waiters if the count is negative
includes: [atomicsHelper.js]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
$262.agent.start(`
$262.agent.receiveBroadcast(function(sab) {
var ia = new Int32Array(sab);
$262.agent.report(Atomics.wait(ia, 0, 0, 1000)); // Timeout after 1 second
$262.agent.receiveBroadcast(function(sab) {
var i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(i32a, 0, 0, 1000)); // Timeout after 1 second
$262.agent.leaving();
})
});
`);
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
);
$262.agent.broadcast(ia.buffer);
$262.agent.broadcast(i32a.buffer);
$262.agent.sleep(500); // Give the agent a chance to wait
assert.sameValue(Atomics.wake(ia, 0, -1), 0); // Don't actually wake it
assert.sameValue(getReport(), "timed-out");
assert.sameValue(Atomics.wake(i32a, 0, -1), 0, 'Atomics.wake(i32a, 0, -1) returns 0'); // Don't actually wake it
assert.sameValue(getReport(), 'timed-out', 'getReport() returns "timed-out"');
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(10);
}
return r;
}

View File

@ -20,19 +20,19 @@ var sab = new SharedArrayBuffer(1024);
var i32a = new Int32Array(sab);
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(RangeError, function() {
Atomics.wake(i32a, -Infinity, poisoned);
}, 'Atomics.wake(i32a, -Infinity, poisoned) throws RangeError');
}, '`Atomics.wake(i32a, -Infinity, poisoned)` throws RangeError');
assert.throws(RangeError, function() {
Atomics.wake(i32a, -7.999, poisoned);
}, 'Atomics.wake(i32a, -7.999, poisoned) throws RangeError');
}, '`Atomics.wake(i32a, -7.999, poisoned)` throws RangeError');
assert.throws(RangeError, function() {
Atomics.wake(i32a, -1, poisoned);
}, 'Atomics.wake(i32a, -1, poisoned) throws RangeError');
}, '`Atomics.wake(i32a, -1, poisoned)` throws RangeError');
assert.throws(RangeError, function() {
Atomics.wake(i32a, -300, poisoned);
}, 'Atomics.wake(i32a, -300, poisoned) throws RangeError');
}, '`Atomics.wake(i32a, -300, poisoned)` throws RangeError');

View File

@ -17,38 +17,38 @@ features: [Atomics, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Arr
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.wake(new Float64Array(), poisoned, poisoned);
}, 'Float64Array');
}, '`Atomics.wake(new Float64Array(), poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(new Float32Array(), poisoned, poisoned);
}, 'Float32Array');
}, '`Atomics.wake(new Float32Array(), poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(new Int16Array(), poisoned, poisoned);
}, 'Int16Array');
}, '`Atomics.wake(new Int16Array(), poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(new Int8Array(), poisoned, poisoned);
}, 'Int8Array');
}, '`Atomics.wake(new Int8Array(), poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(new Uint32Array(), poisoned, poisoned);
}, 'Uint32Array');
}, '`Atomics.wake(new Uint32Array(), poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(new Uint16Array(), poisoned, poisoned);
}, 'Uint16Array');
}, '`Atomics.wake(new Uint16Array(), poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wait(new Uint8Array(), poisoned, poisoned);
}, 'Uint8Array');
}, '`Atomics.wait(new Uint8Array(), poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(new Uint8ClampedArray(), poisoned, poisoned);
}, 'Uint8ClampedArray');
}, '`Atomics.wake(new Uint8ClampedArray(), poisoned, poisoned)` throws TypeError');

View File

@ -18,14 +18,14 @@ features: [ArrayBuffer, Atomics, TypedArray]
var i32a = new Int32Array(new ArrayBuffer(4));
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.wake(i32a, 0, 0);
});
}, '`Atomics.wake(i32a, 0, 0)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(i32a, poisoned, poisoned);
});
}, '`Atomics.wake(i32a, poisoned, poisoned)` throws TypeError');

View File

@ -12,5 +12,5 @@ features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedAr
testWithAtomicsNonViewValues(function(view) {
assert.throws(TypeError, function() {
Atomics.wake(view, 0, 0);
}, 'Atomics.wake(view, 0, 0) throws TypeError'); // Even with count == 0
}, '`Atomics.wake(view, 0, 0)` throws TypeError'); // Even with count == 0
});

View File

@ -16,5 +16,5 @@ testWithTypedArrayConstructors(function(TA) {
// Should fail even if waking zero waiters
assert.throws(TypeError, function() {
Atomics.wake(new TA(buffer), 0, 0);
}, 'Atomics.wake(new TA(buffer), 0, 0) throws TypeError');
}, '`Atomics.wake(new TA(buffer), 0, 0)` throws TypeError');
}, views);

View File

@ -16,14 +16,14 @@ features: [Atomics]
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.wait({}, 0, 0, 0);
});
}, '`Atomics.wait({}, 0, 0, 0)` throws TypeError');
assert.throws(TypeError, function () {
Atomics.wait({}, poisoned, poisoned, poisoned);
});
}, '`Atomics.wait({}, poisoned, poisoned, poisoned)` throws TypeError');

View File

@ -15,34 +15,34 @@ features: [Atomics, Symbol]
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.wake(null, poisoned, poisoned);
}, 'null');
}, '`Atomics.wake(null, poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(undefined, poisoned, poisoned);
}, 'undefined');
}, '`Atomics.wake(undefined, poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(true, poisoned, poisoned);
}, 'true');
}, '`Atomics.wake(true, poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(false, poisoned, poisoned);
}, 'false');
}, '`Atomics.wake(false, poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake('***string***', poisoned, poisoned);
}, 'String');
}, '`Atomics.wake(\'***string***\', poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(Number.NEGATIVE_INFINITY, poisoned, poisoned);
}, '-Infinity');
}, '`Atomics.wake(Number.NEGATIVE_INFINITY, poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(Symbol('***symbol***'), poisoned, poisoned);
}, 'Symbol');
}, '`Atomics.wake(Symbol(\'***symbol***\'), poisoned, poisoned)` throws TypeError');

View File

@ -19,7 +19,7 @@ features: [ArrayBuffer, Atomics, TypedArray]
var i32a = new Int32Array(new ArrayBuffer(1024));
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
@ -27,4 +27,4 @@ $DETACHBUFFER(i32a.buffer); // Detaching a non-shared ArrayBuffer sets the [[Arr
assert.throws(TypeError, function() {
Atomics.wake(i32a, poisoned, poisoned);
});
}, '`Atomics.wake(i32a, poisoned, poisoned)` throws TypeError');

View File

@ -19,16 +19,16 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
var i32a = new Int32Array(new SharedArrayBuffer(4));
var poisoned = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(RangeError, function() {
Atomics.wake(i32a, Infinity, poisoned);
});
}, '`Atomics.wake(i32a, Infinity, poisoned)` throws RangeError');
assert.throws(RangeError, function() {
Atomics.wake(i32a, 2, poisoned);
});
}, '`Atomics.wake(i32a, 2, poisoned)` throws RangeError');
assert.throws(RangeError, function() {
Atomics.wake(i32a, 200, poisoned);
});
}, '`Atomics.wake(i32a, 200, poisoned)` throws RangeError');

View File

@ -14,7 +14,7 @@ var buffer = new SharedArrayBuffer(1024);
testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.wake(new TA(buffer), 0, 0);
}, 'Atomics.wake(new TA(buffer), 0, 0) throws TypeError');
}, '`Atomics.wake(new TA(buffer), 0, 0)` throws TypeError');
}, floatArrayConstructors);

View File

@ -33,7 +33,7 @@ var i32a = new Int32Array(buffer);
var poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
throw new Test262Error('should not evaluate this code');
}
};
@ -45,16 +45,16 @@ var poisonedToPrimitive = {
assert.throws(Test262Error, function() {
Atomics.wake(i32a, poisonedValueOf, poisonedValueOf);
});
}, '`Atomics.wake(i32a, poisonedValueOf, poisonedValueOf)` throws Test262Error');
assert.throws(Test262Error, function() {
Atomics.wake(i32a, poisonedToPrimitive, poisonedToPrimitive);
});
}, '`Atomics.wake(i32a, poisonedToPrimitive, poisonedToPrimitive)` throws Test262Error');
assert.throws(TypeError, function() {
Atomics.wake(i32a, Symbol("foo"), poisonedValueOf);
});
}, '`Atomics.wake(i32a, Symbol("foo"), poisonedValueOf)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.wake(i32a, Symbol("foo"), poisonedToPrimitive);
});
}, '`Atomics.wake(i32a, Symbol("foo"), poisonedToPrimitive)` throws TypeError');

Some files were not shown because too many files have changed in this diff Show More