]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | var global = null; |
2 | ||
3 | function 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 | ||
11 | noInline(foo); | |
12 | ||
13 | var lastObject = null; | |
14 | ||
15 | function 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 | ||
26 | for (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 | ||
37 | var result = foo(true, 2147483647); | |
38 | if (result != 42 + 2147483647 + 1) | |
39 | throw "Error: bad result at end: " + result; | |
40 | validateEscape("at end"); |