]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/fold-multi-put-by-offset-to-put-by-offset.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / fold-multi-put-by-offset-to-put-by-offset.js
1 function foo(o) {
2 o.f = (o.f | 0) + 42;
3 }
4
5 function callFoo(o) {
6 return foo(o);
7 }
8
9 noInline(callFoo);
10
11 for (var i = 0; i < 10000; ++i) {
12 var object;
13 if ((i % 3) == 0)
14 object = {g:3};
15 else if ((i % 3) == 1)
16 object = {f:1, g:2};
17 else if ((i % 3) == 2)
18 object = {g:1, f:2};
19 callFoo(object);
20 if (object.f != 42 + (i % 3))
21 throw "Error: bad result for i = " + i + ": " + object.f;
22 }
23
24 function bar(o) {
25 var result = o.f;
26 foo(o);
27 return result;
28 }
29
30 noInline(bar);
31
32 for (var i = 0; i < 100000; ++i) {
33 var o = {f:42};
34 var result = bar(o);
35 if (result != 42)
36 throw "Error: bad result at end: " + result;
37 if (o.f != 42 + 42)
38 throw "Error: bad o.f: " + o.f;
39 }
40