mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 05:55:36 +02:00
Atomics: wait/bigint cleanup
This commit is contained in:
parent
ab72a55748
commit
daa9af846d
@ -18,7 +18,7 @@ features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(4);
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
var i64a = new BigInt64Array(buffer);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
|
@ -25,17 +25,20 @@ function getReport() {
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab, id) {
|
||||
var ia = new BigInt64Array(sab);
|
||||
var then = $262.agent.monotonicNow();
|
||||
$262.agent.report(Atomics.wait(ia, 0, 0, 500)); // Timeout 500ms
|
||||
const i64a = new BigInt64Array(sab);
|
||||
const then = $262.agent.monotonicNow();
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, 500)); // Timeout 500ms
|
||||
$262.agent.report($262.agent.monotonicNow() - then); // Actual time can be more than 500ms
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var ia = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.broadcast(ia.buffer);
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
$262.agent.sleep(100);
|
||||
assert.sameValue(getReport(), "timed-out");
|
||||
assert.sameValue((getReport() | 0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true);
|
||||
|
||||
|
@ -47,20 +47,22 @@ $262.agent.receiveBroadcast(function(sab) {
|
||||
});
|
||||
`);
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
$262.agent.sleep(100);
|
||||
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
|
||||
var timeDiffReport = getReport();
|
||||
var lapse = getReport();
|
||||
|
||||
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
|
||||
assert(lapse >= 0, 'timeout should be a min of 0ms');
|
||||
|
||||
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
|
||||
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
|
||||
|
||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
||||
|
||||
|
@ -24,8 +24,7 @@ function getReport() {
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, NaN)); // NaN => +Infinity
|
||||
@ -33,10 +32,11 @@ $262.agent.receiveBroadcast(function(sab) {
|
||||
});
|
||||
`);
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
$262.agent.sleep(500); // Ample time
|
||||
|
||||
$262.agent.sleep(100);
|
||||
assert.sameValue(Atomics.wake(i64a, 0), 1);
|
||||
assert.sameValue(getReport(), "ok");
|
||||
|
@ -16,9 +16,10 @@ info: |
|
||||
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var i64a = new BigInt64Array(sab);
|
||||
var poisoned = {
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
const poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
|
@ -24,8 +24,9 @@ $262.agent.receiveBroadcast(function(sab, id) {
|
||||
});
|
||||
`);
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var i64a = new BigInt64Array(buffer);
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
assert.sameValue(getReport(), "timed-out");
|
||||
|
@ -9,7 +9,8 @@ features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var i64a = new BigInt64Array(buffer);
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
assert.sameValue(Atomics.wait(i64a, 0, 0, -1), "timed-out");
|
||||
|
@ -16,9 +16,11 @@ info: |
|
||||
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(4));
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
var poisoned = {
|
||||
const poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
|
@ -37,10 +37,13 @@ $262.agent.receiveBroadcast(function(sab) {
|
||||
});
|
||||
`);
|
||||
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT));
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
$262.agent.sleep(100);
|
||||
|
||||
assert.sameValue(getReport(), value.toString());
|
||||
assert.sameValue(getReport(), "not-equal");
|
||||
assert.sameValue(getReport(), 'not-equal');
|
||||
|
||||
|
@ -34,7 +34,7 @@ $262.agent.receiveBroadcast(function(sab) {
|
||||
|
||||
// Wait on index 0
|
||||
Atomics.wait(i64a, 0, 0, 200);
|
||||
$262.agent.report("fail");
|
||||
$262.agent.report(0);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
@ -45,18 +45,23 @@ $262.agent.receiveBroadcast(function(sab) {
|
||||
|
||||
// Wait on index 2
|
||||
Atomics.wait(i64a, 2, 0, 200);
|
||||
$262.agent.report("pass");
|
||||
$262.agent.report(2);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var length = 4 * BigInt64Array.BYTES_PER_ELEMENT;
|
||||
var i64a = new BigInt64Array(new SharedArrayBuffer(length));
|
||||
const i64a = new BigInt64Array(
|
||||
new SharedArrayBuffer(4 * BigInt64Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.broadcast(i64a.buffer);
|
||||
$262.agent.sleep(10);
|
||||
|
||||
// Wake index 2
|
||||
Atomics.wake(i64a, 2, 1);
|
||||
assert.sameValue(getReport(), "2");
|
||||
|
||||
// Wake index 0
|
||||
Atomics.wake(i64a, 2, 1);
|
||||
assert.sameValue(getReport(), "0");
|
||||
|
||||
assert.sameValue(getReport(), "pass");
|
||||
|
@ -24,8 +24,7 @@ function getReport() {
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.start(`
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
return false;
|
||||
@ -49,20 +48,22 @@ $262.agent.receiveBroadcast(function(sab) {
|
||||
});
|
||||
`);
|
||||
|
||||
var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
const i32a = new Int32Array(
|
||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
$262.agent.broadcast(i32a.buffer);
|
||||
$262.agent.sleep(150);
|
||||
$262.agent.sleep(100);
|
||||
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
assert.sameValue(getReport(), 'timed-out');
|
||||
|
||||
var timeDiffReport = getReport();
|
||||
var lapse = getReport();
|
||||
|
||||
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
|
||||
assert(lapse >= 0, 'timeout should be a min of 0ms');
|
||||
|
||||
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
|
||||
assert(lapse <= $ATOMICS_MAX_TIME_EPSILON, `timeout should be a max of ${$ATOMICS_MAX_TIME_EPSILON}`);
|
||||
|
||||
assert.sameValue(Atomics.wake(i32a, 0), 0);
|
||||
|
||||
|
@ -16,16 +16,17 @@ features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var i32a = new Int32Array(buffer);
|
||||
const i32a = new Int32Array(
|
||||
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
|
||||
);
|
||||
|
||||
var valueOf = {
|
||||
const valueOf = {
|
||||
valueOf: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var toPrimitive = {
|
||||
const toPrimitive = {
|
||||
[Symbol.toPrimitive]: function() {
|
||||
return false;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ $262.agent.receiveBroadcast(function(sab) {
|
||||
|
||||
// Wait on index 0
|
||||
Atomics.wait(i32a, 0, 0, 200);
|
||||
$262.agent.report("fail");
|
||||
$262.agent.report(0);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
@ -45,7 +45,7 @@ $262.agent.receiveBroadcast(function(sab) {
|
||||
|
||||
// Wait on index 2
|
||||
Atomics.wait(i32a, 2, 0, 200);
|
||||
$262.agent.report("pass");
|
||||
$262.agent.report(0);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
@ -58,5 +58,8 @@ $262.agent.sleep(10);
|
||||
|
||||
// Wake index 2
|
||||
Atomics.wake(i32a, 2, 1);
|
||||
assert.sameValue(getReport(), '2');
|
||||
|
||||
assert.sameValue(getReport(), "pass");
|
||||
// Wake index 0
|
||||
Atomics.wake(i32a, 2, 1);
|
||||
assert.sameValue(getReport(), '0');
|
||||
|
@ -23,44 +23,39 @@ function getReport() {
|
||||
return r;
|
||||
}
|
||||
|
||||
var agent1 = '1';
|
||||
var agent2 = '2';
|
||||
var agent3 = '3';
|
||||
const agent1 = '1';
|
||||
const agent2 = '2';
|
||||
const agent3 = '3';
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
const i32a = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent1});
|
||||
Atomics.wait(i32a, 0, 0);
|
||||
$262.agent.report(${agent1});
|
||||
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
const i32a = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent2});
|
||||
|
||||
Atomics.wait(i32a, 0, 0);
|
||||
$262.agent.report(${agent2});
|
||||
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
const i32a = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent3});
|
||||
|
||||
Atomics.wait(i32a, 0, 0);
|
||||
$262.agent.report(${agent3});
|
||||
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user