]> git.saurik.com Git - apple/javascriptcore.git/blame_incremental - tests/stress/arguments-copy-register-array-backing-store.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / arguments-copy-register-array-backing-store.js
... / ...
CommitLineData
1var foo = function(o) {
2 return arguments;
3};
4
5var bar = function() {
6 var a = Array.prototype.slice.call(arguments);
7 var sum = 0;
8 for (var i = 0; i < a.length; ++i)
9 sum += a[i];
10 return sum;
11};
12
13var args = foo({}, 1, 2, 3);
14var expectedArgs = Array.prototype.slice.call(args);
15
16edenGC();
17
18var expectedResult = 0;
19var result = 0;
20for (var i = 0; i < 10000; ++i) {
21 expectedResult += i + i + 1 + i + 2;
22 result += bar(i, i + 1, i + 2);
23}
24
25if (result != expectedResult)
26 throw new Error("Incorrect result: " + result + " != " + expectedResult);
27
28for (var i = 0; i < expectedArgs.length; ++i) {
29 if (args[i] !== expectedArgs[i])
30 throw new Error("Incorrect arg result");
31}
32