Environment-getVariable-13.js (1588B)
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 // GCs can invalidate JIT code and cause this test to fail. 9 gczeal(0); 10 11 if (!jitTogglesMatch(Opts_Ion2NoOffthreadCompilation)) 12 quit(0); 13 14 withJitOptions(Opts_Ion2NoOffthreadCompilation, function () { 15 var g = newGlobal({newCompartment: true}); 16 var dbg = new Debugger; 17 18 // Note that this *depends* on CCW scripted functions being opaque to Ion 19 // optimization and not deoptimizing the frames below the call to toggle. 20 g.toggle = function toggle(d) { 21 if (d) { 22 dbg.addDebuggee(g); 23 var frame = dbg.getNewestFrame(); 24 assertEq(frame.implementation, "ion"); 25 // g is heavyweight but its call object is optimized out, because its 26 // arguments and locals are unaliased. 27 // 28 // Calling frame.environment here should make a fake debug scope that 29 // gets things directly from the frame. Calling frame.arguments doesn't 30 // go through the scope object and reads directly off the frame. Assert 31 // that the two are equal. 32 assertEq(frame.environment.getVariable("x"), frame.arguments[1]); 33 } 34 }; 35 36 g.eval("" + function f(d, x) { g(d, x); }); 37 g.eval("" + function g(d, x) { 38 for (var i = 0; i < 100; i++); 39 function inner() { i = 42; }; 40 toggle(d); 41 // Use x so it doesn't get optimized out. 42 x++; 43 }); 44 45 g.eval("(" + function test() { 46 for (i = 0; i < 15; i++) 47 f(false, 42); 48 f(true, 42); 49 } + ")();"); 50 });