summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/manual-tests
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/jit-test/manual-tests
parentInitial commit. (diff)
downloadfirefox-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/manual-tests')
-rw-r--r--js/src/jit-test/manual-tests/dense-to-sparse.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/jit-test/manual-tests/dense-to-sparse.js b/js/src/jit-test/manual-tests/dense-to-sparse.js
new file mode 100644
index 0000000000..efe56620da
--- /dev/null
+++ b/js/src/jit-test/manual-tests/dense-to-sparse.js
@@ -0,0 +1,40 @@
+// |jit-test| allow-oom
+// Appending elements to a dense array should make the array sparse when the
+// length exceeds the limit.
+
+function test() {
+ const MAX_DENSE_ELEMENTS_ALLOCATION = (1 << 28) - 1;
+ const VALUES_PER_HEADER = 2;
+ const MAX_DENSE_ELEMENTS_COUNT = MAX_DENSE_ELEMENTS_ALLOCATION - VALUES_PER_HEADER;
+ const SPARSE_DENSITY_RATIO = 8;
+ const MIN_DENSE = MAX_DENSE_ELEMENTS_COUNT / SPARSE_DENSITY_RATIO;
+ const MARGIN = 16;
+
+ let a = [];
+ // Fill the beginning of array to make it keep dense until length exceeds
+ // MAX_DENSE_ELEMENTS_COUNT.
+ for (let i = 0; i < MIN_DENSE; i++)
+ a[i] = i;
+
+ // Skip from MIN_DENSE to MAX_DENSE_ELEMENTS_COUNT - MARGIN, to reduce the
+ // time taken by test.
+
+ // Fill the ending of array to make it sparse at MAX_DENSE_ELEMENTS_COUNT.
+ for (let i = MAX_DENSE_ELEMENTS_COUNT - MARGIN; i < MAX_DENSE_ELEMENTS_COUNT + MARGIN; i++)
+ a[i] = i;
+
+ // Make sure the last element is defined.
+ assertEq(a.length, MAX_DENSE_ELEMENTS_COUNT + MARGIN);
+ assertEq(a[a.length - 1], MAX_DENSE_ELEMENTS_COUNT + MARGIN - 1);
+
+ // Make sure elements around MAX_DENSE_ELEMENTS_COUNT are also defined.
+ assertEq(a[MAX_DENSE_ELEMENTS_COUNT - 1], MAX_DENSE_ELEMENTS_COUNT - 1);
+ assertEq(a[MAX_DENSE_ELEMENTS_COUNT], MAX_DENSE_ELEMENTS_COUNT);
+ assertEq(a[MAX_DENSE_ELEMENTS_COUNT + 1], MAX_DENSE_ELEMENTS_COUNT + 1);
+}
+
+var config = getBuildConfiguration();
+// Takes too long time on debug build.
+if (!config.debug) {
+ test();
+}