Skip to content
Snippets Groups Projects
Commit 84f448f0 authored by Rick Waldron's avatar Rick Waldron
Browse files

Atomics: fix buffer sizes

parent 5ebd632d
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ function getReport() { ...@@ -35,7 +35,7 @@ function getReport() {
* @param {Number} index The index of which all agents will report. * @param {Number} index The index of which all agents will report.
* @param {Number} expected The number of agents that are expected to report as active. * @param {Number} expected The number of agents that are expected to report as active.
*/ */
function waitUntil(i32a, index, expected ) { function waitUntil(i32a, index, expected) {
var i = 0; var i = 0;
while (Atomics.load(i32a, index) !== expected && i < 15) { while (Atomics.load(i32a, index) !== expected && i < 15) {
$262.agent.sleep(10); $262.agent.sleep(10);
......
...@@ -27,7 +27,7 @@ const poisoned = { ...@@ -27,7 +27,7 @@ const poisoned = {
}; };
try { try {
$DETACHBUFFER(i64a.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
} catch (error) { } catch (error) {
$ERROR(`An unexpected error occurred when detaching ArrayBuffer: ${error.message}`); $ERROR(`An unexpected error occurred when detaching ArrayBuffer: ${error.message}`);
} }
......
...@@ -38,9 +38,6 @@ const i32a = new Int32Array( ...@@ -38,9 +38,6 @@ const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT) new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
); );
const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(i32a.buffer); $262.agent.broadcast(i32a.buffer);
$262.agent.sleep(150); $262.agent.sleep(150);
......
...@@ -41,7 +41,7 @@ $262.agent.broadcast(i32a.buffer); ...@@ -41,7 +41,7 @@ $262.agent.broadcast(i32a.buffer);
// Wait for agents to be running. // Wait for agents to be running.
waitUntil(i32a, RUNNING, NUMAGENT); waitUntil(i32a, RUNNING, NUMAGENT);
// Then wait some more to give the agents a fair chance to wait. If we don't, // Sleep to allow the agents a fair chance to wait. If we don't,
// we risk sending the wakeup before agents are sleeping, and we hang. // we risk sending the wakeup before agents are sleeping, and we hang.
$262.agent.sleep(50); $262.agent.sleep(50);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
esid: sec-atomics.wake esid: sec-atomics.wake
description: > description: >
Test that Atomics.wake wakes zero waiters if the count is NaN Test that Atomics.wake wakes zero waiters if the count is NaN
includes: [testAtomics.js] includes: [atomicsHelper.js,testAtomics.js]
features: [ArrayBuffer, DataView, let, arrow-function, for-of, Atomics, BigInt, SharedArrayBuffer, TypedArray] features: [ArrayBuffer, DataView, let, arrow-function, for-of, Atomics, BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
......
...@@ -19,7 +19,7 @@ $262.agent.start(` ...@@ -19,7 +19,7 @@ $262.agent.start(`
`); `);
const i32a = new Int32Array( const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT) new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)
); );
$262.agent.broadcast(i32a.buffer); $262.agent.broadcast(i32a.buffer);
...@@ -28,12 +28,7 @@ waitUntil(i32a, 1, 1); ...@@ -28,12 +28,7 @@ waitUntil(i32a, 1, 1);
assert.sameValue(Atomics.wake(i32a, 0, 1), 1, 'Atomics.wake(i32a, 0, 1) returns 1'); assert.sameValue(Atomics.wake(i32a, 0, 1), 1, 'Atomics.wake(i32a, 0, 1) returns 1');
$262.agent.sleep(10); assert.sameValue(getReport(), 'ok', 'The value of `report` is "ok"');
// Collect and check results
var report = getReport();
assert.sameValue(report, 'ok', 'The value of `report` is "ok"');
// Already awake, this should be a noop // Already awake, this should be a noop
assert.sameValue(Atomics.wake(i32a, 0, 1), 0, 'Atomics.wake(i32a, 0, 1) returns 0'); assert.sameValue(Atomics.wake(i32a, 0, 1), 0, 'Atomics.wake(i32a, 0, 1) returns 0');
......
...@@ -29,7 +29,7 @@ for (var i = 0; i < NUMAGENT; i++ ) { ...@@ -29,7 +29,7 @@ for (var i = 0; i < NUMAGENT; i++ ) {
} }
const i32a = new Int32Array( const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT) new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
); );
$262.agent.broadcast(i32a.buffer); $262.agent.broadcast(i32a.buffer);
......
...@@ -19,7 +19,7 @@ $262.agent.start(` ...@@ -19,7 +19,7 @@ $262.agent.start(`
`); `);
const i32a = new Int32Array( const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT) new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)
); );
$262.agent.broadcast(i32a.buffer); $262.agent.broadcast(i32a.buffer);
......
...@@ -20,7 +20,7 @@ $262.agent.start(` ...@@ -20,7 +20,7 @@ $262.agent.start(`
`); `);
const i32a = new Int32Array( const i32a = new Int32Array(
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT) new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)
); );
$262.agent.broadcast(i32a.buffer); $262.agent.broadcast(i32a.buffer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment