js/src/jit-test/tests/debug/clear-old-analyses-02.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.

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

mercurial