js/src/jit-test/lib/bytecode-cache.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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