diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/cacheir/store-typed-element-bigint.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.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/jit-test/tests/cacheir/store-typed-element-bigint.js')
-rw-r--r-- | js/src/jit-test/tests/cacheir/store-typed-element-bigint.js | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/cacheir/store-typed-element-bigint.js b/js/src/jit-test/tests/cacheir/store-typed-element-bigint.js new file mode 100644 index 0000000000..e46ca13f85 --- /dev/null +++ b/js/src/jit-test/tests/cacheir/store-typed-element-bigint.js @@ -0,0 +1,131 @@ +// Different typed array types to ensure we emit a SetProp IC. +var xs = [ + new BigInt64Array(10), + new BigUint64Array(10), +]; + +// Store with 0n as rhs. +function storeConstantZero() { + var value = 0n; + + for (var i = 0; i < 100; ++i) { + var ta = xs[i & 1]; + ta[0] = value; + } + + assertEq(xs[0][0], BigInt.asIntN(64, value)); + assertEq(xs[1][0], BigInt.asUintN(64, value)); +} +storeConstantZero(); + +// Store non-negative BigInt using inline digits. +function storeInlineDigits() { + var value = 1n; + + for (var i = 0; i < 100; ++i) { + var ta = xs[i & 1]; + ta[0] = value; + } + + assertEq(xs[0][0], BigInt.asIntN(64, value)); + assertEq(xs[1][0], BigInt.asUintN(64, value)); +} +storeInlineDigits(); + +// Store negative BigInt using inline digits. +function storeInlineDigitsNegative() { + var value = -1n; + + for (var i = 0; i < 100; ++i) { + var ta = xs[i & 1]; + ta[0] = value; + } + + assertEq(xs[0][0], BigInt.asIntN(64, value)); + assertEq(xs[1][0], BigInt.asUintN(64, value)); +} +storeInlineDigitsNegative(); + +// Still inline digits, but now two digits on 32-bit platforms +function storeInlineDigitsTwoDigits() { + var value = 4294967296n; + + for (var i = 0; i < 100; ++i) { + var ta = xs[i & 1]; + ta[0] = value; + } + + assertEq(xs[0][0], BigInt.asIntN(64, value)); + assertEq(xs[1][0], BigInt.asUintN(64, value)); +} +storeInlineDigitsTwoDigits(); + +// Negative case of |storeInlineDigitsTwoDigits|. +function storeInlineDigitsTwoDigitsNegative() { + var value = -4294967296n; + + for (var i = 0; i < 100; ++i) { + var ta = xs[i & 1]; + ta[0] = value; + } + + assertEq(xs[0][0], BigInt.asIntN(64, value)); + assertEq(xs[1][0], BigInt.asUintN(64, value)); +} +storeInlineDigitsTwoDigitsNegative(); + +// Store BigInt using heap digits. +function storeHeapDigits() { + var value = 2n ** 1000n; + + for (var i = 0; i < 100; ++i) { + var ta = xs[i & 1]; + ta[0] = value; + } + + assertEq(xs[0][0], BigInt.asIntN(64, value)); + assertEq(xs[1][0], BigInt.asUintN(64, value)); +} +storeHeapDigits(); + +// Store negative BigInt using heap digits. +function storeHeapDigitsNegative() { + var value = -(2n ** 1000n); + + for (var i = 0; i < 100; ++i) { + var ta = xs[i & 1]; + ta[0] = value; + } + + assertEq(xs[0][0], BigInt.asIntN(64, value)); + assertEq(xs[1][0], BigInt.asUintN(64, value)); +} +storeHeapDigitsNegative(); + +// Store BigInt with first number requiring heap digits. +function storeFirstHeapDigits() { + var value = 2n ** 64n; + + for (var i = 0; i < 100; ++i) { + var ta = xs[i & 1]; + ta[0] = value; + } + + assertEq(xs[0][0], BigInt.asIntN(64, value)); + assertEq(xs[1][0], BigInt.asUintN(64, value)); +} +storeFirstHeapDigits(); + +// Store negative BigInt with first number requiring heap digits. +function storeFirstHeapDigitsNegative() { + var value = -(2n ** 64n); + + for (var i = 0; i < 100; ++i) { + var ta = xs[i & 1]; + ta[0] = value; + } + + assertEq(xs[0][0], BigInt.asIntN(64, value)); + assertEq(xs[1][0], BigInt.asUintN(64, value)); +} +storeFirstHeapDigitsNegative(); |