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