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/lib/pretenure.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/lib/pretenure.js')
-rw-r--r-- | js/src/jit-test/lib/pretenure.js | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/js/src/jit-test/lib/pretenure.js b/js/src/jit-test/lib/pretenure.js new file mode 100644 index 0000000000..85282680c0 --- /dev/null +++ b/js/src/jit-test/lib/pretenure.js @@ -0,0 +1,80 @@ +// Functions shared by gc/pretenure-*.js tests + +const is64bit = getBuildConfiguration()['pointer-byte-size'] === 8; + +// Count of objects that will exceed the size of the nursery. +const nurseryCount = is64bit ? 25000 : 50000; + +// Count of objects that will exceed the tenured heap collection threshold. +const tenuredCount = is64bit ? 300000 : 600000; + +function setupPretenureTest() { + // The test requires that baseline is enabled and is not bypassed with + // --ion-eager or similar. + let jitOptions = getJitCompilerOptions(); + if (!jitOptions['baseline.enable'] || + jitOptions['ion.warmup.trigger'] <= jitOptions['baseline.warmup.trigger']) { + print("Unsupported JIT options"); + quit(); + } + + // Disable zeal modes that will interfere with this test. + gczeal(0); + + // Restrict nursery size so we can fill it quicker, and ensure it is resized. + gcparam("minNurseryBytes", 1024 * 1024); + gcparam("maxNurseryBytes", 1024 * 1024); + + // Limit allocation threshold so we trigger major GCs sooner. + gcparam("allocationThreshold", 1 /* MB */); + + // Disable incremental GC so there's at most one minor GC per major GC. + gcparam("incrementalGCEnabled", false); + + // Disable balanced heap limits to make the number of GCs predictable. + gcparam("balancedHeapLimitsEnabled", false); + + // Force a nursery collection to apply size parameters. + let o = {}; + + gc(); +} + +function allocateObjects(count, longLived) { + let array = new Array(nurseryCount); + for (let i = 0; i < count; i++) { + let x = {x: i}; + if (longLived) { + array[i % nurseryCount] = x; + } else { + array[0] = x; + } + } + return array; +} + +function allocateArrays(count, longLived) { + let array = new Array(nurseryCount); + for (let i = 0; i < count; i++) { + let x = [i]; + if (longLived) { + array[i % nurseryCount] = x; + } else { + array[0] = x; + } + } + return array; +} + +function gcCounts() { + return { minor: gcparam("minorGCNumber"), + major: gcparam("majorGCNumber") }; +} + +function runTestAndCountCollections(thunk) { + let initialCounts = gcCounts(); + thunk(); + let finalCounts = gcCounts(); + return { minor: finalCounts.minor - initialCounts.minor, + major: finalCounts.major - initialCounts.major }; +} |