Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // |jit-test| slow
3 var nlocals = 50;
4 var localstr = "";
5 for (var i = 0; i < nlocals; ++i)
6 localstr += "var x" + i + "; ";
8 /*
9 * Attempt to test, in a stack-parameter-independent manner, ComileFunction
10 * hitting a stack-commit boundary (which is not an OOM, but requires checking
11 * and updating the stack limit).
12 */
13 var arr = [function() {return 0}, function() {return 1}, function() {return 2}];
14 var arg = "x";
15 var body = localstr +
16 "if (x == 0) return; " +
17 "arr[3] = (new Function(arg, body));" +
18 "for (var i = 0; i < 4; ++i) arr[i](x-1);";
20 // XXX interpreter bailouts during recursion below can cause us to hit the limit quickly.
21 try { (new Function(arg, body))(1000); } catch (e) {}
23 /*
24 * Also check for OOM in CompileFunction. To avoid taking 5 seconds, use a
25 * monster apply to chew up most the stack.
26 */
27 var gotIn = false;
28 var threwOut = false;
29 try {
30 (function() {
31 gotIn = true;
32 (new Function(arg, body))(10000000);
33 }).apply(null, new Array(getMaxArgs()));
34 } catch(e) {
35 assertEq(""+e, "InternalError: too much recursion");
36 threwOut = true;
37 }
38 assertEq(threwOut, true);
39 /* If tweaking some stack parameter makes this fail, shrink monster apply. */
40 assertEq(gotIn, true);