]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/put-local-conservative.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / put-local-conservative.js
CommitLineData
ed1e77d3
A
1function foo(o, a, b, c) {
2 // Don't do anything real but have some control flow. This causes the PutLocals for a,
3 // b, and c to survive into SSA form. But we don't have any effects, so sinking will be
4 // successful.
5 if (o.f)
6 return 42;
7 else
8 return 0;
9}
10
11function bar(o, y) {
12 var a = y;
13 var b = y + 1;
14 var c = y + 2;
15 var d = y + 3;
16 var e = y + 4;
17 var f = y + 5;
18 var g = y + 6;
19 var h = y + 7;
20 var i = y + 8;
21 var j = y + 9;
22 var k = y + 10;
23 var result = function(p, q) {
24 var x = a + b + c + d + e + f + g + h + i + j + k;
25 if (q) {
26 // Make it appear that it's possible to clobber those closure variables, so that we
27 // load from them again down below.
28 a = b = c = d = e = f = g = h = i = j = k = 42;
29 }
30 if (p)
31 x = foo(o, 1, 2, 3)
32 else
33 x = 5;
34 return x + a + b + c + d + e + f + g + h + i + j + k;
35 };
36 noInline(result);
37 return result;
38}
39
40var o = {f: 42};
41
42for (var i = 0; i < 100000; ++i) {
43 var result = bar(o, i)(true, false);
44 if (result != 42 + 11 * i + 55)
45 throw "Error: bad result: " + result;
46}
47