michael@0: // Tests that we can use debug scopes with Ion frames. michael@0: // michael@0: // Unfortunately these tests are brittle. They depend on opaque JIT heuristics michael@0: // kicking in. michael@0: michael@0: load(libdir + "jitopts.js"); michael@0: michael@0: if (!jitTogglesMatch(Opts_Ion2NoParallelCompilation)) michael@0: quit(0); michael@0: michael@0: withJitOptions(Opts_Ion2NoParallelCompilation, function () { michael@0: var g = newGlobal(); michael@0: var dbg = new Debugger; michael@0: michael@0: // Note that this *depends* on CCW scripted functions being opaque to Ion michael@0: // optimization and not deoptimizing the frames below the call to toggle. michael@0: g.toggle = function toggle(d) { michael@0: if (d) { michael@0: dbg.addDebuggee(g); michael@0: var frame = dbg.getNewestFrame(); michael@0: assertEq(frame.implementation, "ion"); michael@0: // g is heavyweight but its call object is optimized out, because its michael@0: // arguments and locals are unaliased. michael@0: // michael@0: // Calling frame.environment here should make a fake debug scope that michael@0: // gets things directly from the frame. Calling frame.arguments doesn't michael@0: // go through the scope object and reads directly off the frame. Assert michael@0: // that the two are equal. michael@0: assertEq(frame.environment.getVariable("x"), frame.arguments[1]); michael@0: } michael@0: }; michael@0: michael@0: g.eval("" + function f(d, x) { g(d, x); }); michael@0: g.eval("" + function g(d, x) { michael@0: for (var i = 0; i < 200; i++); michael@0: function inner() { i = 42; }; michael@0: toggle(d); michael@0: // Use x so it doesn't get optimized out. michael@0: x++; michael@0: }); michael@0: michael@0: g.eval("(" + function test() { michael@0: for (i = 0; i < 5; i++) michael@0: f(false, 42); michael@0: f(true, 42); michael@0: } + ")();"); michael@0: });