optimized-out-02.js (995B)
1 // Test that prevUpToDate on frames are cleared. 2 3 var g = newGlobal({newCompartment: true}); 4 var dbg = new Debugger(g); 5 6 g.eval(` 7 function outer(unaliasedArg) { 8 var unaliasedVar = unaliasedArg + 42; 9 var aliasedVar = unaliasedArg; 10 11 inner(); 12 return unaliasedVar; // To prevent the JIT from optimizing out unaliasedVar. 13 14 function inner() { 15 aliasedVar++; 16 } 17 } 18 `); 19 20 var log = ""; 21 for (var script of dbg.findScripts()) { 22 if (script.displayName === "inner") { 23 script.setBreakpoint(0, { hit: function(frame) { 24 // Force updateLiveScopes. 25 var outerEnv = frame.environment; 26 27 // Get the environment of outer's frame on the stack, so that we may 28 // recover unaliased bindings in the debug scope. 29 outerEnv = frame.older.environment; 30 log += outerEnv.getVariable('unaliasedArg'); // 42 31 log += outerEnv.getVariable('unaliasedVar'); // 84 32 log += outerEnv.getVariable('aliasedVar'); // 42 33 }}); 34 } 35 } 36 37 g.outer(42); 38 assertEq(log, "428442");