js/src/jit-test/tests/debug/gc-05.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // If a Debugger survives its debuggee, its object cache must still be swept.
michael@0 2
michael@0 3 var g2arr = []; // non-debuggee globals
michael@0 4 var xarr = []; // debuggee objects
michael@0 5
michael@0 6 var N = 4, M = 4;
michael@0 7 for (var i = 0; i < N; i++) {
michael@0 8 var g1 = newGlobal();
michael@0 9 g1.M = M;
michael@0 10 var dbg = new Debugger(g1);
michael@0 11 var g2 = g1.eval("newGlobal('same-compartment')");
michael@0 12 g1.x = g2.eval("x = {};");
michael@0 13
michael@0 14 dbg.onDebuggerStatement = function (frame) { xarr.push(frame.eval("x").return); };
michael@0 15 g1.eval("debugger;");
michael@0 16 g2arr.push(g2);
michael@0 17
michael@0 18 g1 = null;
michael@0 19 gc();
michael@0 20 }
michael@0 21
michael@0 22 // At least some of the debuggees have probably been collected at this
michael@0 23 // point. It is nondeterministic, though.
michael@0 24 assertEq(g2arr.length, N);
michael@0 25 assertEq(xarr.length, N);
michael@0 26
michael@0 27 // Try to make g2arr[i].eval eventually allocate a new object in the same
michael@0 28 // location as a previously gc'd object. If the object caches are not being
michael@0 29 // swept, the pointer coincidence will cause a Debugger.Object to be erroneously
michael@0 30 // reused.
michael@0 31 for (var i = 0; i < N; i++) {
michael@0 32 var obj = xarr[i];
michael@0 33 for (j = 0; j < M; j++) {
michael@0 34 assertEq(obj instanceof Debugger.Object, true);
michael@0 35 g2arr[i].eval("x = x.prop = {};");
michael@0 36 obj = obj.getOwnPropertyDescriptor("prop").value;;
michael@0 37 assertEq("seen" in obj, false);
michael@0 38 obj.seen = true;
michael@0 39 gc();
michael@0 40 }
michael@0 41 }

mercurial