Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 }