|
1 // Tests that we can use debug scopes with Ion frames. |
|
2 // |
|
3 // Unfortunately these tests are brittle. They depend on opaque JIT heuristics |
|
4 // kicking in. |
|
5 |
|
6 load(libdir + "jitopts.js"); |
|
7 |
|
8 if (!jitTogglesMatch(Opts_Ion2NoParallelCompilation)) |
|
9 quit(0); |
|
10 |
|
11 withJitOptions(Opts_Ion2NoParallelCompilation, function () { |
|
12 var g = newGlobal(); |
|
13 var dbg = new Debugger; |
|
14 |
|
15 // Note that this *depends* on CCW scripted functions being opaque to Ion |
|
16 // optimization and not deoptimizing the frames below the call to toggle. |
|
17 g.toggle = function toggle(d) { |
|
18 if (d) { |
|
19 dbg.addDebuggee(g); |
|
20 var frame = dbg.getNewestFrame(); |
|
21 assertEq(frame.implementation, "ion"); |
|
22 // g is heavyweight but its call object is optimized out, because its |
|
23 // arguments and locals are unaliased. |
|
24 // |
|
25 // Calling frame.environment here should make a fake debug scope that |
|
26 // gets things directly from the frame. Calling frame.arguments doesn't |
|
27 // go through the scope object and reads directly off the frame. Assert |
|
28 // that the two are equal. |
|
29 assertEq(frame.environment.getVariable("x"), frame.arguments[1]); |
|
30 } |
|
31 }; |
|
32 |
|
33 g.eval("" + function f(d, x) { g(d, x); }); |
|
34 g.eval("" + function g(d, x) { |
|
35 for (var i = 0; i < 200; i++); |
|
36 function inner() { i = 42; }; |
|
37 toggle(d); |
|
38 // Use x so it doesn't get optimized out. |
|
39 x++; |
|
40 }); |
|
41 |
|
42 g.eval("(" + function test() { |
|
43 for (i = 0; i < 5; i++) |
|
44 f(false, 42); |
|
45 f(true, 42); |
|
46 } + ")();"); |
|
47 }); |