]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/multi-put-by-offset-reallocation-butterfly-cse.js
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / tests / stress / multi-put-by-offset-reallocation-butterfly-cse.js
CommitLineData
81345200
A
1var foos = [
2 function(o) { o[0] = 5; o.ff = 42; o[0] = 6; },
3 function(o) { o[0] = 5; o.ff = 42; o[0] = 6; },
4 function(o) { o[0] = 5; o.ff = 42; o[0] = 6; },
5 function(o) { o[0] = 5; o.ff = 42; o[0] = 6; },
6 function(o) { o[0] = 5; o.ff = 42; o[0] = 6; },
7 function(o) { o[0] = 5; o.ff = 42; o[0] = 6; },
8 function(o) { o[0] = 5; o.ff = 42; o[0] = 6; },
9 function(o) { o[0] = 5; o.ff = 42; o[0] = 6; }
10];
11
12if (foos.length != 8)
13 throw "Error";
14
15function bar(o, n) {
16 if (n == 0)
17 return;
18 o.na = 1;
19 if (n == 1)
20 return;
21 o.nb = 2;
22 if (n == 2)
23 return;
24 o.nc = 3;
25 if (n == 3)
26 return;
27 o.nd = 4;
28 if (n == 4)
29 return;
30 o.ne = 5;
31 if (n == 5)
32 return;
33 o.nf = 6;
34 if (n == 6)
35 return;
36 o.ng = 7;
37 if (n == 7)
38 return;
39 o.nh = 8;
40}
41
42function baz(o, n) {
43 if (n == 0)
44 return;
45 if (o.na != 1)
46 throw "Memory corruption; have o.na = " + o.na;
47 if (n == 1)
48 return;
49 if (o.nb != 2)
50 throw "Memory corruption";
51 if (n == 2)
52 return;
53 if (o.nc != 3)
54 throw "Memory corruption";
55 if (n == 3)
56 return;
57 if (o.nd != 4)
58 throw "Memory corruption";
59 if (n == 4)
60 return;
61 if (o.ne != 5)
62 throw "Memory corruption";
63 if (n == 5)
64 return;
65 if (o.nf != 6)
66 throw "Memory corruption";
67 if (n == 6)
68 return;
69 if (o.ng != 7)
70 throw "Memory corruption";
71 if (n == 7)
72 return;
73 if (o.nh != 8)
74 throw "Memory corruption";
75}
76
77for (var i = 0; i < 8; ++i)
78 noInline(foos[i]);
79noInline(bar);
80
81for (var i = 0; i < 100000; ++i) {
82 var o = {};
83 var p = {a:1, b:2, c:3, d:4, e:5, f:6};
84 o[0] = 0;
85 p[0] = 0;
86 bar(o, i % 8);
87 bar(p, i % 8);
88
89 foos[i % 8](o);
90 foos[i % 8](p);
91
92 if (o.ff != 42)
93 throw "Bad result in o: " + o.ff;
94 if (p.ff != 42)
95 throw "Bad result in o: " + p.ff;
96
97 if (p.a != 1 || p.b != 2 || p.c != 3 || p.d != 4 || p.e != 5 || p.f != 6)
98 throw "Memory corruption"
99 baz(o, i % 8);
100 baz(p, i % 8);
101}
102