|
1 |
|
2 // Test exotic ways of triggering recompilation. |
|
3 |
|
4 // Lowered native call. |
|
5 |
|
6 var x = 0; |
|
7 var y = true; |
|
8 for (var i = 0; i < 20; i++) { |
|
9 x += Array.map.apply(undefined, [[0], function(x) { if (i == 10) eval("y = 20"); return 1; }])[0]; |
|
10 } |
|
11 assertEq(x, 20); |
|
12 assertEq(y, 20); |
|
13 |
|
14 // Recompilation triggered by local function. |
|
15 |
|
16 var o = {}; |
|
17 function what(q) { |
|
18 function inner() { return q; } |
|
19 o.f = inner; |
|
20 var a = o.f(); |
|
21 return a; |
|
22 } |
|
23 for (var i = 0; i < 10; i++) { |
|
24 var a = what(i); |
|
25 assertEq(a, i); |
|
26 } |
|
27 |
|
28 // Lowered scripted call to apply returning code pointer. |
|
29 |
|
30 var global = 3; |
|
31 function foo(x, y) { |
|
32 var q = x.apply(null, y); |
|
33 if (q != 10) |
|
34 assertEq(global, true); |
|
35 } |
|
36 foo(function(a) { global = a; return 10; }, [1]); |
|
37 foo(function(a) { global = a; return 10; }, [1]); |
|
38 foo(function(a) { global = a; return 10; }, [1]); |
|
39 assertEq(global, 1); |
|
40 foo(function(a) { global = a; return 3; }, [true]); |
|
41 assertEq(global, true); |
|
42 |
|
43 // Lowered scripted call returning NULL. |
|
44 |
|
45 var oglobal = 3; |
|
46 function xfoo(x, y) { |
|
47 var q = x.apply(null, y); |
|
48 if (q != 10) |
|
49 assertEq(oglobal, true); |
|
50 } |
|
51 xfoo(function(a) { oglobal = a; return 10; }, [1]); |
|
52 xfoo(function(a) { oglobal = a; return 10; }, [1]); |
|
53 xfoo(function(a) { oglobal = a; return 10; }, [1]); |
|
54 assertEq(oglobal, 1); |
|
55 xfoo(function(a) { [1,2,3]; oglobal = a; return 3; }, [true]); |
|
56 assertEq(oglobal, true); |
|
57 |
|
58 // Recompilation out of SplatApplyArgs. |
|
59 |
|
60 weirdarray = [,,1,2,3]; |
|
61 Object.defineProperty(weirdarray, 0, {get: function() { vglobal = 'true'; }}); |
|
62 |
|
63 var vglobal = 3; |
|
64 function yfoo(x, y) { |
|
65 var q = x.apply(null, y); |
|
66 if (q != 10) |
|
67 assertEq(vglobal, 'true'); |
|
68 else |
|
69 assertEq(vglobal, 3); |
|
70 } |
|
71 yfoo(function(a) { return 10; }, [1]); |
|
72 yfoo(function(a) { return 10; }, [1]); |
|
73 yfoo(function(a) { return 10; }, [1]); |
|
74 yfoo(function() { return 0; }, weirdarray); |