From e4883091b93c98338dc81ae0e6b9a7f1754ca09d Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Thu, 15 Nov 2018 15:27:01 -0500 Subject: [PATCH 1/3] Introduce $262.agent.safeBroadcast and migrate Atomics tests. Migrating all tests to this API is necessary to prevent tests from hanging indefinitely when a SAB is sent to a worker but the code in the worker attempts to create a non-sharable TypedArray (something that is not Int32Array or BigInt64Array). When that scenario occurs, an exception is thrown and the agent worker can no longer communicate with any other threads that control the SAB. If the main thread happens to be spinning in the $262.agent.waitUntil() while loop, it will never meet its termination condition and the test will hang indefinitely. Because we've defined $262.agent.broadcast(SAB) in https://github.com/tc39/test262/blob/master/INTERPRETING.md, there are host implementations that assume compatibility, which must be maintained. --- INTERPRETING.md | 21 ++++---- harness/atomicsHelper.js | 50 +++++++++++++++++-- .../notify/bigint/notify-all-on-loc.js | 2 +- .../count-defaults-to-infinity-missing.js | 2 +- .../count-defaults-to-infinity-undefined.js | 2 +- .../Atomics/notify/negative-count.js | 2 +- .../Atomics/notify/notify-all-on-loc.js | 2 +- test/built-ins/Atomics/notify/notify-all.js | 2 +- .../notify/notify-in-order-one-time.js | 2 +- .../Atomics/notify/notify-in-order.js | 2 +- test/built-ins/Atomics/notify/notify-nan.js | 2 +- test/built-ins/Atomics/notify/notify-one.js | 2 +- .../Atomics/notify/notify-renotify-noop.js | 2 +- test/built-ins/Atomics/notify/notify-two.js | 2 +- .../notify/notify-with-no-agents-waiting.js | 2 +- .../notify-with-no-matching-agents-waiting.js | 2 +- test/built-ins/Atomics/notify/notify-zero.js | 2 +- .../undefined-index-defaults-to-zero.js | 2 +- .../wait/bigint/false-for-timeout-agent.js | 10 ++-- .../Atomics/wait/bigint/nan-for-timeout.js | 2 +- .../wait/bigint/negative-timeout-agent.js | 2 +- .../bigint/no-spurious-wakeup-no-operation.js | 2 +- .../wait/bigint/no-spurious-wakeup-on-add.js | 2 +- .../wait/bigint/no-spurious-wakeup-on-and.js | 2 +- .../no-spurious-wakeup-on-compareExchange.js | 2 +- .../bigint/no-spurious-wakeup-on-exchange.js | 2 +- .../wait/bigint/no-spurious-wakeup-on-or.js | 2 +- .../bigint/no-spurious-wakeup-on-store.js | 2 +- .../wait/bigint/no-spurious-wakeup-on-sub.js | 2 +- .../wait/bigint/no-spurious-wakeup-on-xor.js | 2 +- .../Atomics/wait/bigint/value-not-equal.js | 2 +- .../waiterlist-block-indexedposition-wake.js | 2 +- .../waiterlist-order-of-operations-is-fifo.js | 2 +- .../wait/bigint/was-woken-before-timeout.js | 2 +- .../Atomics/wait/false-for-timeout-agent.js | 2 +- .../built-ins/Atomics/wait/nan-for-timeout.js | 2 +- .../Atomics/wait/negative-timeout-agent.js | 2 +- .../wait/no-spurious-wakeup-no-operation.js | 2 +- .../Atomics/wait/no-spurious-wakeup-on-add.js | 2 +- .../Atomics/wait/no-spurious-wakeup-on-and.js | 2 +- .../no-spurious-wakeup-on-compareExchange.js | 2 +- .../wait/no-spurious-wakeup-on-exchange.js | 2 +- .../Atomics/wait/no-spurious-wakeup-on-or.js | 2 +- .../wait/no-spurious-wakeup-on-store.js | 2 +- .../Atomics/wait/no-spurious-wakeup-on-sub.js | 2 +- .../Atomics/wait/no-spurious-wakeup-on-xor.js | 2 +- .../Atomics/wait/null-for-timeout-agent.js | 2 +- .../Atomics/wait/object-for-timeout-agent.js | 2 +- ...oisoned-object-for-timeout-throws-agent.js | 2 +- .../wait/symbol-for-index-throws-agent.js | 2 +- .../wait/symbol-for-timeout-throws-agent.js | 2 +- .../wait/symbol-for-value-throws-agent.js | 2 +- .../Atomics/wait/true-for-timeout-agent.js | 2 +- .../Atomics/wait/undefined-for-timeout.js | 2 +- .../wait/undefined-index-defaults-to-zero.js | 2 +- .../built-ins/Atomics/wait/value-not-equal.js | 2 +- .../wait/wait-index-value-not-equal.js | 2 +- .../waiterlist-block-indexedposition-wake.js | 2 +- .../waiterlist-order-of-operations-is-fifo.js | 2 +- .../Atomics/wait/was-woken-before-timeout.js | 2 +- 60 files changed, 119 insertions(+), 76 deletions(-) diff --git a/INTERPRETING.md b/INTERPRETING.md index f75b7ccf29..99bfcc1c47 100644 --- a/INTERPRETING.md +++ b/INTERPRETING.md @@ -66,24 +66,24 @@ properties of the global scope prior to test execution. - **`global`** - a reference to the global object on which `$262` was initially defined - **`IsHTMLDDA`** - (present only in implementations that can provide it) an object that 1) has an [[IsHTMLDDA]] internal slot, and 2) when called with - no arguments or with the single argument `""` returns `null`. Use this + no arguments or with the single argument `""` returns `null`. Use this property to test that ECMAScript algorithms aren't mis-implemented to treat `document.all` as being `undefined` or of type Undefined (instead of - Object). (The peculiar second requirement permits testing algorithms when + Object). (The peculiar second requirement permits testing algorithms when they also call `document.all` with such arguments, so that testing for - correct behavior requires knowing how the call behaves. This is rarely + correct behavior requires knowing how the call behaves. This is rarely necessary.) Tests using this function must be tagged with the `IsHTMLDDA` feature so that only hosts supporting this property will run them. - **`agent`** - an ordinary object with the following properties: - **`start`** - a function that takes a script source string and runs - the script in a concurrent agent. Will block until that agent is - running. The agent has no representation. The agent script will be + the script in a concurrent agent. Will block until that agent is + running. The agent has no representation. The agent script will be run in an environment that has an object `$262` with a property `agent` with the following properties: - **`receiveBroadcast`** - a function that takes a function and calls the function when it has received a broadcast from the parent, passing it the broadcast as two arguments, a SharedArrayBuffer and - an Int32. This function may return before a broadcast is received + an Int32 or BigInt. This function may return before a broadcast is received (eg to return to an event loop to await a message) and no code should follow the call to this function. - **`report`** - a function that accepts a single "message" argument, @@ -93,10 +93,11 @@ properties of the global scope prior to test execution. - **`leaving`** - a function that signals that the agent is done and may be terminated (if possible). - **`monotonicNow`** - a function that returns a value that conforms to [`DOMHighResTimeStamp`][] and is produced in such a way that its semantics conform to **[Monotonic Clock][]**. - - **`broadcast`** - a function that takes a SharedArrayBuffer and an Int32 - and broadcasts the two values to all concurrent agents. The function - blocks until all agents have retrieved the message. Note, this assumes - that all agents that were started are still running. + - **`broadcast`** - a function that takes a SharedArrayBuffer and an + Int32 or BigInt and broadcasts the two values to all concurrent + agents. The function blocks until all agents have retrieved the + message. Note, this assumes that all agents that were started are + still running. - **`getReport`** - a function that reads an incoming string from any agent, and returns it if it exists, or returns `null` otherwise. - **`sleep`** - a function that takes a millisecond argument and diff --git a/harness/atomicsHelper.js b/harness/atomicsHelper.js index aa308a3387..135c16eb67 100644 --- a/harness/atomicsHelper.js +++ b/harness/atomicsHelper.js @@ -28,6 +28,47 @@ description: > return r; }; } + +/** + * + * Share a given Int32Array or BigInt64Array to all running agents. Ensure that the + * provided TypedArray is a "shared typed array". + * + * NOTE: Migrating all tests to this API is necessary to prevent tests from hanging + * indefinitely when a SAB is sent to a worker but the code in the worker attempts to + * create a non-sharable TypedArray (something that is not Int32Array or BigInt64Array). + * When that scenario occurs, an exception is thrown and the agent worker can no + * longer communicate with any other threads that control the SAB. If the main + * thread happens to be spinning in the $262.agent.waitUntil() while loop, it will never + * meet its termination condition and the test will hang indefinitely. + * + * Because we've defined $262.agent.broadcast(SAB) in + * https://github.com/tc39/test262/blob/master/INTERPRETING.md, there are host implementations + * that assume compatibility, which must be maintained. + * + * + * $262.agent.safeBroadcast(TA) should not be included in + * https://github.com/tc39/test262/blob/master/INTERPRETING.md + * + * + * @param {(Int32Array|BigInt64Array)} typedArray An Int32Array or BigInt64Array with a SharedArrayBuffer + */ +$262.agent.safeBroadcast = function(typedArray) { + let Constructor = Object.getPrototypeOf(typedArray).constructor; + let temp = new Constructor( + new SharedArrayBuffer(Constructor.BYTES_PER_ELEMENT) + ); + try { + // This will never actually wait, but that's fine because we only + // want to ensure that this typedArray CAN be waited on and is shareable. + Atomics.wait(temp, 0, Constructor === Int32Array ? 1 : BigInt(1)); + } catch (error) { + $ERROR(`${Constructor.name} cannot be used as a shared typed array. (${error})`); + } + + $262.agent.broadcast(typedArray.buffer); +}; + /** * With a given Int32Array or BigInt64Array, wait until the expected number of agents have * reported themselves by calling: @@ -39,6 +80,7 @@ description: > * @param {number} expected The number of agents that are expected to report as active. */ $262.agent.waitUntil = function(typedArray, index, expected) { + var agents = 0; while ((agents = Atomics.load(typedArray, index)) !== expected) { /* nothing */ @@ -76,7 +118,7 @@ $262.agent.waitUntil = function(typedArray, index, expected) { * $262.agent.leaving(); * }); * `); - * $262.agent.broadcast(i32a.buffer); + * $262.agent.safeBroadcast(i32a.buffer); * * // Wait until the agent was started and then try to yield control to increase * // the likelihood the agent has called `Atomics.wait` and is now waiting. @@ -106,7 +148,7 @@ $262.agent.waitUntil = function(typedArray, index, expected) { * }); * `); * } - * $262.agent.broadcast(i32a.buffer); + * $262.agent.safeBroadcast(i32a.buffer); * * // Wait until the agents were started and then try to yield control to increase * // the likelihood the agents have called `Atomics.wait` and are now waiting. @@ -151,7 +193,7 @@ $262.agent.waitUntil = function(typedArray, index, expected) { * }); * `); * } - * $262.agent.broadcast(i32a.buffer); + * $262.agent.safeBroadcast(i32a.buffer); * * // Wait until the agents were started and then try to yield control to increase * // the likelihood the agents have called `Atomics.wait` and are now waiting. @@ -204,7 +246,7 @@ $262.agent.timeouts = { * $262.agent.leaving(); * }); * `); - * $262.agent.broadcast(i32a.buffer); + * $262.agent.safeBroadcast(i32a.buffer); * * // Wait until agent was started and then try to yield control. * $262.agent.waitUntil(i32a, RUNNING, 1); diff --git a/test/built-ins/Atomics/notify/bigint/notify-all-on-loc.js b/test/built-ins/Atomics/notify/bigint/notify-all-on-loc.js index 0675b6e188..9375849799 100644 --- a/test/built-ins/Atomics/notify/bigint/notify-all-on-loc.js +++ b/test/built-ins/Atomics/notify/bigint/notify-all-on-loc.js @@ -57,7 +57,7 @@ const i64a = new BigInt64Array( new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); // Wait for agents to be running. $262.agent.waitUntil(i64a, RUNNING, BigInt(NUMAGENT + 1)); diff --git a/test/built-ins/Atomics/notify/count-defaults-to-infinity-missing.js b/test/built-ins/Atomics/notify/count-defaults-to-infinity-missing.js index 3439eb2dc4..e1124943ea 100644 --- a/test/built-ins/Atomics/notify/count-defaults-to-infinity-missing.js +++ b/test/built-ins/Atomics/notify/count-defaults-to-infinity-missing.js @@ -43,7 +43,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); // An agent may have been interrupted between reporting its initial report diff --git a/test/built-ins/Atomics/notify/count-defaults-to-infinity-undefined.js b/test/built-ins/Atomics/notify/count-defaults-to-infinity-undefined.js index 71db309b73..ac4069dfec 100644 --- a/test/built-ins/Atomics/notify/count-defaults-to-infinity-undefined.js +++ b/test/built-ins/Atomics/notify/count-defaults-to-infinity-undefined.js @@ -41,7 +41,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); // An agent may have been interrupted between reporting its initial report diff --git a/test/built-ins/Atomics/notify/negative-count.js b/test/built-ins/Atomics/notify/negative-count.js index 8cc7f0b036..bba1edb962 100644 --- a/test/built-ins/Atomics/notify/negative-count.js +++ b/test/built-ins/Atomics/notify/negative-count.js @@ -26,7 +26,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/notify/notify-all-on-loc.js b/test/built-ins/Atomics/notify/notify-all-on-loc.js index c2cb5e5c66..0dee710d7f 100644 --- a/test/built-ins/Atomics/notify/notify-all-on-loc.js +++ b/test/built-ins/Atomics/notify/notify-all-on-loc.js @@ -57,7 +57,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait for agents to be running. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT + 1); diff --git a/test/built-ins/Atomics/notify/notify-all.js b/test/built-ins/Atomics/notify/notify-all.js index 02fa23edf2..cb7f13fa71 100644 --- a/test/built-ins/Atomics/notify/notify-all.js +++ b/test/built-ins/Atomics/notify/notify-all.js @@ -30,7 +30,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait for agents to be running. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); diff --git a/test/built-ins/Atomics/notify/notify-in-order-one-time.js b/test/built-ins/Atomics/notify/notify-in-order-one-time.js index ed968417ee..99b9330523 100644 --- a/test/built-ins/Atomics/notify/notify-in-order-one-time.js +++ b/test/built-ins/Atomics/notify/notify-in-order-one-time.js @@ -42,7 +42,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait for agents to be running. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); diff --git a/test/built-ins/Atomics/notify/notify-in-order.js b/test/built-ins/Atomics/notify/notify-in-order.js index ed968417ee..99b9330523 100644 --- a/test/built-ins/Atomics/notify/notify-in-order.js +++ b/test/built-ins/Atomics/notify/notify-in-order.js @@ -42,7 +42,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait for agents to be running. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); diff --git a/test/built-ins/Atomics/notify/notify-nan.js b/test/built-ins/Atomics/notify/notify-nan.js index 8f80445585..242c434e33 100644 --- a/test/built-ins/Atomics/notify/notify-nan.js +++ b/test/built-ins/Atomics/notify/notify-nan.js @@ -26,7 +26,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/notify/notify-one.js b/test/built-ins/Atomics/notify/notify-one.js index ffd29d0214..08fcda3bfc 100644 --- a/test/built-ins/Atomics/notify/notify-one.js +++ b/test/built-ins/Atomics/notify/notify-one.js @@ -34,7 +34,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait for agents to be running. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); diff --git a/test/built-ins/Atomics/notify/notify-renotify-noop.js b/test/built-ins/Atomics/notify/notify-renotify-noop.js index 3812556880..c47ff8fca5 100644 --- a/test/built-ins/Atomics/notify/notify-renotify-noop.js +++ b/test/built-ins/Atomics/notify/notify-renotify-noop.js @@ -26,7 +26,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); diff --git a/test/built-ins/Atomics/notify/notify-two.js b/test/built-ins/Atomics/notify/notify-two.js index 2a8d6fb8d1..c678bc6bdc 100644 --- a/test/built-ins/Atomics/notify/notify-two.js +++ b/test/built-ins/Atomics/notify/notify-two.js @@ -34,7 +34,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait for agents to be running. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); diff --git a/test/built-ins/Atomics/notify/notify-with-no-agents-waiting.js b/test/built-ins/Atomics/notify/notify-with-no-agents-waiting.js index 747e01766b..27a9ee1e32 100644 --- a/test/built-ins/Atomics/notify/notify-with-no-agents-waiting.js +++ b/test/built-ins/Atomics/notify/notify-with-no-agents-waiting.js @@ -24,7 +24,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // There are ZERO agents waiting to notify... diff --git a/test/built-ins/Atomics/notify/notify-with-no-matching-agents-waiting.js b/test/built-ins/Atomics/notify/notify-with-no-matching-agents-waiting.js index b4a247e493..3eade75b90 100644 --- a/test/built-ins/Atomics/notify/notify-with-no-matching-agents-waiting.js +++ b/test/built-ins/Atomics/notify/notify-with-no-matching-agents-waiting.js @@ -24,7 +24,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // There are ZERO matching agents waiting on index 1 diff --git a/test/built-ins/Atomics/notify/notify-zero.js b/test/built-ins/Atomics/notify/notify-zero.js index 615cb6b91c..9a7688b551 100644 --- a/test/built-ins/Atomics/notify/notify-zero.js +++ b/test/built-ins/Atomics/notify/notify-zero.js @@ -34,7 +34,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * BUFFER_SIZE) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait for agents to be running. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); diff --git a/test/built-ins/Atomics/notify/undefined-index-defaults-to-zero.js b/test/built-ins/Atomics/notify/undefined-index-defaults-to-zero.js index 59119a50df..b59844e22e 100644 --- a/test/built-ins/Atomics/notify/undefined-index-defaults-to-zero.js +++ b/test/built-ins/Atomics/notify/undefined-index-defaults-to-zero.js @@ -50,7 +50,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait until both agents started. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); diff --git a/test/built-ins/Atomics/wait/bigint/false-for-timeout-agent.js b/test/built-ins/Atomics/wait/bigint/false-for-timeout-agent.js index e7987f30b9..ca525a3f16 100644 --- a/test/built-ins/Atomics/wait/bigint/false-for-timeout-agent.js +++ b/test/built-ins/Atomics/wait/bigint/false-for-timeout-agent.js @@ -16,6 +16,10 @@ includes: [atomicsHelper.js] features: [Atomics, BigInt, SharedArrayBuffer, TypedArray] ---*/ +const i64a = new BigInt64Array( + new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) +); + const RUNNING = 1; $262.agent.start(` @@ -46,11 +50,7 @@ $262.agent.start(` }); `); -const i64a = new BigInt64Array( - new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) -); - -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/nan-for-timeout.js b/test/built-ins/Atomics/wait/bigint/nan-for-timeout.js index 87ac7a679f..bc128b612f 100644 --- a/test/built-ins/Atomics/wait/bigint/nan-for-timeout.js +++ b/test/built-ins/Atomics/wait/bigint/nan-for-timeout.js @@ -33,7 +33,7 @@ const i64a = new BigInt64Array( new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/negative-timeout-agent.js b/test/built-ins/Atomics/wait/bigint/negative-timeout-agent.js index 15085d371b..a0799b2120 100644 --- a/test/built-ins/Atomics/wait/bigint/negative-timeout-agent.js +++ b/test/built-ins/Atomics/wait/bigint/negative-timeout-agent.js @@ -25,7 +25,7 @@ const i64a = new BigInt64Array( new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-no-operation.js b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-no-operation.js index df6942dc6e..04491cf8fb 100644 --- a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-no-operation.js +++ b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-no-operation.js @@ -38,7 +38,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-add.js b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-add.js index a8e16f1a01..2128ae5372 100644 --- a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-add.js +++ b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-add.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-and.js b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-and.js index 80358b7bbe..3e25e5db56 100644 --- a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-and.js +++ b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-and.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-compareExchange.js b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-compareExchange.js index 91b69dc05a..f44a14969f 100644 --- a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-compareExchange.js +++ b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-compareExchange.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-exchange.js b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-exchange.js index fc1404cde0..b359f25f51 100644 --- a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-exchange.js +++ b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-exchange.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-or.js b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-or.js index 3c705fbce1..f0c384b518 100644 --- a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-or.js +++ b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-or.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-store.js b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-store.js index 5d0b8a7d4d..521e5e8166 100644 --- a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-store.js +++ b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-store.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-sub.js b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-sub.js index b066d03bad..11e097f22a 100644 --- a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-sub.js +++ b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-sub.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-xor.js b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-xor.js index 9cc06769a6..a336047bb0 100644 --- a/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-xor.js +++ b/test/built-ins/Atomics/wait/bigint/no-spurious-wakeup-on-xor.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/value-not-equal.js b/test/built-ins/Atomics/wait/bigint/value-not-equal.js index 9033f1d723..1c48790c7f 100644 --- a/test/built-ins/Atomics/wait/bigint/value-not-equal.js +++ b/test/built-ins/Atomics/wait/bigint/value-not-equal.js @@ -41,7 +41,7 @@ const i64a = new BigInt64Array( // test case, we only do it for consistency with other test cases which do // require the main agent to wait and yield control. -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/bigint/waiterlist-block-indexedposition-wake.js b/test/built-ins/Atomics/wait/bigint/waiterlist-block-indexedposition-wake.js index 3f0e138663..5b700cb57f 100644 --- a/test/built-ins/Atomics/wait/bigint/waiterlist-block-indexedposition-wake.js +++ b/test/built-ins/Atomics/wait/bigint/waiterlist-block-indexedposition-wake.js @@ -51,7 +51,7 @@ const i64a = new BigInt64Array( new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 5) ); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); // Wait until all agents started. $262.agent.waitUntil(i64a, RUNNING, BigInt(NUMAGENT)); diff --git a/test/built-ins/Atomics/wait/bigint/waiterlist-order-of-operations-is-fifo.js b/test/built-ins/Atomics/wait/bigint/waiterlist-order-of-operations-is-fifo.js index 769dac832a..5eb18a5b56 100644 --- a/test/built-ins/Atomics/wait/bigint/waiterlist-order-of-operations-is-fifo.js +++ b/test/built-ins/Atomics/wait/bigint/waiterlist-order-of-operations-is-fifo.js @@ -54,7 +54,7 @@ const i64a = new BigInt64Array( new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); // Wait until all agents started. $262.agent.waitUntil(i64a, RUNNING, BigInt(NUMAGENT)); diff --git a/test/built-ins/Atomics/wait/bigint/was-woken-before-timeout.js b/test/built-ins/Atomics/wait/bigint/was-woken-before-timeout.js index 2ae8b384e2..98a3e2319a 100644 --- a/test/built-ins/Atomics/wait/bigint/was-woken-before-timeout.js +++ b/test/built-ins/Atomics/wait/bigint/was-woken-before-timeout.js @@ -44,7 +44,7 @@ const i64a = new BigInt64Array( new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i64a.buffer); +$262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/false-for-timeout-agent.js b/test/built-ins/Atomics/wait/false-for-timeout-agent.js index 737963f321..33081f485f 100644 --- a/test/built-ins/Atomics/wait/false-for-timeout-agent.js +++ b/test/built-ins/Atomics/wait/false-for-timeout-agent.js @@ -50,7 +50,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/nan-for-timeout.js b/test/built-ins/Atomics/wait/nan-for-timeout.js index 08dea96c3c..fc99bb6513 100644 --- a/test/built-ins/Atomics/wait/nan-for-timeout.js +++ b/test/built-ins/Atomics/wait/nan-for-timeout.js @@ -33,7 +33,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/negative-timeout-agent.js b/test/built-ins/Atomics/wait/negative-timeout-agent.js index 4b505cf5b0..08c5114473 100644 --- a/test/built-ins/Atomics/wait/negative-timeout-agent.js +++ b/test/built-ins/Atomics/wait/negative-timeout-agent.js @@ -25,7 +25,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup-no-operation.js b/test/built-ins/Atomics/wait/no-spurious-wakeup-no-operation.js index 2bd298c2c8..963ee034c6 100644 --- a/test/built-ins/Atomics/wait/no-spurious-wakeup-no-operation.js +++ b/test/built-ins/Atomics/wait/no-spurious-wakeup-no-operation.js @@ -38,7 +38,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-add.js b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-add.js index 6757300aad..dcbcecac1f 100644 --- a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-add.js +++ b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-add.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-and.js b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-and.js index 64efe55af8..6fcdb11148 100644 --- a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-and.js +++ b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-and.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-compareExchange.js b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-compareExchange.js index adc190c001..2b1c1a22d2 100644 --- a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-compareExchange.js +++ b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-compareExchange.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-exchange.js b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-exchange.js index 93b880b61e..d46aeb715f 100644 --- a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-exchange.js +++ b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-exchange.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-or.js b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-or.js index 0f73bafacd..fea55f6172 100644 --- a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-or.js +++ b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-or.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-store.js b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-store.js index 95a8d8a8a7..2098e391f9 100644 --- a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-store.js +++ b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-store.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-sub.js b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-sub.js index bf260d7a02..9e85f7ca57 100644 --- a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-sub.js +++ b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-sub.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-xor.js b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-xor.js index dbb38f8e74..2d372cd1d7 100644 --- a/test/built-ins/Atomics/wait/no-spurious-wakeup-on-xor.js +++ b/test/built-ins/Atomics/wait/no-spurious-wakeup-on-xor.js @@ -31,7 +31,7 @@ $262.agent.start(` }); `); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/null-for-timeout-agent.js b/test/built-ins/Atomics/wait/null-for-timeout-agent.js index 3e0818bd4d..c44ef2f625 100644 --- a/test/built-ins/Atomics/wait/null-for-timeout-agent.js +++ b/test/built-ins/Atomics/wait/null-for-timeout-agent.js @@ -50,7 +50,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/object-for-timeout-agent.js b/test/built-ins/Atomics/wait/object-for-timeout-agent.js index 3217e42261..8844598504 100644 --- a/test/built-ins/Atomics/wait/object-for-timeout-agent.js +++ b/test/built-ins/Atomics/wait/object-for-timeout-agent.js @@ -56,7 +56,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws-agent.js b/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws-agent.js index 156f04176c..96411d3a08 100644 --- a/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws-agent.js +++ b/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws-agent.js @@ -59,7 +59,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js b/test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js index 21902487ca..d1c98fddd9 100644 --- a/test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js +++ b/test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js @@ -72,7 +72,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/symbol-for-timeout-throws-agent.js b/test/built-ins/Atomics/wait/symbol-for-timeout-throws-agent.js index efba942cd6..9a0710ba17 100644 --- a/test/built-ins/Atomics/wait/symbol-for-timeout-throws-agent.js +++ b/test/built-ins/Atomics/wait/symbol-for-timeout-throws-agent.js @@ -47,7 +47,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js b/test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js index d4de5f952b..dacb229fa7 100644 --- a/test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js +++ b/test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js @@ -63,7 +63,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/true-for-timeout-agent.js b/test/built-ins/Atomics/wait/true-for-timeout-agent.js index b6bec0f039..08050925d4 100644 --- a/test/built-ins/Atomics/wait/true-for-timeout-agent.js +++ b/test/built-ins/Atomics/wait/true-for-timeout-agent.js @@ -50,7 +50,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/undefined-for-timeout.js b/test/built-ins/Atomics/wait/undefined-for-timeout.js index 7c774fba22..b923a12b77 100644 --- a/test/built-ins/Atomics/wait/undefined-for-timeout.js +++ b/test/built-ins/Atomics/wait/undefined-for-timeout.js @@ -48,7 +48,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/undefined-index-defaults-to-zero.js b/test/built-ins/Atomics/wait/undefined-index-defaults-to-zero.js index 3d207c1a11..0f605da69e 100644 --- a/test/built-ins/Atomics/wait/undefined-index-defaults-to-zero.js +++ b/test/built-ins/Atomics/wait/undefined-index-defaults-to-zero.js @@ -39,7 +39,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/value-not-equal.js b/test/built-ins/Atomics/wait/value-not-equal.js index 4c2ca25129..b56157033e 100644 --- a/test/built-ins/Atomics/wait/value-not-equal.js +++ b/test/built-ins/Atomics/wait/value-not-equal.js @@ -41,7 +41,7 @@ const i32a = new Int32Array( // test case, we only do it for consistency with other test cases which do // require the main agent to wait and yield control. -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/wait-index-value-not-equal.js b/test/built-ins/Atomics/wait/wait-index-value-not-equal.js index 5d9babd78e..f267b582b4 100644 --- a/test/built-ins/Atomics/wait/wait-index-value-not-equal.js +++ b/test/built-ins/Atomics/wait/wait-index-value-not-equal.js @@ -38,7 +38,7 @@ const i32a = new Int32Array( // test case, we only do it for consistency with other test cases which do // require the main agent to wait and yield control. -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. diff --git a/test/built-ins/Atomics/wait/waiterlist-block-indexedposition-wake.js b/test/built-ins/Atomics/wait/waiterlist-block-indexedposition-wake.js index 32290826be..01732beb8f 100644 --- a/test/built-ins/Atomics/wait/waiterlist-block-indexedposition-wake.js +++ b/test/built-ins/Atomics/wait/waiterlist-block-indexedposition-wake.js @@ -51,7 +51,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 5) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait until all agents started. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); diff --git a/test/built-ins/Atomics/wait/waiterlist-order-of-operations-is-fifo.js b/test/built-ins/Atomics/wait/waiterlist-order-of-operations-is-fifo.js index c5a731f334..2a2a80b0fd 100644 --- a/test/built-ins/Atomics/wait/waiterlist-order-of-operations-is-fifo.js +++ b/test/built-ins/Atomics/wait/waiterlist-order-of-operations-is-fifo.js @@ -54,7 +54,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); // Wait until all agents started. $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); diff --git a/test/built-ins/Atomics/wait/was-woken-before-timeout.js b/test/built-ins/Atomics/wait/was-woken-before-timeout.js index 135dd23d1a..7b524babe8 100644 --- a/test/built-ins/Atomics/wait/was-woken-before-timeout.js +++ b/test/built-ins/Atomics/wait/was-woken-before-timeout.js @@ -44,7 +44,7 @@ const i32a = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); -$262.agent.broadcast(i32a.buffer); +$262.agent.safeBroadcast(i32a); $262.agent.waitUntil(i32a, RUNNING, 1); // Try to yield control to ensure the agent actually started to wait. From 8793bf5d57ab1c75211d11ad3469300d48205301 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Tue, 20 Nov 2018 15:18:14 -0500 Subject: [PATCH 2/3] Atomics: fix running index in notify-with-no-matching-agents-waiting.js Migrating all tests to this API is necessary to prevent tests from hanging indefinitely when a SAB is sent to a worker but the code in the worker attempts to create a non-sharable TypedArray (something that is not Int32Array or BigInt64Array). When that scenario occurs, an exception is thrown and the agent worker can no longer communicate with any other threads that control the SAB. If the main thread happens to be spinning in the $262.agent.waitUntil() while loop, it will never meet its termination condition and the test will hang indefinitely. Because we've defined $262.agent.broadcast(SAB) in https://github.com/tc39/test262/blob/master/INTERPRETING.md, there are host implementations that assume compatibility, which must be maintained. --- .../Atomics/notify/notify-with-no-matching-agents-waiting.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Atomics/notify/notify-with-no-matching-agents-waiting.js b/test/built-ins/Atomics/notify/notify-with-no-matching-agents-waiting.js index 3eade75b90..5fc8267c42 100644 --- a/test/built-ins/Atomics/notify/notify-with-no-matching-agents-waiting.js +++ b/test/built-ins/Atomics/notify/notify-with-no-matching-agents-waiting.js @@ -10,7 +10,7 @@ includes: [atomicsHelper.js] features: [Atomics, SharedArrayBuffer, TypedArray] ---*/ -const RUNNING = 1; +const RUNNING = 0; $262.agent.start(` $262.agent.receiveBroadcast(function(sab) { From e91645c812720abdc5432c5cba6d85510f4fba19 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Tue, 20 Nov 2018 15:57:39 -0500 Subject: [PATCH 3/3] Atomics: (bigint) initialize BigInt64Array before calling $262.agent.start(string-of-program-code) --- .../Atomics/notify/bigint/notify-all-on-loc.js | 8 ++++---- test/built-ins/Atomics/wait/bigint/nan-for-timeout.js | 8 ++++---- .../Atomics/wait/bigint/negative-timeout-agent.js | 8 ++++---- test/built-ins/Atomics/wait/bigint/value-not-equal.js | 9 ++++----- .../bigint/waiterlist-block-indexedposition-wake.js | 8 ++++---- .../bigint/waiterlist-order-of-operations-is-fifo.js | 11 +++++------ .../Atomics/wait/bigint/was-woken-before-timeout.js | 8 ++++---- 7 files changed, 29 insertions(+), 31 deletions(-) diff --git a/test/built-ins/Atomics/notify/bigint/notify-all-on-loc.js b/test/built-ins/Atomics/notify/bigint/notify-all-on-loc.js index 9375849799..790d099c5f 100644 --- a/test/built-ins/Atomics/notify/bigint/notify-all-on-loc.js +++ b/test/built-ins/Atomics/notify/bigint/notify-all-on-loc.js @@ -22,6 +22,10 @@ const BUFFER_SIZE = 4; // `Atomics.notify`. const TIMEOUT = $262.agent.timeouts.long; +const i64a = new BigInt64Array( + new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * BUFFER_SIZE) +); + for (var i = 0; i < NUMAGENT; i++) { $262.agent.start(` $262.agent.receiveBroadcast(function(sab) { @@ -53,10 +57,6 @@ $262.agent.start(` }); `); -const i64a = new BigInt64Array( - new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * BUFFER_SIZE) -); - $262.agent.safeBroadcast(i64a); // Wait for agents to be running. diff --git a/test/built-ins/Atomics/wait/bigint/nan-for-timeout.js b/test/built-ins/Atomics/wait/bigint/nan-for-timeout.js index bc128b612f..f50a11ebf3 100644 --- a/test/built-ins/Atomics/wait/bigint/nan-for-timeout.js +++ b/test/built-ins/Atomics/wait/bigint/nan-for-timeout.js @@ -17,6 +17,10 @@ includes: [atomicsHelper.js] features: [Atomics, BigInt, SharedArrayBuffer, TypedArray] ---*/ +const i64a = new BigInt64Array( + new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) +); + const RUNNING = 1; $262.agent.start(` @@ -29,10 +33,6 @@ $262.agent.start(` }); `); -const i64a = new BigInt64Array( - new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) -); - $262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); diff --git a/test/built-ins/Atomics/wait/bigint/negative-timeout-agent.js b/test/built-ins/Atomics/wait/bigint/negative-timeout-agent.js index a0799b2120..8c9346bd9c 100644 --- a/test/built-ins/Atomics/wait/bigint/negative-timeout-agent.js +++ b/test/built-ins/Atomics/wait/bigint/negative-timeout-agent.js @@ -9,6 +9,10 @@ includes: [atomicsHelper.js] features: [Atomics, BigInt, SharedArrayBuffer, TypedArray] ---*/ +const i64a = new BigInt64Array( + new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) +); + const RUNNING = 1; $262.agent.start(` @@ -21,10 +25,6 @@ $262.agent.start(` }); `); -const i64a = new BigInt64Array( - new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) -); - $262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n); diff --git a/test/built-ins/Atomics/wait/bigint/value-not-equal.js b/test/built-ins/Atomics/wait/bigint/value-not-equal.js index 1c48790c7f..d23f3bead5 100644 --- a/test/built-ins/Atomics/wait/bigint/value-not-equal.js +++ b/test/built-ins/Atomics/wait/bigint/value-not-equal.js @@ -19,9 +19,12 @@ features: [Atomics, BigInt, SharedArrayBuffer, TypedArray] ---*/ const RUNNING = 1; - const value = "42n"; +const i64a = new BigInt64Array( + new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) +); + $262.agent.start(` $262.agent.receiveBroadcast(function(sab) { const i64a = new BigInt64Array(sab); @@ -33,10 +36,6 @@ $262.agent.start(` }); `); -const i64a = new BigInt64Array( - new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) -); - // NB: We don't actually explicitly need to wait for the agent to start in this // test case, we only do it for consistency with other test cases which do // require the main agent to wait and yield control. diff --git a/test/built-ins/Atomics/wait/bigint/waiterlist-block-indexedposition-wake.js b/test/built-ins/Atomics/wait/bigint/waiterlist-block-indexedposition-wake.js index 5b700cb57f..6f9c7c678c 100644 --- a/test/built-ins/Atomics/wait/bigint/waiterlist-block-indexedposition-wake.js +++ b/test/built-ins/Atomics/wait/bigint/waiterlist-block-indexedposition-wake.js @@ -25,6 +25,10 @@ features: [Atomics, BigInt, SharedArrayBuffer, TypedArray] var NUMAGENT = 2; var RUNNING = 4; +const i64a = new BigInt64Array( + new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 5) +); + $262.agent.start(` $262.agent.receiveBroadcast(function(sab) { const i64a = new BigInt64Array(sab); @@ -47,10 +51,6 @@ $262.agent.start(` }); `); -const i64a = new BigInt64Array( - new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 5) -); - $262.agent.safeBroadcast(i64a); // Wait until all agents started. diff --git a/test/built-ins/Atomics/wait/bigint/waiterlist-order-of-operations-is-fifo.js b/test/built-ins/Atomics/wait/bigint/waiterlist-order-of-operations-is-fifo.js index 5eb18a5b56..bebe05a0b9 100644 --- a/test/built-ins/Atomics/wait/bigint/waiterlist-order-of-operations-is-fifo.js +++ b/test/built-ins/Atomics/wait/bigint/waiterlist-order-of-operations-is-fifo.js @@ -16,11 +16,14 @@ includes: [atomicsHelper.js] features: [Atomics, BigInt, SharedArrayBuffer, TypedArray] ---*/ -var NUMAGENT = 3; - var WAIT_INDEX = 0; var RUNNING = 1; var LOCK_INDEX = 2; +var NUMAGENT = 3; + +const i64a = new BigInt64Array( + new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) +); for (var i = 0; i < NUMAGENT; i++) { var agentNum = i; @@ -50,10 +53,6 @@ for (var i = 0; i < NUMAGENT; i++) { `); } -const i64a = new BigInt64Array( - new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) -); - $262.agent.safeBroadcast(i64a); // Wait until all agents started. diff --git a/test/built-ins/Atomics/wait/bigint/was-woken-before-timeout.js b/test/built-ins/Atomics/wait/bigint/was-woken-before-timeout.js index 98a3e2319a..9359ebe34d 100644 --- a/test/built-ins/Atomics/wait/bigint/was-woken-before-timeout.js +++ b/test/built-ins/Atomics/wait/bigint/was-woken-before-timeout.js @@ -25,6 +25,10 @@ features: [Atomics, BigInt, SharedArrayBuffer, TypedArray] const RUNNING = 1; const TIMEOUT = $262.agent.timeouts.huge; +const i64a = new BigInt64Array( + new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) +); + $262.agent.start(` $262.agent.receiveBroadcast(function(sab) { const i64a = new BigInt64Array(sab); @@ -40,10 +44,6 @@ $262.agent.start(` }); `); -const i64a = new BigInt64Array( - new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) -); - $262.agent.safeBroadcast(i64a); $262.agent.waitUntil(i64a, RUNNING, 1n);