js/src/jit-test/tests/debug/clear-old-analyses-02.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:fbf20af8da5c
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.
6
7 var g = newGlobal();
8 var dbg = new Debugger();
9 var gw = dbg.addDebuggee(g);
10
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 });
18
19
20 // Cause g.fib to be jitted. This creates an analysis with debug mode on.
21 g.fib(20);
22
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) { } });
26
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');
34
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);
38
39 throw('AllDone');

mercurial