Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // |jit-test| error:AllDone |
michael@0 | 2 | // When we leave debug mode in a compartment, we must throw away all |
michael@0 | 3 | // analyses in that compartment (debug mode affects the results of |
michael@0 | 4 | // analysis, so they become out of date). We cannot skip this step when |
michael@0 | 5 | // there are debuggee frames on the stack. |
michael@0 | 6 | |
michael@0 | 7 | var g = newGlobal(); |
michael@0 | 8 | var dbg = new Debugger(); |
michael@0 | 9 | var gw = dbg.addDebuggee(g); |
michael@0 | 10 | |
michael@0 | 11 | g.eval("" + |
michael@0 | 12 | function fib(n) { |
michael@0 | 13 | var a = 0, b = 1; |
michael@0 | 14 | while (n-- > 0) |
michael@0 | 15 | b = b+a, a = b-a; |
michael@0 | 16 | return b; |
michael@0 | 17 | }); |
michael@0 | 18 | |
michael@0 | 19 | |
michael@0 | 20 | // Cause g.fib to be jitted. This creates an analysis with debug mode on. |
michael@0 | 21 | g.fib(20); |
michael@0 | 22 | |
michael@0 | 23 | // Setting a breakpoint in g.f causes us to throw away the jit code, but |
michael@0 | 24 | // not the analysis. |
michael@0 | 25 | gw.makeDebuggeeValue(g.fib).script.setBreakpoint(0, { hit: function (f) { } }); |
michael@0 | 26 | |
michael@0 | 27 | // Take g out of debug mode, with debuggee code on the stack. In older |
michael@0 | 28 | // code, this would not trigger a cleansing GC, so the script will |
michael@0 | 29 | // retain its analysis. |
michael@0 | 30 | dbg.onDebuggerStatement = function (f) { |
michael@0 | 31 | dbg.removeDebuggee(g); |
michael@0 | 32 | }; |
michael@0 | 33 | g.eval('debugger'); |
michael@0 | 34 | |
michael@0 | 35 | // Run g.fib again, causing it to be re-jitted. If the original analysis is |
michael@0 | 36 | // still present, JM will assert, because it is not in debug mode. |
michael@0 | 37 | g.fib(20); |
michael@0 | 38 | |
michael@0 | 39 | throw('AllDone'); |