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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     2 // Test exotic ways of triggering recompilation.
     4 // Lowered native call.
     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);
    14 // Recompilation triggered by local function.
    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 }
    28 // Lowered scripted call to apply returning code pointer.
    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);
    43 // Lowered scripted call returning NULL.
    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);
    58 // Recompilation out of SplatApplyArgs.
    60 weirdarray = [,,1,2,3];
    61 Object.defineProperty(weirdarray, 0, {get: function() { vglobal = 'true'; }});
    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);

mercurial