michael@0: // |jit-test| slow michael@0: michael@0: var nlocals = 50; michael@0: var localstr = ""; michael@0: for (var i = 0; i < nlocals; ++i) michael@0: localstr += "var x" + i + "; "; michael@0: michael@0: /* michael@0: * Attempt to test, in a stack-parameter-independent manner, ComileFunction michael@0: * hitting a stack-commit boundary (which is not an OOM, but requires checking michael@0: * and updating the stack limit). michael@0: */ michael@0: var arr = [function() {return 0}, function() {return 1}, function() {return 2}]; michael@0: var arg = "x"; michael@0: var body = localstr + michael@0: "if (x == 0) return; " + michael@0: "arr[3] = (new Function(arg, body));" + michael@0: "for (var i = 0; i < 4; ++i) arr[i](x-1);"; michael@0: michael@0: // XXX interpreter bailouts during recursion below can cause us to hit the limit quickly. michael@0: try { (new Function(arg, body))(1000); } catch (e) {} michael@0: michael@0: /* michael@0: * Also check for OOM in CompileFunction. To avoid taking 5 seconds, use a michael@0: * monster apply to chew up most the stack. michael@0: */ michael@0: var gotIn = false; michael@0: var threwOut = false; michael@0: try { michael@0: (function() { michael@0: gotIn = true; michael@0: (new Function(arg, body))(10000000); michael@0: }).apply(null, new Array(getMaxArgs())); michael@0: } catch(e) { michael@0: assertEq(""+e, "InternalError: too much recursion"); michael@0: threwOut = true; michael@0: } michael@0: assertEq(threwOut, true); michael@0: /* If tweaking some stack parameter makes this fail, shrink monster apply. */ michael@0: assertEq(gotIn, true);