js/src/jit-test/lib/bytecode-cache.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 function evalWithCache(code, ctx) {
     3   ctx = ctx || {};
     4   ctx = Object.create(ctx, {
     5     fileName: { value: "evalWithCacheCode.js" },
     6     lineNumber: { value: 0 }
     7   });
     8   code = code instanceof Object ? code : cacheEntry(code);
    10   // We create a new global ...
    11   if (!("global" in ctx))
    12     ctx.global = newGlobal();
    14   // ... and by default enable compileAndGo.
    15   if (!("compileAndGo" in ctx))
    16     ctx.compileAndGo = true;
    18   // Fetch the verification function from the evaluation context.  This function
    19   // is used to assert the state of the script/function after each run of the
    20   // evaluate function.
    21   var checkAfter = ctx.checkAfter || function(ctx) {};
    23   // The generation counter is used to represent environment variations which
    24   // might cause the program to run differently, and thus to have a different
    25   // set of functions executed.
    26   ctx.global.generation = 0;
    27   var res1 = evaluate(code, Object.create(ctx, {saveBytecode: { value: true } }));
    28   checkAfter(ctx);
    30   ctx.global.generation = 1;
    31   var res2 = evaluate(code, Object.create(ctx, {loadBytecode: { value: true }, saveBytecode: { value: true } }));
    32   checkAfter(ctx);
    34   ctx.global.generation = 2;
    35   var res3 = evaluate(code, Object.create(ctx, {loadBytecode: { value: true } }));
    36   checkAfter(ctx);
    38   ctx.global.generation = 3;
    39   var res0 = evaluate(code, ctx);
    40   checkAfter(ctx);
    42   if (ctx.assertEqResult) {
    43     assertEq(res0, res1);
    44     assertEq(res0, res2);
    45     assertEq(res0, res3);
    46   }
    47 }

mercurial