1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/jaeger/recompile/exotic.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 1.4 + 1.5 +// Test exotic ways of triggering recompilation. 1.6 + 1.7 +// Lowered native call. 1.8 + 1.9 +var x = 0; 1.10 +var y = true; 1.11 +for (var i = 0; i < 20; i++) { 1.12 + x += Array.map.apply(undefined, [[0], function(x) { if (i == 10) eval("y = 20"); return 1; }])[0]; 1.13 +} 1.14 +assertEq(x, 20); 1.15 +assertEq(y, 20); 1.16 + 1.17 +// Recompilation triggered by local function. 1.18 + 1.19 +var o = {}; 1.20 +function what(q) { 1.21 + function inner() { return q; } 1.22 + o.f = inner; 1.23 + var a = o.f(); 1.24 + return a; 1.25 +} 1.26 +for (var i = 0; i < 10; i++) { 1.27 + var a = what(i); 1.28 + assertEq(a, i); 1.29 +} 1.30 + 1.31 +// Lowered scripted call to apply returning code pointer. 1.32 + 1.33 +var global = 3; 1.34 +function foo(x, y) { 1.35 + var q = x.apply(null, y); 1.36 + if (q != 10) 1.37 + assertEq(global, true); 1.38 +} 1.39 +foo(function(a) { global = a; return 10; }, [1]); 1.40 +foo(function(a) { global = a; return 10; }, [1]); 1.41 +foo(function(a) { global = a; return 10; }, [1]); 1.42 +assertEq(global, 1); 1.43 +foo(function(a) { global = a; return 3; }, [true]); 1.44 +assertEq(global, true); 1.45 + 1.46 +// Lowered scripted call returning NULL. 1.47 + 1.48 +var oglobal = 3; 1.49 +function xfoo(x, y) { 1.50 + var q = x.apply(null, y); 1.51 + if (q != 10) 1.52 + assertEq(oglobal, true); 1.53 +} 1.54 +xfoo(function(a) { oglobal = a; return 10; }, [1]); 1.55 +xfoo(function(a) { oglobal = a; return 10; }, [1]); 1.56 +xfoo(function(a) { oglobal = a; return 10; }, [1]); 1.57 +assertEq(oglobal, 1); 1.58 +xfoo(function(a) { [1,2,3]; oglobal = a; return 3; }, [true]); 1.59 +assertEq(oglobal, true); 1.60 + 1.61 +// Recompilation out of SplatApplyArgs. 1.62 + 1.63 +weirdarray = [,,1,2,3]; 1.64 +Object.defineProperty(weirdarray, 0, {get: function() { vglobal = 'true'; }}); 1.65 + 1.66 +var vglobal = 3; 1.67 +function yfoo(x, y) { 1.68 + var q = x.apply(null, y); 1.69 + if (q != 10) 1.70 + assertEq(vglobal, 'true'); 1.71 + else 1.72 + assertEq(vglobal, 3); 1.73 +} 1.74 +yfoo(function(a) { return 10; }, [1]); 1.75 +yfoo(function(a) { return 10; }, [1]); 1.76 +yfoo(function(a) { return 10; }, [1]); 1.77 +yfoo(function() { return 0; }, weirdarray);