michael@0: var o; michael@0: var f1; michael@0: var counter = 0; michael@0: michael@0: function f2(a) { michael@0: bailout(); michael@0: return f2.arguments; michael@0: }; michael@0: michael@0: var restartCode = "counter = 0; " + f2.toSource(); michael@0: michael@0: // We need to reevaluate this function everytime, otherwise it is flagged as michael@0: // having an argument object and it would not be re-entered. michael@0: michael@0: // This test case is checking that f.arguments reflects the overflow or the michael@0: // underflow of arguments after a bailout. Due to the way bailouts are michael@0: // recovered we need to check for the intial frame and for any other JS frame michael@0: // below. michael@0: // michael@0: // To produce a JSFrame, we need to avoid the 'Hot' counters of f1 to be the michael@0: // same as f2, because IonMonkey will try to inline f2 in f1, and not michael@0: // compiling/calling f2 separately. This explain why we ignore the 5 first call michael@0: // of f1 by returning immediately. michael@0: // michael@0: // Bailouts are caused by calling an object function, which is expected to be a michael@0: // function by IonMonkey. So bailout() cause a bailout in the currently michael@0: // compiled function. michael@0: // michael@0: // To avoid any preventive effect to re-enter f2, we re-evaluate it before every michael@0: // test. michael@0: michael@0: // Check bailouts of the initial frame. michael@0: michael@0: eval(restartCode); michael@0: while (counter++ < 50) { michael@0: o = f2(); michael@0: assertEq(o.length, 0); michael@0: } michael@0: michael@0: eval(restartCode); michael@0: while (counter++ < 50) { michael@0: o = f2(21); michael@0: assertEq(o.length, 1); michael@0: assertEq(o[0], 21); michael@0: } michael@0: michael@0: eval(restartCode); michael@0: while (counter++ < 50) { michael@0: o = f2(21,42); michael@0: assertEq(o.length, 2); michael@0: assertEq(o[0], 21); michael@0: assertEq(o[1], 42); michael@0: } michael@0: michael@0: // 100 arguments. michael@0: eval(restartCode); michael@0: while (counter++ < 50) { michael@0: o = f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9); michael@0: assertEq(o.length, 100); michael@0: for (var i in o) michael@0: assertEq(o[i], i % 10); michael@0: } michael@0: michael@0: // 200 arguments. michael@0: eval(restartCode); michael@0: while (counter++ < 50) { michael@0: o = f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9); michael@0: assertEq(o.length, 200); michael@0: for (var i in o) michael@0: assertEq(o[i], i % 10); michael@0: } michael@0: michael@0: // 300 arguments. michael@0: eval(restartCode); michael@0: while (counter++ < 50) { michael@0: o = f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9); michael@0: assertEq(o.length, 300); michael@0: for (var i in o) michael@0: assertEq(o[i], i % 10); michael@0: } michael@0: michael@0: // Check bailouts of one frame which is not the initial frame. michael@0: michael@0: eval(restartCode); michael@0: f1 = function() { michael@0: if (counter < 5) return 0; michael@0: return f2(); michael@0: }; michael@0: while (counter++ < 50) { michael@0: o = f1(); michael@0: if (counter < 5) continue; michael@0: assertEq(o.length, 0); michael@0: } michael@0: michael@0: eval(restartCode); michael@0: f1 = function() { michael@0: if (counter < 5) return 0; michael@0: return f2(21); michael@0: }; michael@0: while (counter++ < 50) { michael@0: o = f1(); michael@0: if (counter < 5) continue; michael@0: assertEq(o.length, 1); michael@0: assertEq(o[0], 21); michael@0: } michael@0: michael@0: eval(restartCode); michael@0: f1 = function() { michael@0: if (counter < 5) return 0; michael@0: return f2(21,42); michael@0: }; michael@0: while (counter++ < 50) { michael@0: o = f1(); michael@0: if (counter < 5) continue; michael@0: assertEq(o.length, 2); michael@0: assertEq(o[0], 21); michael@0: assertEq(o[1], 42); michael@0: } michael@0: michael@0: // 100 arguments. michael@0: eval(restartCode); michael@0: f1 = function() { michael@0: if (counter < 5) return 0; michael@0: return f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9); michael@0: }; michael@0: while (counter++ < 50) { michael@0: o = f1(); michael@0: if (counter < 5) continue; michael@0: assertEq(o.length, 100); michael@0: for (var i in o) michael@0: assertEq(o[i], i % 10); michael@0: } michael@0: michael@0: // 200 arguments. michael@0: eval(restartCode); michael@0: f1 = function() { michael@0: if (counter < 5) return 0; michael@0: return f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9); michael@0: }; michael@0: while (counter++ < 50) { michael@0: o = f1(); michael@0: if (counter < 5) continue; michael@0: assertEq(o.length, 200); michael@0: for (var i in o) michael@0: assertEq(o[i], i % 10); michael@0: } michael@0: michael@0: // 300 arguments. michael@0: eval(restartCode); michael@0: f1 = function() { michael@0: if (counter < 5) return 0; michael@0: return f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9, michael@0: 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9); michael@0: }; michael@0: while (counter++ < 500) { michael@0: o = f1(); michael@0: if (counter < 5) continue; michael@0: assertEq(o.length, 300); michael@0: for (var i in o) michael@0: assertEq(o[i], i % 10); michael@0: }