summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Atomics/notify/bigint
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Atomics/notify/bigint
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Atomics/notify/bigint')
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/bad-range.js29
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/non-bigint64-typedarray-throws.js37
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js36
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-index-evaluation-throws.js35
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js24
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-returns-0.js24
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/notify-all-on-loc.js92
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/null-bufferdata-throws.js39
-rw-r--r--js/src/tests/test262/built-ins/Atomics/notify/bigint/shell.js0
10 files changed, 316 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/bad-range.js
new file mode 100644
index 0000000000..7479c2fb00
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/bad-range.js
@@ -0,0 +1,29 @@
+// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration()['arm64-simulator'])) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics
+// Copyright (C) 2018 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-atomics.notify
+description: >
+ Test range checking of Atomics.notify on arrays that allow atomic operations
+info: |
+ Atomics.notify( typedArray, index, count )
+
+ 1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
+ ..
+
+includes: [testAtomics.js]
+features: [ArrayBuffer, Atomics, BigInt, DataView, SharedArrayBuffer, Symbol, TypedArray]
+---*/
+
+const i64a = new BigInt64Array(
+ new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
+);
+
+testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ assert.throws(RangeError, function() {
+ Atomics.notify(i64a, IdxGen(i64a), 0);
+ }, '`Atomics.notify(i64a, IdxGen(i64a), 0)` throws RangeError');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/browser.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/browser.js
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-bigint64-typedarray-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-bigint64-typedarray-throws.js
new file mode 100644
index 0000000000..94fc29e40d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-bigint64-typedarray-throws.js
@@ -0,0 +1,37 @@
+// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
+// Copyright (C) 2018 Amal Hussein. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-atomics.notify
+description: >
+ Throws a TypeError if typedArray arg is not an BigInt64Array
+info: |
+ Atomics.notify( 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, TypedArray]
+---*/
+
+const i64a = new BigUint64Array(
+ new SharedArrayBuffer(BigUint64Array.BYTES_PER_ELEMENT * 8)
+);
+
+const poisoned = {
+ valueOf: function() {
+ throw new Test262Error('should not evaluate this code');
+ }
+};
+
+assert.throws(TypeError, function() {
+ Atomics.wait(i64a, 0, 0);
+}, '`Atomics.wait(i64a, 0, 0)` throws TypeError');
+
+assert.throws(TypeError, function() {
+ Atomics.wait(i64a, poisoned, poisoned);
+}, '`Atomics.wait(i64a, poisoned, poisoned)` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js
new file mode 100644
index 0000000000..5c5781f429
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js
@@ -0,0 +1,36 @@
+// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-atomics.notify
+description: >
+ Evaluates index before returning 0, when TA.buffer is not a SharedArrayBuffer
+info: |
+ Atomics.notify( typedArray, index, count )
+
+ Let buffer be ? ValidateIntegerTypedArray(typedArray, true).
+ ...
+ Else,
+ Let intCount be ? ToInteger(count).
+ Let c be max(intCount, 0).
+ ...
+ If IsSharedArrayBuffer(buffer) is false, return 0.
+
+features: [ArrayBuffer, Atomics, BigInt, TypedArray]
+---*/
+
+const i64a = new BigInt64Array(
+ new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
+);
+
+const poisoned = {
+ valueOf() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ Atomics.notify(i64a, poisoned, 0);
+}, '`Atomics.notify(i64a, poisoned, 0)` throws Test262Error');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-index-evaluation-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-index-evaluation-throws.js
new file mode 100644
index 0000000000..c345fa7265
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-index-evaluation-throws.js
@@ -0,0 +1,35 @@
+// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-atomics.notify
+description: >
+ Evaluates index before returning 0, when TA.buffer is not a SharedArrayBuffer
+info: |
+ Atomics.notify( typedArray, index, count )
+
+ Let buffer be ? ValidateIntegerTypedArray(typedArray, true).
+ Let i be ? ValidateAtomicAccess(typedArray, index).
+ ...
+ If IsSharedArrayBuffer(buffer) is false, return 0.
+
+features: [ArrayBuffer, Atomics, BigInt, TypedArray]
+---*/
+
+const i64a = new BigInt64Array(
+ new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
+);
+
+const poisoned = {
+ valueOf() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ Atomics.notify(i64a, 0, poisoned);
+}, '`Atomics.notify(i64a, 0, poisoned)` throws Test262Error');
+
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js
new file mode 100644
index 0000000000..274bb87374
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js
@@ -0,0 +1,24 @@
+// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-atomics.notify
+description: >
+ Atomics.notify throws on non-shared integer TypedArrays
+features: [ArrayBuffer, Atomics, BigInt, TypedArray]
+---*/
+
+const nonsab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8);
+
+const poisoned = {
+ valueOf() {
+ throw new Test262Error('should not evaluate this code');
+ }
+};
+
+assert.throws(TypeError, function() {
+ Atomics.notify(new BigUint64Array(nonsab), poisoned, poisoned);
+}, '`Atomics.notify(new BigUint64Array(nonsab), poisoned, poisoned)` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-returns-0.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-returns-0.js
new file mode 100644
index 0000000000..2662027e8b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-returns-0.js
@@ -0,0 +1,24 @@
+// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-atomics.notify
+description: >
+ Returns 0, when TA.buffer is not a SharedArrayBuffer
+info: |
+ Atomics.notify( typedArray, index, count )
+
+ Let buffer be ? ValidateIntegerTypedArray(typedArray, true).
+ ...
+ If IsSharedArrayBuffer(buffer) is false, return 0.
+
+features: [ArrayBuffer, Atomics, BigInt, TypedArray]
+---*/
+const i64a = new BigInt64Array(
+ new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
+);
+
+assert.sameValue(Atomics.notify(i64a, 0, 0), 0, 'Atomics.notify(i64a, 0, 0) returns 0');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/notify-all-on-loc.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/notify-all-on-loc.js
new file mode 100644
index 0000000000..18ea073bfc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/notify-all-on-loc.js
@@ -0,0 +1,92 @@
+// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration()['arm64-simulator'])) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-atomics.notify
+description: >
+ Test that Atomics.notify notifies all waiters on a location, but does not
+ notify waiters on other locations.
+includes: [atomicsHelper.js]
+features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+const WAIT_INDEX = 0; // Waiters on this will be woken
+const WAIT_FAKE = 1; // Waiters on this will not be woken
+const RUNNING = 2; // Accounting of live agents
+const NOTIFY_INDEX = 3; // Accounting for too early timeouts
+const NUMAGENT = 3;
+const TIMEOUT_AGENT_MESSAGES = 2; // Number of messages for the timeout agent
+const BUFFER_SIZE = 4;
+
+// Long timeout to ensure the agent doesn't timeout before the main agent calls
+// `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) {
+ const i64a = new BigInt64Array(sab);
+ Atomics.add(i64a, ${RUNNING}, 1n);
+
+ $262.agent.report("A " + Atomics.wait(i64a, ${WAIT_INDEX}, 0n));
+ $262.agent.leaving();
+ });
+ `);
+}
+
+$262.agent.start(`
+ $262.agent.receiveBroadcast(function(sab) {
+ const i64a = new BigInt64Array(sab);
+ Atomics.add(i64a, ${RUNNING}, 1n);
+
+ // This will always time out.
+ $262.agent.report("B " + Atomics.wait(i64a, ${WAIT_FAKE}, 0n, ${TIMEOUT}));
+
+ // If this value is not 1n, then the agent timeout before the main agent
+ // called Atomics.notify.
+ const result = Atomics.load(i64a, ${NOTIFY_INDEX}) === 1n
+ ? "timeout after Atomics.notify"
+ : "timeout before Atomics.notify";
+ $262.agent.report("W " + result);
+
+ $262.agent.leaving();
+ });
+`);
+
+$262.agent.safeBroadcast(i64a);
+
+// Wait for agents to be running.
+$262.agent.waitUntil(i64a, RUNNING, BigInt(NUMAGENT + 1));
+
+// Try to yield control to ensure the agent actually started to wait. If we
+// don't, we risk sending the notification before agents are sleeping, and we hang.
+$262.agent.tryYield();
+
+// Notify all waiting on WAIT_INDEX, should be 3 always, they won't time out.
+assert.sameValue(
+ Atomics.notify(i64a, WAIT_INDEX),
+ NUMAGENT,
+ 'Atomics.notify(i64a, WAIT_INDEX) returns the value of `NUMAGENT`'
+);
+
+Atomics.store(i64a, NOTIFY_INDEX, 1n);
+
+const reports = [];
+for (var i = 0; i < NUMAGENT + TIMEOUT_AGENT_MESSAGES; i++) {
+ reports.push($262.agent.getReport());
+}
+reports.sort();
+
+for (var i = 0; i < NUMAGENT; i++) {
+ assert.sameValue(reports[i], 'A ok', 'The value of reports[i] is "A ok"');
+}
+assert.sameValue(reports[NUMAGENT], 'B timed-out', 'The value of reports[NUMAGENT] is "B timed-out"');
+assert.sameValue(reports[NUMAGENT + 1], "W timeout after Atomics.notify",
+ 'The value of reports[NUMAGENT + 1] is "W timeout after Atomics.notify"');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/null-bufferdata-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/null-bufferdata-throws.js
new file mode 100644
index 0000000000..99bfc3cff9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/null-bufferdata-throws.js
@@ -0,0 +1,39 @@
+// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
+// Copyright (C) 2018 Amal Hussein. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-atomics.notify
+description: >
+ A null value for bufferData throws a TypeError
+info: |
+ Atomics.notify( 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, Atomics, BigInt, TypedArray]
+---*/
+
+const i64a = new BigInt64Array(
+ new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
+);
+const poisoned = {
+ valueOf: function() {
+ throw new Test262Error('should not evaluate this code');
+ }
+};
+
+try {
+ $DETACHBUFFER(i64a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
+} catch (error) {
+ throw new Test262Error(`An unexpected error occurred when detaching ArrayBuffer: ${error.message}`);
+}
+
+assert.throws(TypeError, function() {
+ Atomics.notify(i64a, poisoned, poisoned);
+}, '`Atomics.notify(i64a, poisoned, poisoned)` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/shell.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/shell.js