Skip to content

Commit

Permalink
Bug 1688791 - Part 1: Remove saveBytecode option from evaluate shell …
Browse files Browse the repository at this point in the history
…function. r=tcampbell

Differential Revision: https://phabricator.services.mozilla.com/D121267
  • Loading branch information
arai-a committed Sep 21, 2021
1 parent 8b739e8 commit c8ed1a1
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 153 deletions.
14 changes: 3 additions & 11 deletions js/src/jit-test/lib/bytecode-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,9 @@ function evalWithCache(code, ctx) {
if (!("global" in ctx))
ctx.global = newGlobal({newCompartment: ctx.newCompartment});

// NOTE: Run-once scripts must use incremental mode since they may use
// singleton objects that are mutated by the time the bytecode is captured in
// non-incremental mode.
if (!("isRunOnce" in ctx))
ctx.isRunOnce = incremental;

var ctx_save;
if (incremental)
ctx_save = Object.create(ctx, {saveIncrementalBytecode: { value: true } });
else
ctx_save = Object.create(ctx, {saveBytecode: { value: true } });
var ctx_save = Object.create(ctx, {
saveIncrementalBytecode: { value: true }
});

// Fetch the verification function from the evaluation context. This function
// is used to assert the state of the script/function after each run of the
Expand Down
2 changes: 1 addition & 1 deletion js/src/jit-test/tests/basic/bug1061534.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ evalWithCache(test, {});
function evalWithCache(code, ctx) {
code = cacheEntry(code);
ctx.global = newGlobal({ cloneSingletons: true });
var res1 = evaluate(code, Object.create(ctx, {saveBytecode: { value: true } }));
var res1 = evaluate(code, Object.create(ctx, {saveIncrementalBytecode: { value: true } }));
}
if (typeof assertThrowsInstanceOf === 'undefined') {
var assertThrowsInstanceOf = function assertThrowsInstanceOf(f, ctor, msg) {};
Expand Down
2 changes: 1 addition & 1 deletion js/src/jit-test/tests/gc/bug-1108007.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gczeal(2);
evaluate(cacheEntry((function() {
return "(new String(\"\"))"
})()), Object.create({ global: newGlobal({ cloneSingletons: true }) }, {
saveBytecode: {
saveIncrementalBytecode: {
value: true
}
}))
Expand Down
2 changes: 1 addition & 1 deletion js/src/jit-test/tests/gc/bug-1696880.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gczeal(4);
function a(b) {
c = cacheEntry(b);
evaluate(c, {
saveBytecode: true
saveIncrementalBytecode: true
});
return c;
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/jit-test/tests/parser/bug-1319443.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ function f() {}
Object.freeze(this);
`);

evaluate(code, { global, saveBytecode: true });
evaluate(code, { global, saveBytecode: true });
evaluate(code, { global, saveIncrementalBytecode: true });
evaluate(code, { global, saveIncrementalBytecode: true });
2 changes: 1 addition & 1 deletion js/src/jit-test/tests/parser/bug-1431353.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function encodeScript(source)
{
let entry = cacheEntry(source);
let global = newGlobal({ cloneSingletons: true });
evaluate(entry, { global: global, saveBytecode: true });
evaluate(entry, { global: global, saveIncrementalBytecode: true });
return entry;
}

Expand Down
15 changes: 4 additions & 11 deletions js/src/jit-test/tests/xdr/decode-off-thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ function evalWithCacheLoadOffThread(code, ctx) {
});
code = code instanceof Object ? code : cacheEntry(code);

var incremental = ctx.incremental || false;

// We create a new global ...
if (!("global" in ctx))
ctx.global = newGlobal({ cloneSingletons: !incremental });
ctx.global = newGlobal();

var ctx_save;
if (incremental)
ctx_save = Object.create(ctx, {saveIncrementalBytecode: { value: true } });
else
ctx_save = Object.create(ctx, {saveBytecode: { value: true } });
var ctx_save = Object.create(ctx, {
saveIncrementalBytecode: { value: true }
});

ctx.global.generation = 0;
evaluate(code, ctx_save);
Expand All @@ -34,7 +30,6 @@ test = `
1;
`;
evalWithCacheLoadOffThread(test, {});
evalWithCacheLoadOffThread(test, { incremental: true });

// Decode object literals.
test = `
Expand All @@ -43,7 +38,6 @@ test = `
assertEq(obj.a, 2);
`;
evalWithCacheLoadOffThread(test, {});
evalWithCacheLoadOffThread(test, { incremental: true });

// Decode functions.
test = `
Expand All @@ -53,6 +47,5 @@ test = `
assertEq(g()(), 1);
`;
evalWithCacheLoadOffThread(test, {});
evalWithCacheLoadOffThread(test, { incremental: true });


5 changes: 0 additions & 5 deletions js/src/jit-test/tests/xdr/lazy-class-definition.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// |jit-test| --off-thread-parse-global

// NOTE: This tests legacy XDR behaviour. Once that support is removed, just
// remove this annotation and let test use Stencil.

load(libdir + 'bytecode-cache.js');

// Bury the class definition deep in a lazy function to hit edge cases of lazy
Expand Down
2 changes: 1 addition & 1 deletion js/src/jit-test/tests/xdr/lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ var g1 = newGlobal({ cloneSingletons: true });
var g2 = newGlobal();
var res = "function f(){}";
var code = cacheEntry(res + "; f();");
evaluate(code, {global:g1, compileAndGo: true, saveBytecode: {value: true}});
evaluate(code, {global:g1, saveIncrementalBytecode: {value: true}});
evaluate(code, {global:g2, loadBytecode: true});
gc();
assertEq(g2.f.toString(), res);
Expand Down
9 changes: 1 addition & 8 deletions js/src/jit-test/tests/xdr/runonce.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
load(libdir + "asserts.js")

// JS::EncodeScript cannot be use for run-once scripts.
evaluate(cacheEntry(""), { saveBytecode: true });
evaluate(cacheEntry(""), { saveBytecode: true, isRunOnce: false });
assertErrorMessage(() => {
evaluate(cacheEntry(""), { saveBytecode: true, isRunOnce: true });
}, Error, "run-once script are not supported by XDR");

// Incremental XDR doesn't have any of these restrictions.
// Incremental XDR doesn't have run-once script restrictions.
evaluate(cacheEntry(""), { saveIncrementalBytecode: true });
evaluate(cacheEntry(""), { saveIncrementalBytecode: true, isRunOnce: false });
evaluate(cacheEntry(""), { saveIncrementalBytecode: true, isRunOnce: true });
4 changes: 2 additions & 2 deletions js/src/jit-test/tests/xdr/tagged-template-literals-2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var code = cacheEntry("(x => JSON.stringify(x))`bar`;");
var g = newGlobal({ cloneSingletons: true });
assertEq("[\"bar\"]", evaluate(code, { global: g, saveBytecode: true }));
assertEq("[\"bar\"]", evaluate(code, { global: g, loadBytecode: true }));
assertEq("[\"bar\"]", evaluate(code, { global: g, saveIncrementalBytecode: true }));
assertEq("[\"bar\"]", evaluate(code, { global: g, saveIncrementalBytecode: true }));
2 changes: 1 addition & 1 deletion js/src/jit-test/tests/xdr/tagged-template-literals.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var code = cacheEntry("assertEq('bar', String.raw`bar`);");
var g = newGlobal({ cloneSingletons: true });
evaluate(code, { global: g, saveBytecode: true });
evaluate(code, { global: g, saveIncrementalBytecode: true });
evaluate(code, { global: g, loadBytecode: true })
Loading

0 comments on commit c8ed1a1

Please sign in to comment.