mirror of https://github.com/tc39/test262.git
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() {
|
||||
|
|
|
@ -24,18 +24,21 @@ 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
|
||||
$262.agent.report($262.agent.monotonicNow() - then); // Actual time can be more than 500ms
|
||||
$262.agent.leaving();
|
||||
});
|
||||
$262.agent.receiveBroadcast(function(sab, id) {
|
||||
const i64a = new BigInt64Array(sab);
|
||||
const then = $262.agent.monotonicNow();
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, 500)); // Timeout 500ms
|
||||
$262.agent.report($262.agent.monotonicNow() - then); // Actual time can be more than 500ms
|
||||
$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);
|
||||
|
||||
|
|
|
@ -24,43 +24,45 @@ function getReport() {
|
|||
}
|
||||
|
||||
$262.agent.start(`
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var toPrimitive = {
|
||||
[Symbol.toPrimitive]: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
var toPrimitive = {
|
||||
[Symbol.toPrimitive]: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
var start = $262.agent.monotonicNow();
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, false));
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, valueOf));
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, toPrimitive));
|
||||
$262.agent.report($262.agent.monotonicNow() - start);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
var start = $262.agent.monotonicNow();
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, false));
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, valueOf));
|
||||
$262.agent.report(Atomics.wait(i64a, 0, 0, toPrimitive));
|
||||
$262.agent.report($262.agent.monotonicNow() - start);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -13,34 +13,34 @@ features: [Atomics, BigInt]
|
|||
// even in the shell.
|
||||
|
||||
$262.agent.start(`
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var good_indices = [ (view) => 0/-1, // -0
|
||||
(view) => '-0',
|
||||
(view) => view.length - 1,
|
||||
(view) => ({ valueOf: () => 0 }),
|
||||
(view) => ({ toString: () => '0', valueOf: false }) // non-callable valueOf triggers invocation of toString
|
||||
];
|
||||
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);
|
||||
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));
|
||||
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));
|
||||
}
|
||||
// In-bounds boundary cases for indexing
|
||||
for ( let IdxGen of good_indices ) {
|
||||
let Idx = IdxGen(view);
|
||||
view.fill(0);
|
||||
// Atomics.store() computes an index from Idx in the same way as other
|
||||
// Atomics operations, not quite like view[Idx].
|
||||
Atomics.store(view, Idx, 37);
|
||||
$262.agent.report("C " + Atomics.wait(view, Idx, 0));
|
||||
}
|
||||
|
||||
$262.agent.report("done");
|
||||
$262.agent.leaving();
|
||||
$262.agent.report("done");
|
||||
$262.agent.leaving();
|
||||
`);
|
||||
|
||||
assert.sameValue(getReport(), "A timed-out");
|
||||
|
|
|
@ -24,19 +24,19 @@ function getReport() {
|
|||
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();
|
||||
});
|
||||
$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));
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -17,15 +17,16 @@ function getReport() {
|
|||
}
|
||||
|
||||
$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();
|
||||
});
|
||||
$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);
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -28,19 +28,22 @@ function getReport() {
|
|||
var value = 42;
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
$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();
|
||||
});
|
||||
$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));
|
||||
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');
|
||||
|
||||
|
|
|
@ -29,34 +29,39 @@ function getReport() {
|
|||
}
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
$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();
|
||||
});
|
||||
// Wait on index 0
|
||||
Atomics.wait(i64a, 0, 0, 200);
|
||||
$262.agent.report(0);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i64a = new BigInt64Array(sab);
|
||||
$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();
|
||||
});
|
||||
// Wait on index 2
|
||||
Atomics.wait(i64a, 2, 0, 200);
|
||||
$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;
|
||||
}
|
||||
|
|
|
@ -29,25 +29,25 @@ function getReport() {
|
|||
}
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
|
||||
// Wait on index 0
|
||||
Atomics.wait(i32a, 0, 0, 200);
|
||||
$262.agent.report("fail");
|
||||
$262.agent.leaving();
|
||||
});
|
||||
// Wait on index 0
|
||||
Atomics.wait(i32a, 0, 0, 200);
|
||||
$262.agent.report(0);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32a = new Int32Array(sab);
|
||||
|
||||
// Wait on index 2
|
||||
Atomics.wait(i32a, 2, 0, 200);
|
||||
$262.agent.report("pass");
|
||||
$262.agent.leaving();
|
||||
});
|
||||
// Wait on index 2
|
||||
Atomics.wait(i32a, 2, 0, 200);
|
||||
$262.agent.report(0);
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var length = 4 * Int32Array.BYTES_PER_ELEMENT;
|
||||
|
@ -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,46 +23,41 @@ 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);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
const i32a = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent1});
|
||||
Atomics.wait(i32a, 0, 0);
|
||||
$262.agent.report(${agent1});
|
||||
|
||||
$262.agent.leaving();
|
||||
});
|
||||
$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);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
const i32a = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent2});
|
||||
|
||||
Atomics.wait(i32a, 0, 0);
|
||||
$262.agent.report(${agent2});
|
||||
|
||||
$262.agent.leaving();
|
||||
});
|
||||
$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);
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
const i32a = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent3});
|
||||
|
||||
Atomics.wait(i32a, 0, 0);
|
||||
$262.agent.report(${agent3});
|
||||
|
||||
$262.agent.leaving();
|
||||
});
|
||||
$262.agent.report(${agent3});
|
||||
Atomics.wait(i32a, 0, 0);
|
||||
$262.agent.report(${agent3});
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue