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.

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

mercurial