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