Bug 1694916 - Part 1: Remove RealmBehaviors.disableLazyParsing. r=mgaudet

Differential Revision: https://phabricator.services.mozilla.com/D107006
This commit is contained in:
Tooru Fujisawa 2021-03-04 22:36:22 +00:00
parent 02901b3451
commit 54b9d1db5d
9 changed files with 35 additions and 121 deletions

View File

@ -300,12 +300,6 @@ class JS_PUBLIC_API RealmBehaviors {
return *this;
}
bool disableLazyParsing() const { return disableLazyParsing_; }
RealmBehaviors& setDisableLazyParsing(bool flag) {
disableLazyParsing_ = flag;
return *this;
}
bool clampAndJitterTime() const { return clampAndJitterTime_; }
RealmBehaviors& setClampAndJitterTime(bool flag) {
clampAndJitterTime_ = flag;
@ -346,7 +340,6 @@ class JS_PUBLIC_API RealmBehaviors {
private:
bool discardSource_ = false;
bool disableLazyParsing_ = false;
bool clampAndJitterTime_ = true;
bool isNonLive_ = false;
};

View File

@ -22,35 +22,6 @@ function hasGname(f, v, hasIt = true) {
var x = "outer";
var nonLazyGlobal = newGlobal({ disableLazyParsing: true });
nonLazyGlobal.eval(bytecode.toString());
nonLazyGlobal.eval(hasGname.toString());
nonLazyGlobal.x = x;
nonLazyGlobal.evaluate(`
{
let x = "inner";
eval("function g() { assertEq(x, 'inner');} g()");
eval("function g2() { (function nest() { assertEq(x, 'inner'); })(); } g2()");
}
eval(\`
function g3() {
assertEq(x, 'outer');
}
g3();
hasGname(g3, 'x');
\`);
eval(\`
function g4() {
function nest() { assertEq(x, 'outer'); }
nest();
return nest;
}
hasGname(g4(), 'x');
\`);
`);
{
let x = "inner";
eval("function h() { assertEq(x, 'inner');} h()");
@ -74,28 +45,12 @@ eval(`
hasGname(h4(), 'x', true);
`);
nonLazyGlobal.evaluate(`
with ({}) {
let x = "inner";
eval("function i() { assertEq(x, 'inner');} i()");
eval("function i2() { (function nest() { assertEq(x, 'inner'); })(); } i2()");
}
`);
with ({}) {
let x = "inner";
eval("function j() { assertEq(x, 'inner');} j()");
eval("function j2() { (function nest() { assertEq(x, 'inner'); })(); } j2()");
}
nonLazyGlobal.evaluate(`
(function () {
var x = "inner";
eval("function k() { assertEq(x, 'inner');} k()");
eval("function k2() { (function nest() { assertEq(x, 'inner'); })(); } k2()");
})();
`);
(function () {
let x = "inner";
eval("function l() { assertEq(x, 'inner');} l()");
@ -117,22 +72,3 @@ eval(`
assertEq(y2, 6);
(function() { assertEq(y2, 6); })()
`);
nonLazyGlobal.evaluate(`
var y3 = 5;
eval(\`
'use strict';
var y3 = 6;
assertEq(y3, 6);
(function() { assertEq(y3, 6); })()
\`);
assertEq(y3, 5);
eval(\`
'use strict';
var y4 = 6;
assertEq(y4, 6);
(function() { assertEq(y4, 6); })()
\`);
`);

View File

@ -22,33 +22,13 @@ function hasGname(f, v) {
var x = "outer";
var nonLazyGlobal = newGlobal({ disableLazyParsing: true });
nonLazyGlobal.eval(bytecode.toString());
nonLazyGlobal.eval(hasGname.toString());
nonLazyGlobal.x = x;
var f1 = new Function("assertEq(x, 'outer')");
f1();
hasGname(f1, 'x');
nonLazyGlobal.evaluate(`
var f2 = new Function("assertEq(x, 'outer')");
f2();
hasGname(f2, 'x');
`);
{
let x = "inner";
var f3 = new Function("assertEq(x, 'outer')");
f3();
hasGname(f3, 'x');
}
nonLazyGlobal.evaluate(`
{
let x = "inner";
var f4 = new Function("assertEq(x, 'outer')");
f4();
hasGname(f4, 'x');
}
`);

View File

@ -53,10 +53,10 @@ function checkLcov(fun) {
}
}
// Evaluate the code, and generate the Lcov result from the execution. We have
// to disable lazy parsing, as we rely on the ZoneCellIter to emulate the
// behaviour of the finalizer.
var g = newGlobal({ disableLazyParsing: true });
// Evaluate the code, and generate the Lcov result from the execution.
// Enabling LCov disables lazy parsing, as we rely on the ZoneCellIter to
// emulate the behaviour of the finalizer.
var g = newGlobal();
g.eval(source);
var lcovResRaw = getLcovInfo(g);

View File

@ -5,19 +5,32 @@
// Check byte counts produced by takeCensus.
const g = newGlobal({newCompartment: true, disableLazyParsing: true });
g.eval("setJitCompilerOption('ion.warmup.trigger', 1000)");
const g = newGlobal({newCompartment: true });
g.evaluate("setJitCompilerOption('ion.warmup.trigger', 1000)",
{
forceFullParse: true,
});
const dbg = new Debugger(g);
g.evaluate("function one() {}", { fileName: "one.js" });
g.evaluate("function one() {}",
{
fileName: "one.js",
forceFullParse: true,
});
g.evaluate(`function two1() {}
function two2() {}`,
{ fileName: "two.js" });
{
fileName: "two.js",
forceFullParse: true,
});
g.evaluate(`function three1() {}
function three2() {}
function three3() {}`,
{ fileName: "three.js" });
{
fileName: "three.js",
forceFullParse: true,
});
const report = dbg.memory.takeCensus({
breakdown: {

View File

@ -50,13 +50,15 @@ var myInstance = new MyClass();
test(g.myInstance.method, 10);
test(g.myInstance.constructor, 14);
const gEager = newGlobal({newCompartment: true, useWindowProxy: true, disableLazyParsing: true});
const eagerDbg = Debugger(gEager);
const gEagerWrapped = eagerDbg.addDebuggee(gEager);
gEager.eval(`
const g2 = newGlobal({newCompartment: true, useWindowProxy: true});
const dbg2 = Debugger(g2);
const g2Wrapped = dbg2.addDebuggee(g2);
g2.evaluate(`
function f7() { }
`);
const f7w = gEagerWrapped.makeDebuggeeValue(gEager.f7);
`, {
forceFullParse: true,
});
const f7w = g2Wrapped.makeDebuggeeValue(g2.f7);
assertEq(f7w.callable, true);
assertEq(f7w.script.startColumn, 11);

View File

@ -1,18 +1,18 @@
gczeal(2);
g = newGlobal({newCompartment: true, disableLazyParsing: true});
g = newGlobal({newCompartment: true});
dbg = Debugger(g);
dbg.onNewScript = function() { return function() { return this; } };
schedulegc(10);
g.evaluate("function one() {}");
g.evaluate("function one() {}", { forceFullParse: true });
g.evaluate(`
function target () {}
function two2() {}
`, {});
`, { forceFullParse: true });
g.evaluate(`
function three1() {}
function three2() {}
function three3() {}
`, {});
`, { forceFullParse: true });
dbg.memory.takeCensus({
breakdown: {
by: "coarseType",

View File

@ -3594,8 +3594,7 @@ JS::CompileOptions::CompileOptions(JSContext* cx)
forceStrictMode_ = cx->options().strictMode();
// Certain modes of operation disallow syntax parsing in general.
forceFullParse_ = cx->realm()->behaviors().disableLazyParsing() ||
coverage::IsLCovEnabled();
forceFullParse_ = coverage::IsLCovEnabled();
// If instrumentation is enabled in the realm, the compiler should insert the
// requested kinds of instrumentation into all scripts.

View File

@ -6739,13 +6739,6 @@ static bool NewGlobal(JSContext* cx, unsigned argc, Value* vp) {
creationOptions.setNewCompartmentAndZone();
}
if (!JS_GetProperty(cx, opts, "disableLazyParsing", &v)) {
return false;
}
if (v.isBoolean()) {
behaviors.setDisableLazyParsing(v.toBoolean());
}
if (!JS_GetProperty(cx, opts, "discardSource", &v)) {
return false;
}
@ -9228,8 +9221,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
" compartment and zone.\n"
" invisibleToDebugger: If true, the global will be invisible to the\n"
" debugger (default false)\n"
" disableLazyParsing: If true, don't create lazy scripts for functions\n"
" (default false).\n"
" discardSource: If true, discard source after compiling a script\n"
" (default false).\n"
" useWindowProxy: the global will be created with a WindowProxy attached. In this\n"