1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/clear-old-analyses-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +// |jit-test| error:AllDone 1.5 +// When we leave debug mode in a compartment, we must throw away all 1.6 +// analyses in that compartment (debug mode affects the results of 1.7 +// analysis, so they become out of date). We cannot skip this step when 1.8 +// there are debuggee frames on the stack. 1.9 + 1.10 +var g = newGlobal(); 1.11 +var dbg = new Debugger(); 1.12 +var gw = dbg.addDebuggee(g); 1.13 + 1.14 +g.eval("" + 1.15 + function fib(n) { 1.16 + var a = 0, b = 1; 1.17 + while (n-- > 0) 1.18 + b = b+a, a = b-a; 1.19 + return b; 1.20 + }); 1.21 + 1.22 + 1.23 +// Cause g.fib to be jitted. This creates an analysis with debug mode on. 1.24 +g.fib(20); 1.25 + 1.26 +// Setting a breakpoint in g.f causes us to throw away the jit code, but 1.27 +// not the analysis. 1.28 +gw.makeDebuggeeValue(g.fib).script.setBreakpoint(0, { hit: function (f) { } }); 1.29 + 1.30 +// Take g out of debug mode, with debuggee code on the stack. In older 1.31 +// code, this would not trigger a cleansing GC, so the script will 1.32 +// retain its analysis. 1.33 +dbg.onDebuggerStatement = function (f) { 1.34 + dbg.removeDebuggee(g); 1.35 +}; 1.36 +g.eval('debugger'); 1.37 + 1.38 +// Run g.fib again, causing it to be re-jitted. If the original analysis is 1.39 +// still present, JM will assert, because it is not in debug mode. 1.40 +g.fib(20); 1.41 + 1.42 +throw('AllDone');