]> git.saurik.com Git - apple/javascriptcore.git/blame_incremental - tests/stress/elide-new-object-dag-then-exit.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / elide-new-object-dag-then-exit.js
... / ...
CommitLineData
1function sumOfArithSeries(limit) {
2 return limit * (limit + 1) / 2;
3}
4
5var n = 10000000;
6
7function bar() { }
8
9function verify(q, i) {
10 if (q.f == q.g)
11 throw "Error: q.f == q.g";
12 if (q.f.f != q.g.f)
13 throw "Error: q.f.f != q.g.f";
14 if (q.f.f.f != i)
15 throw "Error: q.f.f.f != i";
16}
17
18function foo() {
19 var result = 0;
20 for (var i = 0; i < n; ++i) {
21 var leaf = {f:i};
22 var o = {f:leaf};
23 var p = {f:leaf};
24 var q = {f:o, g:p};
25 result += q.f.f.f;
26 if (i >= n - 100) {
27 // We want the materialization to happen in the exit. So, before calling the thing that
28 // causes the materialization, we call bar(). We've never profiled this call at the time
29 // of FTL compilation, so this should be an exit.
30 bar();
31 verify(q, i);
32 }
33 }
34 return result;
35}
36
37noInline(foo);
38noInline(verify);
39noInline(bar);
40
41var result = foo();
42if (result != sumOfArithSeries(n - 1))
43 throw "Error: bad result: " + result;