]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/sink-function-past-invalid-check-sneakier.js
eff3483d8ab5209450c68f1c0e99036505956635
[apple/javascriptcore.git] / tests / stress / sink-function-past-invalid-check-sneakier.js
1 function bar(o, p) {
2 if (p)
3 return +o.f;
4 return 42;
5 }
6
7 var globalResult;
8 Function.prototype.valueOf = function() { globalResult = 1; };
9
10 function foo(p, q) {
11 globalResult = 0;
12 var o = function() { };
13 var o2 = {f: o};
14 if (p)
15 bar(o2, q);
16 return globalResult;
17 }
18
19 noInline(foo);
20
21 foo(true, false);
22
23 for (var i = 0; i < 10000; ++i)
24 bar({f:42}, true);
25
26 for (var i = 0; i < 10000; ++i) {
27 var result = foo(false, true);
28 if (result !== 0)
29 throw "Error: bad result: " + result;
30 }
31
32 var result = foo(true, true);
33 if (result !== 1)
34 throw "Error: bad result at end: " + result;
35