michael@0: // |jit-test| debug michael@0: // Test that we create new Debugger.Frames and reuse old ones correctly with recursion. michael@0: michael@0: var g = newGlobal(); michael@0: g.debuggeeGlobal = this; michael@0: g.eval("(" + function () { michael@0: function id(f) { michael@0: return ("id" in f) ? f.id : (f.id = nextid++); michael@0: } michael@0: michael@0: var dbg = new Debugger(debuggeeGlobal); michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: var a = []; michael@0: for (; frame; frame = frame.older) michael@0: a.push(frame); michael@0: var s = ''; michael@0: while (a.length) michael@0: s += id(a.pop()); michael@0: results.push(s); michael@0: }; michael@0: } + ")();"); michael@0: michael@0: function cons(a, b) { michael@0: debugger; michael@0: return [a, b]; michael@0: } michael@0: michael@0: function tree(n) { michael@0: if (n < 2) michael@0: return n; michael@0: return cons(tree(n - 1), tree(n - 2)); michael@0: } michael@0: michael@0: g.eval("results = []; nextid = 0;"); michael@0: debugger; michael@0: assertEq(g.results.join(","), "0"); michael@0: assertEq(g.nextid, 1); michael@0: michael@0: g.eval("results = [];"); michael@0: tree(2); michael@0: assertEq(g.results.join(","), "012"); // 0=global, 1=tree, 2=cons michael@0: michael@0: g.eval("results = []; nextid = 1;"); michael@0: tree(3); michael@0: assertEq(g.results.join(","), "0123,014"); //0=global, 1=tree(3), 2=tree(2), 3=cons, 4=cons michael@0: michael@0: g.eval("results = []; nextid = 1;"); michael@0: tree(4); michael@0: // 0=global, 1=tree(4), 2=tree(3), 3=tree(2), 4=cons, tree(1), 5=cons, 6=tree(2), 7=cons, 8=cons michael@0: assertEq(g.results.join(","), "01234,0125,0167,018");