js/src/jit-test/tests/jaeger/recompile/exotic.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial