]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/multi-put-by-offset-reallocation-cases.js
JavaScriptCore-7600.1.4.16.1.tar.gz
[apple/javascriptcore.git] / tests / stress / multi-put-by-offset-reallocation-cases.js
CommitLineData
81345200
A
1var foos = [
2 function(o) { o.ff = 42; },
3 function(o) { o.ff = 42; },
4 function(o) { o.ff = 42; },
5 function(o) { o.ff = 42; },
6 function(o) { o.ff = 42; },
7 function(o) { o.ff = 42; },
8 function(o) { o.ff = 42; },
9 function(o) { o.ff = 42; }
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";
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 bar(o, i % 8);
85 bar(p, i % 8);
86
87 foos[i % 8](o);
88 foos[i % 8](p);
89
90 if (o.ff != 42)
91 throw "Bad result in o: " + o.ff;
92 if (p.ff != 42)
93 throw "Bad result in o: " + p.ff;
94
95 if (p.a != 1 || p.b != 2 || p.c != 3 || p.d != 4 || p.e != 5 || p.f != 6)
96 throw "Memory corruption"
97 baz(o, i % 8);
98 baz(p, i % 8);
99}
100