]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/escape-object-in-diamond-then-exit.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / escape-object-in-diamond-then-exit.js
CommitLineData
ed1e77d3
A
1var global = null;
2
3function foo(p, q) {
4 var o = {f:42};
5 if (p)
6 global = o;
7 var tmp = q + 1;
8 return o.f + tmp;
9}
10
11noInline(foo);
12
13var lastObject = null;
14
15function validateEscape(when) {
16 if (global === lastObject)
17 throw "Error: bad value in global " + when + ", identical to lastObject.";
18 if (global === null || !(typeof global == "object"))
19 throw "Error: bad value in global " + when + ": it's not an object.";
20 if (global.f != 42)
21 throw "Error: bad value in global " + when + ": f isn't 42, it's: " + global.f;
22 lastObject = global;
23 global = null;
24}
25
26for (var i = 0; i < 10000; ++i) {
27 var escape = !!(i & 1);
28 var result = foo(escape, 42);
29 if (result != 42 + 42 + 1)
30 throw "Error: bad result: " + result;
31 if (escape)
32 validateEscape("in loop");
33 else if (global !== null)
34 throw "Error: bad value in global: " + global;
35}
36
37var result = foo(true, 2147483647);
38if (result != 42 + 2147483647 + 1)
39 throw "Error: bad result at end: " + result;
40validateEscape("at end");