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