mirror of https://github.com/tc39/test262.git
Atomics: updates to various Atomics tests. gh-1527
Ref gh-1531
This commit is contained in:
parent
e246d95deb
commit
a3b05ee839
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.add
|
||||
description: >
|
||||
Test range checking of Atomics.add on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.add(view, IdxGen(view), 10));
|
||||
});
|
||||
});
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.add
|
||||
description: Test Atomics.add on arrays that allow atomic operations.
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, Atomics, BigInt, computed-property-names, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
// Add positive number
|
||||
view[8] = 0;
|
||||
assert.sameValue(Atomics.add(view, 8, 10), 0);
|
||||
assert.sameValue(view[8], 10);
|
||||
|
||||
// Add negative number
|
||||
assert.sameValue(Atomics.add(view, 8, -5), 10);
|
||||
assert.sameValue(view[8], 5);
|
||||
|
||||
view[3] = -5;
|
||||
control[0] = -5;
|
||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
||||
"Result is negative and subject to coercion");
|
||||
|
||||
control[0] = 12345;
|
||||
view[3] = 12345;
|
||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
control[0] = 123456789;
|
||||
view[3] = 123456789;
|
||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
// In-bounds boundary cases for indexing
|
||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||
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);
|
||||
assert.sameValue(Atomics.add(view, Idx, 0), 37);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.add
|
||||
description: >
|
||||
Test Atomics.add on non-shared integer TypedArrays
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, () => Atomics.add(new TA(ab), 0, 0));
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.and
|
||||
description: >
|
||||
Test range checking of Atomics.and on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.and(view, IdxGen(view), 10));
|
||||
});
|
||||
});
|
|
@ -0,0 +1,60 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.and
|
||||
description: Test Atomics.and on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, Atomics, BigInt, computed-property-names, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[8] = 0x33333333;
|
||||
control[0] = 0x33333333;
|
||||
assert.sameValue(Atomics.and(view, 8, 0x55555555), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
control[0] = 0x11111111;
|
||||
assert.sameValue(view[8], control[0]);
|
||||
assert.sameValue(Atomics.and(view, 8, 0xF0F0F0F0), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
control[0] = 0x10101010;
|
||||
assert.sameValue(view[8], control[0]);
|
||||
|
||||
view[3] = -5;
|
||||
control[0] = -5;
|
||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
||||
"Result is negative and subject to coercion");
|
||||
assert.sameValue(view[3], 0);
|
||||
|
||||
control[0] = 12345;
|
||||
view[3] = 12345;
|
||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
||||
"Result is subjective to chopping");
|
||||
assert.sameValue(view[3], 0);
|
||||
|
||||
control[0] = 123456789;
|
||||
view[3] = 123456789;
|
||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
||||
"Result is subjective to chopping");
|
||||
assert.sameValue(view[3], 0);
|
||||
|
||||
// In-bounds boundary cases for indexing
|
||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||
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);
|
||||
assert.sameValue(Atomics.and(view, Idx, 0), 37);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.and
|
||||
description: >
|
||||
Test Atomics.and on non-shared integer TypedArrays
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, () => Atomics.and(new TA(buffer), 0, 0));
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.compareexchange
|
||||
description: >
|
||||
Test range checking of Atomics.compareExchange on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.compareExchange(view, IdxGen(view), 10, 0));
|
||||
});
|
||||
});
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.compareexchange
|
||||
description: Test Atomics.compareExchange on arrays that allow atomic operations.
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, Atomics, BigInt, computed-property-names, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
// Performs the exchange
|
||||
view[8] = 0;
|
||||
assert.sameValue(Atomics.compareExchange(view, 8, 0, 10), 0);
|
||||
assert.sameValue(view[8], 10);
|
||||
|
||||
view[8] = 0;
|
||||
assert.sameValue(Atomics.compareExchange(view, 8, 1, 10), 0,
|
||||
"Does not perform the exchange");
|
||||
assert.sameValue(view[8], 0);
|
||||
|
||||
view[8] = 0;
|
||||
assert.sameValue(Atomics.compareExchange(view, 8, 0, -5), 0,
|
||||
"Performs the exchange, coercing the value being stored");
|
||||
control[0] = -5;
|
||||
assert.sameValue(view[8], control[0]);
|
||||
|
||||
|
||||
view[3] = -5;
|
||||
control[0] = -5;
|
||||
assert.sameValue(Atomics.compareExchange(view, 3, -5, 0), control[0],
|
||||
"Performs the exchange, coercing the value being tested");
|
||||
assert.sameValue(view[3], 0);
|
||||
|
||||
|
||||
control[0] = 12345;
|
||||
view[3] = 12345;
|
||||
assert.sameValue(Atomics.compareExchange(view, 3, 12345, 0), control[0],
|
||||
"Performs the exchange, chopping the value being tested");
|
||||
assert.sameValue(view[3], 0);
|
||||
|
||||
control[0] = 123456789;
|
||||
view[3] = 123456789;
|
||||
assert.sameValue(Atomics.compareExchange(view, 3, 123456789, 0), control[0],
|
||||
"Performs the exchange, chopping the value being tested");
|
||||
assert.sameValue(view[3], 0);
|
||||
|
||||
// In-bounds boundary cases for indexing
|
||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||
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);
|
||||
assert.sameValue(Atomics.compareExchange(view, Idx, 37, 0), 37);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.compareexchange
|
||||
description: >
|
||||
Test Atomics.compareExchange on non-shared integer TypedArrays
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.compareExchange(new TA(buffer), 0, 0, 0)));
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.exchange
|
||||
description: >
|
||||
Test range checking of Atomics.exchange on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.exchange(view, IdxGen(view), 10, 0));
|
||||
});
|
||||
});
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.exchange
|
||||
description: Test Atomics.exchange on arrays that allow atomic operations.
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, Atomics, BigInt, computed-property-names, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[8] = 0;
|
||||
assert.sameValue(Atomics.exchange(view, 8, 10), 0,
|
||||
"Exchange returns the value previously in the array");
|
||||
assert.sameValue(view[8], 10);
|
||||
|
||||
assert.sameValue(Atomics.exchange(view, 8, -5), 10,
|
||||
"Exchange returns the value previously in the array");
|
||||
control[0] = -5;
|
||||
assert.sameValue(view[8], control[0]);
|
||||
|
||||
view[3] = -5;
|
||||
control[0] = -5;
|
||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
||||
"Result is subject to coercion");
|
||||
|
||||
control[0] = 12345;
|
||||
view[3] = 12345;
|
||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
control[0] = 123456789;
|
||||
view[3] = 123456789;
|
||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
// In-bounds boundary cases for indexing
|
||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||
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);
|
||||
assert.sameValue(Atomics.exchange(view, Idx, 0), 37);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.exchange
|
||||
description: >
|
||||
Test Atomics.exchange on non-shared integer TypedArrays
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.exchange(new TA(buffer), 0, 0)));
|
||||
});
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.islockfree
|
||||
description: >
|
||||
Test isLockFree on various non-intuitive arguments
|
||||
features: [arrow-function, Atomics]
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Atomics.isLockFree(hide(3, Number.NaN)), false);
|
||||
assert.sameValue(Atomics.isLockFree(hide(3, -1)), false);
|
||||
assert.sameValue(Atomics.isLockFree(hide(3, 3.14)), false);
|
||||
assert.sameValue(Atomics.isLockFree(hide(3, 0)), false);
|
||||
|
||||
assert.sameValue(Atomics.isLockFree('1'), Atomics.isLockFree(1));
|
||||
assert.sameValue(Atomics.isLockFree('3'), Atomics.isLockFree(3));
|
||||
|
||||
assert.sameValue(Atomics.isLockFree(true), Atomics.isLockFree(1));
|
||||
|
||||
assert.sameValue(Atomics.isLockFree(1), Atomics.isLockFree({valueOf: () => 1}));
|
||||
assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({valueOf: () => 3}));
|
||||
assert.sameValue(Atomics.isLockFree(1), Atomics.isLockFree({toString: () => '1'}));
|
||||
assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({toString: () => '3'}));
|
||||
|
||||
function hide(k, x) {
|
||||
if (k) {
|
||||
return hide(k - 3, x) + x;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.islockfree
|
||||
description: >
|
||||
Test isLockFree on nonnegative integer arguments
|
||||
features: [Atomics, computed-property-names]
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
---*/
|
||||
|
||||
var sizes = [ 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12];
|
||||
var answers = [ {}, {}, false, true, false, false, false, false,
|
||||
false, false, false, false];
|
||||
|
||||
var saved = {};
|
||||
|
||||
// This should defeat most optimizations.
|
||||
|
||||
for (var i = 0; i < sizes.length; i++) {
|
||||
var v = Atomics.isLockFree(sizes[i]);
|
||||
var a = answers[i];
|
||||
assert.sameValue(typeof v, 'boolean');
|
||||
if (typeof a == 'boolean') {
|
||||
assert.sameValue(v, a);
|
||||
} else {
|
||||
saved[sizes[i]] = v;
|
||||
}
|
||||
}
|
||||
|
||||
// This ought to be optimizable. Make sure the answers are the same
|
||||
// as for the unoptimized case.
|
||||
|
||||
assert.sameValue(Atomics.isLockFree(1), saved[1]);
|
||||
assert.sameValue(Atomics.isLockFree(2), saved[2]);
|
||||
assert.sameValue(Atomics.isLockFree(3), false);
|
||||
assert.sameValue(Atomics.isLockFree(4), true);
|
||||
assert.sameValue(Atomics.isLockFree(5), false);
|
||||
assert.sameValue(Atomics.isLockFree(6), false);
|
||||
assert.sameValue(Atomics.isLockFree(7), false);
|
||||
assert.sameValue(Atomics.isLockFree(8), false);
|
||||
assert.sameValue(Atomics.isLockFree(9), false);
|
||||
assert.sameValue(Atomics.isLockFree(10), false);
|
||||
assert.sameValue(Atomics.isLockFree(11), false);
|
||||
assert.sameValue(Atomics.isLockFree(12), false);
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.load
|
||||
description: >
|
||||
Test range checking of Atomics.load on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.load(view, IdxGen(view)));
|
||||
});
|
||||
});
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.load
|
||||
description: Test Atomics.load on arrays that allow atomic operations.
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, Atomics, BigInt, computed-property-names, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[3] = -5;
|
||||
control[0] = -5;
|
||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
||||
"Result is subject to coercion");
|
||||
|
||||
control[0] = 12345;
|
||||
view[3] = 12345;
|
||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
control[0] = 123456789;
|
||||
view[3] = 123456789;
|
||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
// In-bounds boundary cases for indexing
|
||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||
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);
|
||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.load
|
||||
description: >
|
||||
Test Atomics.load on non-shared integer TypedArrays
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var view = new TA(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.load(view, 0)));
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.or
|
||||
description: >
|
||||
Test range checking of Atomics.or on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.or(view, IdxGen(view), 10));
|
||||
});
|
||||
});
|
|
@ -0,0 +1,60 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.or
|
||||
description: Test Atomics.or on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, Atomics, BigInt, computed-property-names, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[8] = 0x33333333;
|
||||
control[0] = 0x33333333;
|
||||
assert.sameValue(Atomics.or(view, 8, 0x55555555), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
control[0] = 0x77777777;
|
||||
assert.sameValue(view[8], control[0]);
|
||||
assert.sameValue(Atomics.or(view, 8, 0xF0F0F0F0), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
control[0] = 0xF7F7F7F7;
|
||||
assert.sameValue(view[8], control[0]);
|
||||
|
||||
view[3] = -5;
|
||||
control[0] = -5;
|
||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
||||
"Result is negative and subject to coercion");
|
||||
assert.sameValue(view[3], control[0]);
|
||||
|
||||
control[0] = 12345;
|
||||
view[3] = 12345;
|
||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
||||
"Result is subject to chopping");
|
||||
assert.sameValue(view[3], control[0]);
|
||||
|
||||
control[0] = 123456789;
|
||||
view[3] = 123456789;
|
||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
||||
"Result is subject to chopping");
|
||||
assert.sameValue(view[3], control[0]);
|
||||
|
||||
// In-bounds boundary cases for indexing
|
||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||
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);
|
||||
assert.sameValue(Atomics.or(view, Idx, 0), 37);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.or
|
||||
description: >
|
||||
Test Atomics.or on non-shared integer TypedArrays
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.or(new TA(buffer), 0, 0)));
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.store
|
||||
description: >
|
||||
Test range checking of Atomics.store on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.store(view, IdxGen(view), 10));
|
||||
});
|
||||
});
|
|
@ -0,0 +1,59 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.store
|
||||
description: Test Atomics.store on arrays that allow atomic operations.
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, computed-property-names, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
for (let val of [10, -5,
|
||||
12345,
|
||||
123456789,
|
||||
Math.PI,
|
||||
"33",
|
||||
{
|
||||
valueOf: () => 33
|
||||
},
|
||||
undefined
|
||||
])
|
||||
{
|
||||
assert.sameValue(Atomics.store(view, 3, val), ToInteger(val),
|
||||
"Atomics.store returns its third argument (" + val + ") converted to Integer, not the input value nor the value that was stored");
|
||||
|
||||
control[0] = val;
|
||||
assert.sameValue(view[3], control[0]);
|
||||
}
|
||||
|
||||
// In-bounds boundary cases for indexing
|
||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
view.fill(0);
|
||||
Atomics.store(view, Idx, 37);
|
||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
||||
});
|
||||
});
|
||||
|
||||
function ToInteger(v) {
|
||||
v = +v;
|
||||
if (isNaN(v)) {
|
||||
return 0;
|
||||
}
|
||||
if (v == 0 || !isFinite(v)) {
|
||||
return v;
|
||||
}
|
||||
if (v < 0) {
|
||||
return -Math.floor(Math.abs(v));
|
||||
}
|
||||
return Math.floor(v);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.store
|
||||
description: >
|
||||
Test Atomics.store on non-shared integer TypedArrays
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.store(new TA(buffer), 0, 0)));
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.sub
|
||||
description: >
|
||||
Test range checking of Atomics.sub on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.sub(view, IdxGen(view), 10));
|
||||
});
|
||||
});
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.sub
|
||||
description: Test Atomics.sub on arrays that allow atomic operations
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, Atomics, BigInt, computed-property-names, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[8] = 100;
|
||||
assert.sameValue(Atomics.sub(view, 8, 10), 100,
|
||||
"Subtract positive number");
|
||||
assert.sameValue(view[8], 90);
|
||||
|
||||
assert.sameValue(Atomics.sub(view, 8, -5), 90,
|
||||
"Subtract negative number, though result remains positive");
|
||||
assert.sameValue(view[8], 95);
|
||||
|
||||
view[3] = -5;
|
||||
control[0] = -5;
|
||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
||||
"Result is negative and subject to coercion");
|
||||
|
||||
control[0] = 12345;
|
||||
view[3] = 12345;
|
||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
control[0] = 123456789;
|
||||
view[3] = 123456789;
|
||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
||||
"Result is subject to chopping");
|
||||
|
||||
// In-bounds boundary cases for indexing
|
||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||
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);
|
||||
assert.sameValue(Atomics.sub(view, Idx, 0), 37);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.sub
|
||||
description: >
|
||||
Test Atomics.sub on non-shared integer TypedArrays
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(16);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.sub(new TA(buffer), 0, 0)));
|
||||
});
|
|
@ -11,16 +11,13 @@ info: |
|
|||
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
|
||||
includes: [testAtomics.js, testTypedArray.js]
|
||||
includes: [testAtomics.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(8);
|
||||
var views = [Int32Array];
|
||||
let i32a = new Int32Array(sab);
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(sab);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.wake(view, IdxGen(view), 0)); // Even with waking zero
|
||||
});
|
||||
}, views);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.wait(i32a, IdxGen(i32a), 0, 0));
|
||||
});
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wake
|
||||
description: >
|
||||
Test range checking of Atomics.wake on arrays that allow atomic operations
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
|
||||
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);
|
||||
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.wait(i64a, IdxGen(i64a), 0, 0));
|
||||
});
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Atomics.wait throws if agent cannot be suspended, CanBlock is false
|
||||
info: |
|
||||
Assuming [[CanBlock]] is false for the main host.
|
||||
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
... (after args validation)
|
||||
6. Let B be AgentCanSuspend().
|
||||
7. If B is false, throw a TypeError exception.
|
||||
...
|
||||
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(4);
|
||||
var i64a = new BigInt64Array(buffer);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(i64a, 0, 0, 0);
|
||||
});
|
|
@ -0,0 +1,41 @@
|
|||
// 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 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).
|
||||
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);
|
||||
var then = Date.now();
|
||||
$262.agent.report(Atomics.wait(ia, 0, 0, 500)); // Timeout 500ms
|
||||
$262.agent.report(Date.now() - then); // Actual time can be more than 500ms
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var ia = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(ia.buffer);
|
||||
assert.sameValue(getReport(), "timed-out");
|
||||
assert.sameValue((getReport() | 0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true);
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
False timeout arg should result in an +0 timeout
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
4. Let q be ? ToNumber(timeout).
|
||||
|
||||
Boolean -> If argument is true, return 1. If argument is false, return +0.
|
||||
|
||||
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 = {
|
||||
valueOf: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var toPrimitive = {
|
||||
[Symbol.toPrimitive]: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
var start = Date.now();
|
||||
$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(Date.now() - start);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
|
||||
var timeDiffReport = 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.sameValue(Atomics.wake(i64a, 0), 0);
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
False timeout arg should result in an +0 timeout
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
4. Let q be ? ToNumber(timeout).
|
||||
|
||||
Boolean -> If argument is true, return 1. If argument is false, return +0.
|
||||
|
||||
features: [Atomics, BigInt, computed-property-names, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var i64a = new BigInt64Array(buffer);
|
||||
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var toPrimitive = {
|
||||
[Symbol.toPrimitive]: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
assert.sameValue(Atomics.wait(i64a, 0, 0, false), "timed-out");
|
||||
assert.sameValue(Atomics.wait(i64a, 0, 0, valueOf), "timed-out");
|
||||
assert.sameValue(Atomics.wait(i64a, 0, 0, toPrimitive), "timed-out");
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
// 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 Atomics.wait on arrays that allow atomic operations,
|
||||
in an Agent that is allowed to wait.
|
||||
features: [Atomics, BigInt]
|
||||
---*/
|
||||
|
||||
// Let's assume 'wait' is not allowed on the main thread,
|
||||
// even in the shell.
|
||||
|
||||
$262.agent.start(`
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var good_indices = [ (view) => 0/-1, // -0
|
||||
(view) => '-0',
|
||||
(view) => view.length - 1,
|
||||
(view) => ({ valueOf: () => 0 }),
|
||||
(view) => ({ toString: () => '0', valueOf: false }) // non-callable valueOf triggers invocation of toString
|
||||
];
|
||||
|
||||
var view = new BigInt64Array(sab, 32, 20);
|
||||
|
||||
view[0] = 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 ) {
|
||||
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();
|
||||
`);
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
NaN timeout arg should result in an infinite timeout
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
4.Let q be ? ToNumber(timeout).
|
||||
...
|
||||
Undefined Return NaN.
|
||||
5.If q is NaN, let t be +∞, else let t be max(q, 0)
|
||||
|
||||
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);
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, NaN)); // NaN => +Infinity
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
$262.agent.sleep(500); // Ample time
|
||||
|
||||
assert.sameValue(Atomics.wake(i64a, 0), 1);
|
||||
assert.sameValue(getReport(), "ok");
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Throws a RangeError is index < 0
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
2.Let i be ? ValidateAtomicAccess(typedArray, index).
|
||||
...
|
||||
2.Let accessIndex be ? ToIndex(requestIndex).
|
||||
...
|
||||
2.b If integerIndex < 0, throw a RangeError exception
|
||||
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var i64a = new BigInt64Array(sab);
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(i64a, -Infinity, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(i64a, -7.999, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(i64a, -1, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(i64a, -300, poisoned, poisoned);
|
||||
});
|
|
@ -0,0 +1,32 @@
|
|||
// 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 times out with a negative timeout
|
||||
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
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var i64a = new BigInt64Array(buffer);
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
assert.sameValue(getReport(), "timed-out");
|
||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
|
@ -0,0 +1,15 @@
|
|||
// 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 times out with a negative timeout
|
||||
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var i64a = new BigInt64Array(buffer);
|
||||
|
||||
assert.sameValue(Atomics.wait(i64a, 0, 0, -1), "timed-out");
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
|
||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
|
@ -10,10 +10,9 @@ includes: [atomicsHelper.js]
|
|||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab, id) {
|
||||
var ia = new Int32Array(sab);
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab, id) {
|
||||
var ia = new BigInt64Array(sab);
|
||||
var then = Date.now();
|
||||
Atomics.wait(ia, 0, 0);
|
||||
var diff = Date.now() - then; // Should be about 1000 ms but can be more
|
||||
|
@ -22,7 +21,7 @@ $262.agent.receiveBroadcast(function (sab, id) {
|
|||
})
|
||||
`);
|
||||
|
||||
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var ia = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(ia.buffer);
|
||||
$262.agent.sleep(500); // Give the agent a chance to wait
|
||||
|
@ -34,7 +33,7 @@ assert.sameValue((getReport() | 0) >= 1000 - $ATOMICS_MAX_TIME_EPSILON, true);
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
// 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: >
|
||||
Demonstrates that Atomics.store(...) is causing a waiting
|
||||
features: [Atomics, computed-property-names, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
const TWO_SECOND_TIMEOUT = 2000;
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
var before = Date.now();
|
||||
$262.agent.report("ready");
|
||||
Atomics.wait(i64a, 0, 0, ${TWO_SECOND_TIMEOUT});
|
||||
$262.agent.report(Date.now() - before);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
|
||||
assert.sameValue(getReport(), "ready");
|
||||
|
||||
Atomics.store(i64a, 0, 0x111111);
|
||||
|
||||
// We should expect that the waiting agents will continue to
|
||||
// wait until they both timeout. If either of them reports
|
||||
// a value that is less than the timeout value, it may mean that
|
||||
// calling Atomics.store(...) is causing the agents to wake.
|
||||
//
|
||||
var lapse = getReport();
|
||||
|
||||
assert(
|
||||
lapse >= TWO_SECOND_TIMEOUT,
|
||||
`${lapse} should be at least ${TWO_SECOND_TIMEOUT}`
|
||||
);
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Throws a TypeError if typedArray arg is not an BigInt64Array
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
5.If onlyInt32 is true, then
|
||||
If typeName is not "Int32Array" or "BigInt64Array", throw a TypeError exception.
|
||||
features: [Atomics, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray]
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
---*/
|
||||
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(new BigUint64Array(), poisoned, poisoned, poisoned);
|
||||
}, 'BigUint64Array');
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Throws a TypeError if typedArray.buffer is not a SharedArrayBuffer
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
|
||||
...
|
||||
4.If bufferData is a Data Block, return false.
|
||||
features: [ArrayBuffer, Atomics, TypedArray]
|
||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||
---*/
|
||||
|
||||
var i64a = new BigInt64Array(new ArrayBuffer(4));
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(i64a, 0, 0, 0);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(i64a, poisoned, poisoned, poisoned);
|
||||
});
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
A null value for bufferData throws a TypeError
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
|
||||
...
|
||||
3.If bufferData is null, return false.
|
||||
includes: [detachArrayBuffer.js]
|
||||
features: [ArrayBuffer, BigInt, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
var i64a = new BigInt64Array(new ArrayBuffer(1024));
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
$DETACHBUFFER(i64a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(i64a, poisoned, poisoned, poisoned);
|
||||
});
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Throws a RangeError if value of index arg is out of range
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
2.Let i be ? ValidateAtomicAccess(typedArray, index).
|
||||
...
|
||||
2.Let accessIndex be ? ToIndex(requestIndex).
|
||||
...
|
||||
5. If accessIndex ≥ length, throw a RangeError exception.
|
||||
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(4));
|
||||
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(i64a, Infinity, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(i64a, 2, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(i64a, 200, poisoned, poisoned);
|
||||
});
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Returns "not-equal" when value arg does not match an index in the typedArray
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
3.Let v be ? ToInt32(value).
|
||||
...
|
||||
14.If v is not equal to w, then
|
||||
a.Perform LeaveCriticalSection(WL).
|
||||
b. Return the String "not-equal".
|
||||
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
includes: [atomicsHelper.js, testBigIntTypedArray.js]
|
||||
---*/
|
||||
|
||||
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);
|
||||
|
||||
$262.agent.report(Atomics.store(i64a, 0, ${value}));
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0));
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
|
||||
assert.sameValue(getReport(), value.toString());
|
||||
assert.sameValue(getReport(), "not-equal");
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
// 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: >
|
||||
Get the correct WaiterList
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
...
|
||||
11. Let WL be GetWaiterList(block, indexedPosition).
|
||||
...
|
||||
|
||||
|
||||
GetWaiterList( block, i )
|
||||
|
||||
...
|
||||
4. Return the WaiterList that is referenced by the pair (block, i).
|
||||
|
||||
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);
|
||||
|
||||
// Wait on index 0
|
||||
Atomics.wait(i64a, 0, 0, 200);
|
||||
$262.agent.report("fail");
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
|
||||
// Wait on index 2
|
||||
Atomics.wait(i64a, 2, 0, 200);
|
||||
$262.agent.report("pass");
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var length = 4 * BigInt64Array.BYTES_PER_ELEMENT;
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(length));
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
$262.agent.sleep(10);
|
||||
|
||||
// Wake index 2
|
||||
Atomics.wake(i64a, 2, 1);
|
||||
|
||||
assert.sameValue(getReport(), "pass");
|
|
@ -0,0 +1,89 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
New waiters should be applied to the end of the list and woken by order they entered the list (FIFO)
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
16.Perform AddWaiter(WL, W).
|
||||
...
|
||||
3.Add W to the end of the list of waiters in WL.
|
||||
|
||||
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';
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
|
||||
$262.agent.report(${agent1});
|
||||
Atomics.wait(i64a, 0, 0);
|
||||
$262.agent.report(${agent1});
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
|
||||
$262.agent.report(${agent2});
|
||||
|
||||
Atomics.wait(i64a, 0, 0);
|
||||
$262.agent.report(${agent2});
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
|
||||
$262.agent.report(${agent3});
|
||||
|
||||
Atomics.wait(i64a, 0, 0);
|
||||
$262.agent.report(${agent3});
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(4));
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
|
||||
var orderWhichAgentsWereStarted = getReport() + getReport() + getReport(); // can be started in any order
|
||||
|
||||
assert.sameValue(Atomics.wake(i64a, 0, 1), 1);
|
||||
|
||||
var orderAgentsWereWoken = getReport();
|
||||
|
||||
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
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Test that Atomics.wait returns the right result when it was awoken before
|
||||
a timeout
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
2.Let i be ? ValidateAtomicAccess(typedArray, index).
|
||||
...
|
||||
2.Let accessIndex be ? ToIndex(requestIndex).
|
||||
|
||||
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
|
||||
...
|
||||
3.If bufferData is a Data Block, return false
|
||||
|
||||
If value is undefined, then
|
||||
Let index be 0.
|
||||
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.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var sab = new SharedArrayBuffer(4);
|
||||
var i64a = new BigInt64Array(sab);
|
||||
|
||||
|
||||
$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");
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// 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, SharedArrayBuffer, TypedArray]
|
||||
includes: [testAtomics.js, testBigIntTypedArray.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, 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");
|
|
@ -19,8 +19,8 @@ flags: [CanBlockIsFalse]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(4);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, 0, 0, 0);
|
||||
Atomics.wait(i32a, 0, 0, 0);
|
||||
});
|
||||
|
|
|
@ -19,25 +19,24 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab, id) {
|
||||
var ia = new Int32Array(sab);
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab, id) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var then = Date.now();
|
||||
$262.agent.report(Atomics.wait(ia, 0, 0, 500)); // Timeout 500ms
|
||||
$262.agent.report(Atomics.wait(i32a, 0, 0, 500)); // Timeout 500ms
|
||||
$262.agent.report(Date.now() - then); // Actual time can be more than 500ms
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
||||
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(ia.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
assert.sameValue(getReport(), "timed-out");
|
||||
assert.sameValue((getReport() | 0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ includes: [ atomicsHelper.js ]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -38,20 +38,20 @@ var toPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var start = Date.now();
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, false));
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, valueOf));
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, toPrimitive));
|
||||
$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(Date.now() - start);
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
|
@ -64,5 +64,5 @@ 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.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ flags: [CanBlockIsFalse]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
|
@ -31,7 +31,7 @@ var toPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, false), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, valueOf), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 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");
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@ features: [Atomics]
|
|||
// Let's assume 'wait' is not allowed on the main thread,
|
||||
// even in the shell.
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.start(`
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
|
@ -54,7 +53,7 @@ while ((r = getReport()) != "done") {
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -19,24 +19,24 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, NaN)); // NaN => +Infinity
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(i32a, 0, 0, NaN)); // NaN => +Infinity
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(500); // Ample time
|
||||
|
||||
assert.sameValue(Atomics.wake(int32Array, 0), 1);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 1);
|
||||
assert.sameValue(getReport(), "ok");
|
||||
|
|
|
@ -17,7 +17,7 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
|
|||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(sab);
|
||||
var i32a = new Int32Array(sab);
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
|
@ -25,14 +25,14 @@ var poisoned = {
|
|||
};
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, -Infinity, poisoned, poisoned);
|
||||
Atomics.wait(i32a, -Infinity, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, -7.999, poisoned, poisoned);
|
||||
Atomics.wait(i32a, -7.999, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, -1, poisoned, poisoned);
|
||||
Atomics.wait(i32a, -1, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, -300, poisoned, poisoned);
|
||||
Atomics.wait(i32a, -300, poisoned, poisoned);
|
||||
});
|
||||
|
|
|
@ -11,13 +11,12 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$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
|
||||
|
@ -26,8 +25,8 @@ $262.agent.receiveBroadcast(function(sab, id) {
|
|||
`);
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
assert.sameValue(getReport(), "timed-out");
|
||||
assert.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
|
|
@ -10,6 +10,6 @@ flags: [CanBlockIsFalse]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, -1), "timed-out");
|
||||
assert.sameValue(Atomics.wait(i32a, 0, 0, -1), "timed-out");
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
// 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: >
|
||||
Demonstrates that Atomics.store(...) is causing a waiting
|
||||
features: [Atomics, computed-property-names, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
const TWO_SECOND_TIMEOUT = 2000;
|
||||
const i32 = new Int32Array(
|
||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32 = new Int32Array(sab);
|
||||
var before = Date.now();
|
||||
$262.agent.report("ready");
|
||||
Atomics.wait(i32, 0, 0, ${TWO_SECOND_TIMEOUT});
|
||||
$262.agent.report(Date.now() - before);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.broadcast(i32.buffer);
|
||||
|
||||
assert.sameValue(getReport(), "ready");
|
||||
|
||||
Atomics.add(i32, 0, 1);
|
||||
|
||||
// We should expect that the waiting agents will continue to
|
||||
// wait until they both timeout. If either of them reports
|
||||
// a value that is less than the timeout value, it may mean that
|
||||
// calling Atomics.store(...) is causing the agents to wake.
|
||||
//
|
||||
var lapse = getReport();
|
||||
|
||||
assert(
|
||||
lapse >= TWO_SECOND_TIMEOUT,
|
||||
`${lapse} should be at least ${TWO_SECOND_TIMEOUT}`
|
||||
);
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// 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 actually waits and does not spuriously wake
|
||||
up when the memory value is changed.
|
||||
includes: [atomicsHelper.js]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab, id) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var then = Date.now();
|
||||
Atomics.wait(i32a, 0, 0);
|
||||
var diff = Date.now() - then; // Should be about 1000 ms but can be more
|
||||
$262.agent.report(diff);
|
||||
$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.store(i32a, 0, 1); // Change the value, should not wake the agent
|
||||
$262.agent.sleep(500); // Wait some more so that we can tell
|
||||
Atomics.wake(i32a, 0); // Really wake it up
|
||||
assert.sameValue((getReport() | 0) >= 1000 - $ATOMICS_MAX_TIME_EPSILON, true);
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
// 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: >
|
||||
Demonstrates that Atomics.store(...) is causing a waiting
|
||||
features: [Atomics, computed-property-names, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
const TWO_SECOND_TIMEOUT = 2000;
|
||||
const i32a = new Int32Array(
|
||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var before = Date.now();
|
||||
$262.agent.report("ready");
|
||||
Atomics.wait(i32a, 0, 0, ${TWO_SECOND_TIMEOUT});
|
||||
$262.agent.report(Date.now() - before);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
|
||||
assert.sameValue(getReport(), "ready");
|
||||
|
||||
Atomics.store(i32a, 0, 0x111111);
|
||||
|
||||
// We should expect that the waiting agents will continue to
|
||||
// wait until they both timeout. If either of them reports
|
||||
// a value that is less than the timeout value, it may mean that
|
||||
// calling Atomics.store(...) is causing the agents to wake.
|
||||
//
|
||||
var lapse = getReport();
|
||||
|
||||
assert(
|
||||
lapse >= TWO_SECOND_TIMEOUT,
|
||||
`${lapse} should be at least ${TWO_SECOND_TIMEOUT}`
|
||||
);
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ info: |
|
|||
features: [ArrayBuffer, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
var int32Array = new Int32Array(new ArrayBuffer(4));
|
||||
var i32a = new Int32Array(new ArrayBuffer(4));
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
|
@ -23,9 +23,9 @@ var poisoned = {
|
|||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, 0, 0, 0);
|
||||
Atomics.wait(i32a, 0, 0, 0);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, poisoned, poisoned, poisoned);
|
||||
Atomics.wait(i32a, poisoned, poisoned, poisoned);
|
||||
});
|
||||
|
|
|
@ -16,15 +16,15 @@ includes: [detachArrayBuffer.js]
|
|||
features: [ArrayBuffer, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
var int32Array = new Int32Array(new ArrayBuffer(1024));
|
||||
var i32a = new Int32Array(new ArrayBuffer(1024));
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
$DETACHBUFFER(int32Array.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
|
||||
$DETACHBUFFER(i32a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, poisoned, poisoned, poisoned);
|
||||
Atomics.wait(i32a, poisoned, poisoned, poisoned);
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ includes: [ atomicsHelper.js ]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -38,20 +38,20 @@ var toPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var start = Date.now();
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, null));
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, valueOf));
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, toPrimitive));
|
||||
$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(Date.now() - start);
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
|
@ -64,5 +64,5 @@ 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.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ flags: [CanBlockIsFalse]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
|
@ -31,7 +31,7 @@ var toPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, null), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, valueOf), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, toPrimitive), "timed-out");
|
||||
assert.sameValue(Atomics.wait(i32a, 0, 0, null), "timed-out");
|
||||
assert.sameValue(Atomics.wait(i32a, 0, 0, valueOf), "timed-out");
|
||||
assert.sameValue(Atomics.wait(i32a, 0, 0, toPrimitive), "timed-out");
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ includes: [ atomicsHelper.js ]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -45,20 +45,20 @@ var toPrimitive = {
|
|||
};
|
||||
|
||||
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var start = Date.now();
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, valueOf));
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, toString));
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, toPrimitive));
|
||||
$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(Date.now() - start);
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
|
@ -71,5 +71,5 @@ 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.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ flags: [CanBlockIsFalse]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
|
@ -40,6 +40,6 @@ var toPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, valueOf), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, toString), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 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");
|
||||
|
|
|
@ -16,7 +16,7 @@ info: |
|
|||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(4));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(4));
|
||||
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
|
@ -25,11 +25,11 @@ var poisoned = {
|
|||
};
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, Infinity, poisoned, poisoned);
|
||||
Atomics.wait(i32a, Infinity, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, 2, poisoned, poisoned);
|
||||
Atomics.wait(i32a, 2, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, 200, poisoned, poisoned);
|
||||
Atomics.wait(i32a, 200, poisoned, poisoned);
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ includes: [ atomicsHelper.js ]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -38,16 +38,16 @@ var poisonedToPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var start = Date.now();
|
||||
try {
|
||||
Atomics.wait(int32Array, 0, 0, poisonedValueOf);
|
||||
Atomics.wait(i32a, 0, 0, poisonedValueOf);
|
||||
} catch (error) {
|
||||
$262.agent.report("poisonedValueOf");
|
||||
}
|
||||
try {
|
||||
Atomics.wait(int32Array, 0, 0, poisonedToPrimitive);
|
||||
Atomics.wait(i32a, 0, 0, poisonedToPrimitive);
|
||||
} catch (error) {
|
||||
$262.agent.report("poisonedToPrimitive");
|
||||
}
|
||||
|
@ -56,9 +56,9 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
});
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(getReport(), "poisonedValueOf");
|
||||
|
@ -70,5 +70,5 @@ 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.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
|
@ -34,9 +34,9 @@ var poisonedToPrimitive = {
|
|||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, 0, poisonedValueOf);
|
||||
Atomics.wait(i32a, 0, 0, poisonedValueOf);
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, 0, poisonedToPrimitive);
|
||||
Atomics.wait(i32a, 0, 0, poisonedToPrimitive);
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ includes: [ atomicsHelper.js ]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -51,16 +51,16 @@ var poisonedToPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var start = Date.now();
|
||||
try {
|
||||
Atomics.wait(int32Array, Symbol("1"), poisonedValueOf, poisonedValueOf);
|
||||
Atomics.wait(i32a, Symbol("1"), poisonedValueOf, poisonedValueOf);
|
||||
} catch (error) {
|
||||
$262.agent.report('Symbol("1")');
|
||||
}
|
||||
try {
|
||||
Atomics.wait(int32Array, Symbol("2"), poisonedToPrimitive, poisonedToPrimitive);
|
||||
Atomics.wait(i32a, Symbol("2"), poisonedToPrimitive, poisonedToPrimitive);
|
||||
} catch (error) {
|
||||
$262.agent.report('Symbol("2")');
|
||||
}
|
||||
|
@ -69,9 +69,9 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
});
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(getReport(), 'Symbol("1")');
|
||||
|
@ -82,5 +82,5 @@ var timeDiffReport = 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.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
|
@ -44,17 +44,17 @@ var poisonedToPrimitive = {
|
|||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, poisonedValueOf, poisonedValueOf, poisonedValueOf);
|
||||
Atomics.wait(i32a, poisonedValueOf, poisonedValueOf, poisonedValueOf);
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive);
|
||||
Atomics.wait(i32a, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, Symbol("foo"), poisonedValueOf, poisonedValueOf);
|
||||
Atomics.wait(i32a, Symbol("foo"), poisonedValueOf, poisonedValueOf);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, Symbol("foo"), poisonedToPrimitive, poisonedToPrimitive);
|
||||
Atomics.wait(i32a, Symbol("foo"), poisonedToPrimitive, poisonedToPrimitive);
|
||||
});
|
||||
|
|
|
@ -18,23 +18,22 @@ includes: [ atomicsHelper.js ]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var start = Date.now();
|
||||
try {
|
||||
Atomics.wait(int32Array, 0, 0, Symbol("1"));
|
||||
Atomics.wait(i32a, 0, 0, Symbol("1"));
|
||||
} catch (error) {
|
||||
$262.agent.report('Symbol("1")');
|
||||
}
|
||||
try {
|
||||
Atomics.wait(int32Array, 0, 0, Symbol("2"));
|
||||
Atomics.wait(i32a, 0, 0, Symbol("2"));
|
||||
} catch (error) {
|
||||
$262.agent.report('Symbol("2")');
|
||||
}
|
||||
|
@ -43,9 +42,9 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
});
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(getReport(), 'Symbol("1")');
|
||||
|
@ -56,4 +55,4 @@ var timeDiffReport = 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.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
|
|
@ -16,7 +16,7 @@ features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
|
@ -31,17 +31,17 @@ var poisonedToPrimitive = {
|
|||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, 0, poisonedValueOf);
|
||||
Atomics.wait(i32a, 0, 0, poisonedValueOf);
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, 0, poisonedToPrimitive);
|
||||
Atomics.wait(i32a, 0, 0, poisonedToPrimitive);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, 0, 0, Symbol("foo"));
|
||||
Atomics.wait(i32a, 0, 0, Symbol("foo"));
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, 0, 0, Symbol("foo"));
|
||||
Atomics.wait(i32a, 0, 0, Symbol("foo"));
|
||||
});
|
||||
|
|
|
@ -23,13 +23,12 @@ includes: [ atomicsHelper.js ]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.start(`
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
|
@ -42,16 +41,16 @@ var poisonedToPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var start = Date.now();
|
||||
try {
|
||||
Atomics.wait(int32Array, 0, Symbol("1"), poisonedValueOf);
|
||||
Atomics.wait(i32a, 0, Symbol("1"), poisonedValueOf);
|
||||
} catch (error) {
|
||||
$262.agent.report('Symbol("1")');
|
||||
}
|
||||
try {
|
||||
Atomics.wait(int32Array, 0, Symbol("2"), poisonedToPrimitive);
|
||||
Atomics.wait(i32a, 0, Symbol("2"), poisonedToPrimitive);
|
||||
} catch (error) {
|
||||
$262.agent.report('Symbol("2")');
|
||||
}
|
||||
|
@ -60,9 +59,9 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
});
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(getReport(), 'Symbol("1")');
|
||||
|
@ -73,4 +72,4 @@ var timeDiffReport = 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.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
|
|
@ -20,7 +20,7 @@ features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
|
@ -35,18 +35,18 @@ var poisonedToPrimitive = {
|
|||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, poisonedValueOf, poisonedValueOf);
|
||||
Atomics.wait(i32a, 0, poisonedValueOf, poisonedValueOf);
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, poisonedToPrimitive, poisonedToPrimitive);
|
||||
Atomics.wait(i32a, 0, poisonedToPrimitive, poisonedToPrimitive);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, 0, Symbol("foo"), poisonedValueOf);
|
||||
Atomics.wait(i32a, 0, Symbol("foo"), poisonedValueOf);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, 0, Symbol("foo"), poisonedToPrimitive);
|
||||
Atomics.wait(i32a, 0, Symbol("foo"), poisonedToPrimitive);
|
||||
});
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ includes: [ atomicsHelper.js ]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -38,20 +38,20 @@ var toPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
var start = Date.now();
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, true));
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, valueOf));
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, toPrimitive));
|
||||
$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(Date.now() - start);
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
|
@ -64,5 +64,5 @@ 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.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ flags: [CanBlockIsFalse]
|
|||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
var i32a = new Int32Array(buffer);
|
||||
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
|
@ -31,7 +31,7 @@ var toPrimitive = {
|
|||
}
|
||||
};
|
||||
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, true), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, valueOf), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 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");
|
||||
|
||||
|
|
|
@ -22,38 +22,37 @@ var WAKECOUNT = 2; // Total number of agents to wake up
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("A " + Atomics.wait(int32Array, 0, 0, undefined)); // undefined => NaN => +Infinity
|
||||
$262.agent.start(`
|
||||
$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) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("B " + Atomics.wait(int32Array, 0, 0)); // undefined timeout arg => NaN => +Infinity
|
||||
$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 int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
|
||||
$262.agent.sleep(500); // Ample time
|
||||
|
||||
assert.sameValue($262.agent.getReport(), null);
|
||||
|
||||
assert.sameValue(Atomics.wake(int32Array, WAKEUP, WAKECOUNT), WAKECOUNT);
|
||||
assert.sameValue(Atomics.wake(i32a, WAKEUP, WAKECOUNT), WAKECOUNT);
|
||||
|
||||
var sortedReports = [];
|
||||
for (var i = 0; i < NUMAGENT; i++) {
|
||||
|
|
|
@ -20,31 +20,30 @@ info: |
|
|||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(int32Array, undefined, 0, 1000)); // undefined index => 0
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var 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 int32Array = new Int32Array(sab);
|
||||
var i32a = new Int32Array(sab);
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
|
||||
$262.agent.sleep(150);
|
||||
|
||||
assert.sameValue(Atomics.wake(int32Array, 0), 1); // wake at index 0
|
||||
assert.sameValue(Atomics.wake(int32Array, 0), 0); // wake again at index 0, and 0 agents should be woken
|
||||
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(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -21,29 +21,26 @@ includes: [atomicsHelper.js]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
var value = 42;
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(Atomics.store(int32Array, 0, ${value}));
|
||||
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0));
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(Atomics.store(i32a, 0, ${value}));
|
||||
$262.agent.report(Atomics.wait(i32a, 0, 0));
|
||||
$262.agent.leaving();
|
||||
})
|
||||
});
|
||||
`);
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
|
||||
assert.sameValue(getReport(), value.toString());
|
||||
assert.sameValue(getReport(), "not-equal");
|
||||
|
|
|
@ -18,27 +18,24 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 44, 1000));
|
||||
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 251.4, 1000));
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var 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 int32Array = new Int32Array(new SharedArrayBuffer(1024));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(1024));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
|
||||
$262.agent.sleep(200);
|
||||
|
||||
|
@ -46,4 +43,4 @@ $262.agent.sleep(200);
|
|||
assert.sameValue(getReport(), "not-equal");
|
||||
assert.sameValue(getReport(), "not-equal");
|
||||
|
||||
assert.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
|
|
@ -30,10 +30,10 @@ function getReport() {
|
|||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32 = new Int32Array(sab);
|
||||
var i32a = new Int32Array(sab);
|
||||
|
||||
// Wait on index 0
|
||||
Atomics.wait(i32, 0, 0, 200);
|
||||
Atomics.wait(i32a, 0, 0, 200);
|
||||
$262.agent.report("fail");
|
||||
$262.agent.leaving();
|
||||
});
|
||||
|
@ -41,22 +41,22 @@ $262.agent.receiveBroadcast(function(sab) {
|
|||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32 = new Int32Array(sab);
|
||||
var i32a = new Int32Array(sab);
|
||||
|
||||
// Wait on index 2
|
||||
Atomics.wait(i32, 2, 0, 200);
|
||||
Atomics.wait(i32a, 2, 0, 200);
|
||||
$262.agent.report("pass");
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var length = 4 * Int32Array.BYTES_PER_ELEMENT;
|
||||
var i32 = new Int32Array(new SharedArrayBuffer(length));
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(length));
|
||||
|
||||
$262.agent.broadcast(i32.buffer);
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(10);
|
||||
|
||||
// Wake index 2
|
||||
Atomics.wake(i32, 2, 1);
|
||||
Atomics.wake(i32a, 2, 1);
|
||||
|
||||
assert.sameValue(getReport(), "pass");
|
||||
|
|
|
@ -18,7 +18,7 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -27,9 +27,8 @@ var agent1 = '1';
|
|||
var agent2 = '2';
|
||||
var agent3 = '3';
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent1});
|
||||
|
@ -37,12 +36,11 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
$262.agent.report(${agent1});
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent2});
|
||||
|
@ -51,12 +49,11 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
$262.agent.report(${agent2});
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent3});
|
||||
|
@ -65,7 +62,7 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
$262.agent.report(${agent3});
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
});
|
||||
`);
|
||||
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ function getReport() {
|
|||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, ${timeout}));
|
||||
|
|
|
@ -11,14 +11,13 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab, id) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab, id) {
|
||||
var ia = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(ia, 0, 0)); // No timeout => Infinity
|
||||
$262.agent.leaving();
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wake
|
||||
description: >
|
||||
Test range checking of Atomics.wake on arrays that allow atomic operations
|
||||
info: |
|
||||
Atomics.wake( typedArray, index, count )
|
||||
|
||||
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
..
|
||||
|
||||
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);
|
||||
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.wake(view, IdxGen(i64a), 0));
|
||||
});
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wake
|
||||
description: >
|
||||
Throws a TypeError if typedArray arg is not an BigInt64Array
|
||||
info: |
|
||||
Atomics.wake( typedArray, index, count )
|
||||
|
||||
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
5.If onlyInt32 is true, then
|
||||
If typeName is not "BigInt64Array", throw a TypeError exception.
|
||||
features: [Atomics, BigInt]
|
||||
---*/
|
||||
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wake(new BigUint64Array(), poisoned, poisoned);
|
||||
}, 'BigUint64Array');
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-atomics.wake
|
||||
description: >
|
||||
Throws a TypeError if typedArray.buffer is not a SharedArrayBuffer
|
||||
info: |
|
||||
Atomics.wake( typedArray, index, count )
|
||||
|
||||
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
|
||||
...
|
||||
4.If bufferData is a Data Block, return false.
|
||||
features: [ArrayBuffer, BigInt, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
var i64a = new BigInt64Array(new ArrayBuffer(4));
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wake(i64a, 0, 0);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wake(i64a, poisoned, poisoned);
|
||||
});
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-atomics.wake
|
||||
description: >
|
||||
A null value for bufferData throws a TypeError
|
||||
info: |
|
||||
Atomics.wake( typedArray, index, count )
|
||||
|
||||
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
|
||||
...
|
||||
3.If bufferData is null, return false.
|
||||
includes: [detachArrayBuffer.js]
|
||||
features: [ArrayBuffer, BigInt, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
var i64a = new BigInt64Array(new ArrayBuffer(1024));
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
// Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
|
||||
$DETACHBUFFER(i64a.buffer);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wake(i64a, poisoned, poisoned);
|
||||
});
|
|
@ -0,0 +1,78 @@
|
|||
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wake
|
||||
description: >
|
||||
Test that Atomics.wake wakes all waiters on a location, but does not
|
||||
wake waiters on other locations.
|
||||
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;
|
||||
|
||||
for (var i = 0; i < NUMAGENT; i++) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var 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);
|
||||
Atomics.add(i64a, ${RUNNING}, 1);
|
||||
// This will always time out.
|
||||
$262.agent.report("B " + Atomics.wait(i64a, ${DUMMY}, 0, 10));
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(NUMELEM * BigInt64Array.BYTES_PER_ELEMENT));
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
|
||||
// Wait for agents to be running.
|
||||
waitUntil(i64a, RUNNING, NUMAGENT + 1);
|
||||
|
||||
// Then wait some more to give the agents a fair chance to wait. If we don't,
|
||||
// we risk sending the wakeup before agents are sleeping, and we hang.
|
||||
$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);
|
||||
|
||||
var rs = [];
|
||||
for (var i = 0; i < NUMAGENT + 1; i++) {
|
||||
rs.push(getReport());
|
||||
}
|
||||
rs.sort();
|
||||
|
||||
for (var i = 0; i < NUMAGENT; i++) {
|
||||
assert.sameValue(rs[i], "A ok");
|
||||
}
|
||||
assert.sameValue(rs[NUMAGENT], "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");
|
||||
}
|
|
@ -27,7 +27,7 @@ function getReport() {
|
|||
}
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("A " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50));
|
||||
$262.agent.leaving();
|
||||
|
@ -35,7 +35,7 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("B " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50));
|
||||
$262.agent.leaving();
|
||||
|
@ -43,7 +43,7 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("C " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50));
|
||||
$262.agent.leaving();
|
||||
|
@ -51,7 +51,7 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("D " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50));
|
||||
$262.agent.leaving();
|
||||
|
|
|
@ -18,13 +18,14 @@ var WAKEUP = 0; // Index all agents are waiting on
|
|||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("A " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50));
|
||||
$262.agent.leaving();
|
||||
|
@ -32,7 +33,7 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("B " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50));
|
||||
$262.agent.leaving();
|
||||
|
@ -41,7 +42,7 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("C " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50));
|
||||
$262.agent.leaving();
|
||||
|
@ -50,7 +51,7 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("D " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50));
|
||||
$262.agent.leaving();
|
||||
|
|
|
@ -8,9 +8,8 @@ description: >
|
|||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var ia = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We will timeout eventually
|
||||
$262.agent.leaving();
|
||||
|
@ -26,7 +25,8 @@ assert.sameValue(getReport(), "timed-out");
|
|||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
$262.agent.sleep(100);
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
|
|||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, 200));
|
||||
$262.agent.leaving();
|
||||
|
@ -34,7 +34,7 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
|
||||
;$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0, 200));
|
||||
$262.agent.leaving();
|
||||
|
@ -57,7 +57,7 @@ assert.sameValue(getReport(), "ok");
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -17,9 +17,8 @@ var NUMELEM = 3;
|
|||
var NUMAGENT = 3;
|
||||
|
||||
for (var i=0; i < NUMAGENT; i++) {
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var ia = new Int32Array(sab);
|
||||
Atomics.add(ia, ${RUNNING}, 1);
|
||||
$262.agent.report("A " + Atomics.wait(ia, ${WAKEUP}, 0));
|
||||
|
@ -28,9 +27,8 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
`);
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var ia = new Int32Array(sab);
|
||||
Atomics.add(ia, ${RUNNING}, 1);
|
||||
// This will always time out.
|
||||
|
|
|
@ -16,9 +16,8 @@ var NUMELEM = 3;
|
|||
var NUMAGENT = 3;
|
||||
|
||||
for (var i=0; i < NUMAGENT; i++) {
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var ia = new Int32Array(sab);
|
||||
Atomics.add(ia, ${RUNNING}, 1);
|
||||
$262.agent.report("A " + Atomics.wait(ia, ${WAKEUP}, 0));
|
||||
|
@ -27,9 +26,8 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||
`);
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var ia = new Int32Array(sab);
|
||||
Atomics.add(ia, ${RUNNING}, 1);
|
||||
// This will always time out.
|
||||
|
|
|
@ -20,9 +20,8 @@ var NUMELEM = RUNNING + 1;
|
|||
// one by one and observe the wakeup order.
|
||||
|
||||
for ( var i=0 ; i < NUMAGENT ; i++ ) {
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var ia = new Int32Array(sab);
|
||||
Atomics.add(ia, ${RUNNING}, 1);
|
||||
while (Atomics.load(ia, ${SPIN + i}) === 0)
|
||||
|
|
|
@ -8,9 +8,8 @@ description: >
|
|||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var ia = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We will timeout eventually
|
||||
$262.agent.leaving();
|
||||
|
@ -27,7 +26,7 @@ assert.sameValue(getReport(), "timed-out");
|
|||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -17,9 +17,8 @@ var NUMELEM = 2;
|
|||
var WAKECOUNT = 1;
|
||||
|
||||
for ( var i=0 ; i < NUMAGENT ; i++ ) {
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var ia = new Int32Array(sab);
|
||||
Atomics.add(ia, ${RUNNING}, 1);
|
||||
// Waiters that are not woken will time out eventually.
|
||||
|
|
|
@ -25,8 +25,7 @@ function waitUntil(ia, k, value) {
|
|||
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var ia = new Int32Array(sab);
|
||||
Atomics.add(ia, 1, 1);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue