From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- js/src/jit-test/tests/gc/bug-1505622.js | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 js/src/jit-test/tests/gc/bug-1505622.js (limited to 'js/src/jit-test/tests/gc/bug-1505622.js') diff --git a/js/src/jit-test/tests/gc/bug-1505622.js b/js/src/jit-test/tests/gc/bug-1505622.js new file mode 100644 index 0000000000..3f6f83c076 --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1505622.js @@ -0,0 +1,54 @@ +// Test that we don't repeatedly trigger last-ditch GCs. + +// Turn of any zeal which will disrupt GC number checks. +gczeal(0); + +function allocUntilFail() { + gc(null, 'shrinking'); + + const initialSize = gcparam("gcBytes"); + const initialMaxSize = gcparam("maxBytes"); + const initGCNumber = gcparam("majorGCNumber"); + + // Set a small heap limit. + gcparam("maxBytes", initialSize + 16 * 1024); + + let error; + try { + let a = []; + while (true) { + a.push(Symbol()); // Symbols are tenured. + } + } catch(err) { + error = err; + } + + const finalGCNumber = gcparam("majorGCNumber"); + + // Resetore heap limit. + gcparam("maxBytes", initialMaxSize); + + gc(); + assertEq(error, "out of memory"); + return finalGCNumber - initGCNumber; +} + +// Set the time limit for skipping last ditch GCs to 5 seconds. +gcparam("minLastDitchGCPeriod", 5); +assertEq(gcparam("minLastDitchGCPeriod"), 5); + +// Allocate up to the heap limit. This triggers a last ditch GC. +let gcCount = allocUntilFail(); +assertEq(gcCount, 1) + +// Allocate up to the limit again. The second time we fail without +// triggering a GC. +gcCount = allocUntilFail(); +assertEq(gcCount, 0) + +// Wait for time limit to expire. +sleep(6); + +// Check we trigger a GC again. +gcCount = allocUntilFail(); +assertEq(gcCount, 1) -- cgit v1.2.3