1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Frame-identity-03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +// |jit-test| debug 1.5 +// Test that we create new Debugger.Frames and reuse old ones correctly with recursion. 1.6 + 1.7 +var g = newGlobal(); 1.8 +g.debuggeeGlobal = this; 1.9 +g.eval("(" + function () { 1.10 + function id(f) { 1.11 + return ("id" in f) ? f.id : (f.id = nextid++); 1.12 + } 1.13 + 1.14 + var dbg = new Debugger(debuggeeGlobal); 1.15 + dbg.onDebuggerStatement = function (frame) { 1.16 + var a = []; 1.17 + for (; frame; frame = frame.older) 1.18 + a.push(frame); 1.19 + var s = ''; 1.20 + while (a.length) 1.21 + s += id(a.pop()); 1.22 + results.push(s); 1.23 + }; 1.24 + } + ")();"); 1.25 + 1.26 +function cons(a, b) { 1.27 + debugger; 1.28 + return [a, b]; 1.29 +} 1.30 + 1.31 +function tree(n) { 1.32 + if (n < 2) 1.33 + return n; 1.34 + return cons(tree(n - 1), tree(n - 2)); 1.35 +} 1.36 + 1.37 +g.eval("results = []; nextid = 0;"); 1.38 +debugger; 1.39 +assertEq(g.results.join(","), "0"); 1.40 +assertEq(g.nextid, 1); 1.41 + 1.42 +g.eval("results = [];"); 1.43 +tree(2); 1.44 +assertEq(g.results.join(","), "012"); // 0=global, 1=tree, 2=cons 1.45 + 1.46 +g.eval("results = []; nextid = 1;"); 1.47 +tree(3); 1.48 +assertEq(g.results.join(","), "0123,014"); //0=global, 1=tree(3), 2=tree(2), 3=cons, 4=cons 1.49 + 1.50 +g.eval("results = []; nextid = 1;"); 1.51 +tree(4); 1.52 +// 0=global, 1=tree(4), 2=tree(3), 3=tree(2), 4=cons, tree(1), 5=cons, 6=tree(2), 7=cons, 8=cons 1.53 +assertEq(g.results.join(","), "01234,0125,0167,018");