From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/jit-test/tests/debug/gc-04.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 js/src/jit-test/tests/debug/gc-04.js (limited to 'js/src/jit-test/tests/debug/gc-04.js') diff --git a/js/src/jit-test/tests/debug/gc-04.js b/js/src/jit-test/tests/debug/gc-04.js new file mode 100644 index 0000000000..206be25f47 --- /dev/null +++ b/js/src/jit-test/tests/debug/gc-04.js @@ -0,0 +1,25 @@ +// Storing a Debugger.Object as a key in a WeakMap protects it from GC as long as +// the referent is alive. + +var g = newGlobal({newCompartment: true}); +var N = g.N = 10; +var dbg = Debugger(g); +var cache = new WeakMap; + +var i = 0; +dbg.onDebuggerStatement = function (frame) { + cache.set(frame.arguments[0], i++); +}; +g.eval("function f(x) { debugger; }"); +g.eval("var arr = [], j; for (j = 0; j < N; j++) arr[j] = {};"); +g.eval("for (j = 0; j < N; j++) f(arr[j]);"); +assertEq(i, N); + +gc(); gc(); + +i = 0; +dbg.onDebuggerStatement = function (frame) { + assertEq(cache.get(frame.arguments[0]), i++) +}; +g.eval("for (j = 0; j < N; j++) f(arr[j]);"); +assertEq(i, N); -- cgit v1.2.3