Backed out 5 changesets (bug 1575055) for causing build bustages in mozJSComponentLoader.cpp CLOSED TREE

Backed out changeset e29819477913 (bug 1575055)
Backed out changeset f770e1398276 (bug 1575055)
Backed out changeset 3ee4fd0e20e0 (bug 1575055)
Backed out changeset 51f0929a5c8d (bug 1575055)
Backed out changeset 45f0e989e56e (bug 1575055)
This commit is contained in:
Noemi Erli 2019-08-22 15:15:16 +03:00
Родитель 64ba0d5e30
Коммит 1353cb7336
12 изменённых файлов: 83 добавлений и 80 удалений

Просмотреть файл

@ -103,10 +103,6 @@ class JS_PUBLIC_API TransitiveCompileOptions {
// conditions are checked in the CompileOptions constructor.
bool forceFullParse_ = false;
// Either the Realm configuration or the compile request may force
// strict-mode.
bool forceStrictMode_ = false;
const char* filename_ = nullptr;
const char* introducerFilename_ = nullptr;
const char16_t* sourceMapURL_ = nullptr;
@ -114,6 +110,8 @@ class JS_PUBLIC_API TransitiveCompileOptions {
public:
// POD options.
bool selfHostingMode = false;
bool canLazilyParse = true;
bool strictOption = false;
bool extraWarningsOption = false;
bool werrorOption = false;
AsmJSOption asmJSOption = AsmJSOption::Disabled;
@ -133,6 +131,7 @@ class JS_PUBLIC_API TransitiveCompileOptions {
unsigned introductionLineno = 0;
uint32_t introductionOffset = 0;
bool hasIntroductionInfo = false;
// Mask of operation kinds which should be instrumented.
uint32_t instrumentationKinds = 0;
@ -145,13 +144,10 @@ class JS_PUBLIC_API TransitiveCompileOptions {
void copyPODTransitiveOptions(const TransitiveCompileOptions& rhs);
public:
bool hasIntroductionInfo() const { return introducerFilename_ != nullptr; }
// Read-only accessors for non-POD options. The proper way to set these
// depends on the derived type.
bool mutedErrors() const { return mutedErrors_; }
bool forceFullParse() const { return forceFullParse_; }
bool forceStrictMode() const { return forceStrictMode_; }
const char* filename() const { return filename_; }
const char* introducerFilename() const { return introducerFilename_; }
const char16_t* sourceMapURL() const { return sourceMapURL_; }
@ -214,16 +210,20 @@ class JS_PUBLIC_API ReadOnlyCompileOptions : public TransitiveCompileOptions {
ReadOnlyCompileOptions() = default;
// Set all POD options (those not requiring reference counts, copies,
// rooting, or other hand-holding) not set by copyPODTransitiveOptions to
// their values in |rhs|.
void copyPODNonTransitiveOptions(const ReadOnlyCompileOptions& rhs);
// rooting, or other hand-holding) to their values in |rhs|.
void copyPODOptions(const ReadOnlyCompileOptions& rhs);
public:
// Read-only accessors for non-POD options. The proper way to set these
// depends on the derived type.
bool mutedErrors() const { return mutedErrors_; }
const char* filename() const { return filename_; }
const char* introducerFilename() const { return introducerFilename_; }
const char16_t* sourceMapURL() const { return sourceMapURL_; }
JSObject* element() const override = 0;
JSString* elementAttributeName() const override = 0;
JSScript* introductionScript() const override = 0;
JSScript* scriptOrModule() const override = 0;
private:
void operator=(const ReadOnlyCompileOptions&) = delete;
@ -289,10 +289,25 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
Rooted<JSScript*> scriptOrModuleRoot;
public:
// Default options determined using the JSContext.
explicit CompileOptions(JSContext* cx);
// Copy the transitive options from another options object.
CompileOptions(JSContext* cx, const ReadOnlyCompileOptions& rhs)
: ReadOnlyCompileOptions(),
elementRoot(cx),
elementAttributeNameRoot(cx),
introductionScriptRoot(cx),
scriptOrModuleRoot(cx) {
copyPODOptions(rhs);
filename_ = rhs.filename();
introducerFilename_ = rhs.introducerFilename();
sourceMapURL_ = rhs.sourceMapURL();
elementRoot = rhs.element();
elementAttributeNameRoot = rhs.elementAttributeName();
introductionScriptRoot = rhs.introductionScript();
scriptOrModuleRoot = rhs.scriptOrModule();
}
CompileOptions(JSContext* cx, const TransitiveCompileOptions& rhs)
: ReadOnlyCompileOptions(),
elementRoot(cx),
@ -310,13 +325,6 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
scriptOrModuleRoot = rhs.scriptOrModule();
}
// Copy both the transitive and the non-transitive options from another
// options object.
CompileOptions(JSContext* cx, const ReadOnlyCompileOptions& rhs)
: CompileOptions(cx, static_cast<const TransitiveCompileOptions&>(rhs)) {
copyPODNonTransitiveOptions(rhs);
}
JSObject* element() const override { return elementRoot; }
JSString* elementAttributeName() const override {
@ -360,6 +368,11 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
return *this;
}
CompileOptions& setIntroductionScript(JSScript* s) {
introductionScriptRoot = s;
return *this;
}
CompileOptions& setScriptOrModule(JSScript* s) {
scriptOrModuleRoot = s;
return *this;
@ -395,6 +408,11 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
return *this;
}
CompileOptions& setCanLazilyParse(bool clp) {
canLazilyParse = clp;
return *this;
}
CompileOptions& setSourceIsLazy(bool l) {
sourceIsLazy = l;
return *this;
@ -406,7 +424,6 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
}
CompileOptions& setIntroductionType(const char* t) {
MOZ_ASSERT(t);
introductionType = t;
return *this;
}
@ -414,14 +431,12 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
CompileOptions& setIntroductionInfo(const char* introducerFn,
const char* intro, unsigned line,
JSScript* script, uint32_t offset) {
setIntroductionType(intro);
MOZ_ASSERT(introducerFn);
introducerFilename_ = introducerFn;
introductionType = intro;
introductionLineno = line;
introductionScriptRoot = script;
introductionOffset = offset;
hasIntroductionInfo = true;
return *this;
}
@ -429,13 +444,8 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
CompileOptions& setIntroductionInfoToCaller(JSContext* cx,
const char* introductionType);
CompileOptions& setForceFullParse() {
forceFullParse_ = true;
return *this;
}
CompileOptions& setForceStrictMode() {
forceStrictMode_ = true;
CompileOptions& maybeMakeStrictMode(bool strict) {
strictOption = strictOption || strict;
return *this;
}

Просмотреть файл

@ -294,12 +294,9 @@ static bool EvalKernel(JSContext* cx, HandleValue v, EvalType evalType,
options.setIsRunOnce(true)
.setNoScriptRval(false)
.setMutedErrors(mutedErrors)
.maybeMakeStrictMode(evalType == DIRECT_EVAL && IsStrictEvalPC(pc))
.setScriptOrModule(maybeScript);
if (evalType == DIRECT_EVAL && IsStrictEvalPC(pc)) {
options.setForceStrictMode();
}
if (introducerFilename) {
options.setFileAndLine(filename, 1);
options.setIntroductionInfo(introducerFilename, "eval", lineno,
@ -384,12 +381,10 @@ bool js::DirectEvalStringFromIon(JSContext* cx, HandleObject env,
RootedScope enclosing(cx, callerScript->innermostScope(pc));
CompileOptions options(cx);
options.setIsRunOnce(true).setNoScriptRval(false).setMutedErrors(
mutedErrors);
if (IsStrictEvalPC(pc)) {
options.setForceStrictMode();
}
options.setIsRunOnce(true)
.setNoScriptRval(false)
.setMutedErrors(mutedErrors)
.maybeMakeStrictMode(IsStrictEvalPC(pc));
if (introducerFilename) {
options.setFileAndLine(filename, 1);

Просмотреть файл

@ -3631,7 +3631,7 @@ static bool reflect_parse(JSContext* cx, uint32_t argc, Value* vp) {
CompileOptions options(cx);
options.setFileAndLine(filename.get(), lineno);
options.setForceFullParse();
options.setCanLazilyParse(false);
options.allowHTMLComments = target == ParseGoal::Script;
mozilla::Range<const char16_t> chars = linearChars.twoByteRange();
UsedNameTracker usedNames(cx);

Просмотреть файл

@ -789,11 +789,9 @@ static bool EvaluateInEnv(JSContext* cx, Handle<Env*> env,
options.setIsRunOnce(true)
.setNoScriptRval(false)
.setFileAndLine(filename, lineno)
.setIntroductionType("debugger eval");
if (frame && frame.hasScript() && frame.script()->strict()) {
options.setForceStrictMode();
}
.setIntroductionType("debugger eval")
.maybeMakeStrictMode(frame && frame.hasScript() ? frame.script()->strict()
: false);
SourceText<char16_t> srcBuf;
if (!srcBuf.init(cx, chars.begin().get(), chars.length(),

Просмотреть файл

@ -387,7 +387,7 @@ BytecodeCompiler::BytecodeCompiler(JSContext* cx,
cx(cx),
options(options),
sourceObject(cx),
directives(options.forceStrictMode()),
directives(options.strictOption),
script(cx) {}
bool BytecodeCompiler::createScriptSource(
@ -402,8 +402,8 @@ bool BytecodeCompiler::createScriptSource(
}
bool BytecodeCompiler::canLazilyParse() const {
return !options.discardSource && !options.sourceIsLazy &&
!options.forceFullParse();
return options.canLazilyParse && !options.discardSource &&
!options.sourceIsLazy && !options.forceFullParse();
}
template <typename Unit>
@ -745,7 +745,7 @@ JSScript* frontend::CompileGlobalBinASTScript(
return nullptr;
}
Directives directives(options.forceStrictMode());
Directives directives(options.strictOption);
GlobalSharedContext globalsc(cx, ScopeKind::Global, directives,
options.extraWarningsOption);
@ -796,8 +796,8 @@ static ModuleObject* InternalParseModule(
AutoAssertReportedException assertException(cx);
CompileOptions options(cx, optionsInput);
options.setForceStrictMode(); // ES6 10.2.1 Module code is always strict mode
// code.
options.maybeMakeStrictMode(
true); // ES6 10.2.1 Module code is always strict mode code.
options.setIsRunOnce(true);
options.allowHTMLComments = false;

Просмотреть файл

@ -429,7 +429,7 @@ template <class ParseHandler, typename Unit>
typename ParseHandler::ListNodeType GeneralParser<ParseHandler, Unit>::parse() {
MOZ_ASSERT(checkOptionsCalled_);
Directives directives(options().forceStrictMode());
Directives directives(options().strictOption);
GlobalSharedContext globalsc(cx_, ScopeKind::Global, directives,
options().extraWarningsOption);
SourceParseContext globalpc(this, &globalsc, /* newDirectives = */ nullptr);

Просмотреть файл

@ -3525,8 +3525,9 @@ void JS::TransitiveCompileOptions::copyPODTransitiveOptions(
const TransitiveCompileOptions& rhs) {
mutedErrors_ = rhs.mutedErrors_;
forceFullParse_ = rhs.forceFullParse_;
forceStrictMode_ = rhs.forceStrictMode_;
selfHostingMode = rhs.selfHostingMode;
canLazilyParse = rhs.canLazilyParse;
strictOption = rhs.strictOption;
extraWarningsOption = rhs.extraWarningsOption;
werrorOption = rhs.werrorOption;
asmJSOption = rhs.asmJSOption;
@ -3537,12 +3538,14 @@ void JS::TransitiveCompileOptions::copyPODTransitiveOptions(
introductionType = rhs.introductionType;
introductionLineno = rhs.introductionLineno;
introductionOffset = rhs.introductionOffset;
hasIntroductionInfo = rhs.hasIntroductionInfo;
hideScriptFromDebugger = rhs.hideScriptFromDebugger;
fieldsEnabledOption = rhs.fieldsEnabledOption;
}
};
void JS::ReadOnlyCompileOptions::copyPODNonTransitiveOptions(
void JS::ReadOnlyCompileOptions::copyPODOptions(
const ReadOnlyCompileOptions& rhs) {
copyPODTransitiveOptions(rhs);
lineno = rhs.lineno;
column = rhs.column;
scriptSourceOffset = rhs.scriptSourceOffset;
@ -3582,8 +3585,7 @@ bool JS::OwningCompileOptions::copy(JSContext* cx,
// Release existing string allocations.
release();
copyPODTransitiveOptions(rhs);
copyPODNonTransitiveOptions(rhs);
copyPODOptions(rhs);
elementRoot = rhs.element();
elementAttributeNameRoot = rhs.elementAttributeName();
@ -3621,6 +3623,7 @@ JS::CompileOptions::CompileOptions(JSContext* cx)
elementAttributeNameRoot(cx),
introductionScriptRoot(cx),
scriptOrModuleRoot(cx) {
strictOption = cx->options().strictMode();
extraWarningsOption = cx->realm()->behaviors().extraWarnings(cx);
discardSource = cx->realm()->behaviors().discardSource();
werrorOption = cx->options().werror();
@ -3635,9 +3638,6 @@ JS::CompileOptions::CompileOptions(JSContext* cx)
cx->options().throwOnAsmJSValidationFailure();
fieldsEnabledOption = cx->realm()->creationOptions().getFieldsEnabled();
// Certain modes of operation force strict-mode in general.
forceStrictMode_ = cx->options().strictMode();
// Certain modes of operation disallow syntax parsing in general.
forceFullParse_ = cx->realm()->behaviors().disableLazyParsing() ||
coverage::IsLCovEnabled();

Просмотреть файл

@ -942,9 +942,9 @@ static bool InitModuleLoader(JSContext* cx) {
options.setIntroductionType("shell module loader");
options.setFileAndLine("shell/ModuleLoader.js", 1);
options.setSelfHostingMode(false);
options.setForceFullParse();
options.setCanLazilyParse(false);
options.werrorOption = true;
options.setForceStrictMode();
options.strictOption = true;
JS::SourceText<Utf8Unit> srcBuf;
if (!srcBuf.init(cx, std::move(src), srcLen)) {
@ -5219,7 +5219,7 @@ static bool Parse(JSContext* cx, unsigned argc, Value* vp) {
options.setIntroductionType("js shell parse").setFileAndLine("<string>", 1);
if (goal == frontend::ParseGoal::Module) {
// See frontend::CompileModule.
options.setForceStrictMode();
options.maybeMakeStrictMode(true);
options.allowHTMLComments = false;
}

Просмотреть файл

@ -3437,7 +3437,8 @@ bool ScriptSource::initFromOptions(JSContext* cx,
setIntroductionOffset(options.introductionOffset);
parameterListEnd_ = parameterListEnd.isSome() ? parameterListEnd.value() : 0;
if (options.hasIntroductionInfo()) {
if (options.hasIntroductionInfo) {
MOZ_ASSERT(options.introductionType != nullptr);
const char* filename =
options.filename() ? options.filename() : "<unknown>";
char* formatted = FormatIntroducedFilename(
@ -3446,18 +3447,19 @@ bool ScriptSource::initFromOptions(JSContext* cx,
return false;
}
filename_.reset(formatted);
MOZ_ASSERT(options.introducerFilename());
introducerFilename_ = DuplicateString(cx, options.introducerFilename());
if (!introducerFilename_) {
return false;
}
} else if (options.filename()) {
if (!setFilename(cx, options.filename())) {
return false;
}
}
if (options.introducerFilename()) {
introducerFilename_ = DuplicateString(cx, options.introducerFilename());
if (!introducerFilename_) {
return false;
}
}
return true;
}

Просмотреть файл

@ -2626,10 +2626,10 @@ void js::FillSelfHostingCompileOptions(CompileOptions& options) {
options.setIntroductionType("self-hosted");
options.setFileAndLine("self-hosted", 1);
options.setSelfHostingMode(true);
options.setForceFullParse();
options.setCanLazilyParse(false);
options.werrorOption = true;
options.strictOption = true;
options.extraWarningsOption = true;
options.setForceStrictMode();
}
GlobalObject* JSRuntime::createSelfHostingGlobal(JSContext* cx) {

Просмотреть файл

@ -6936,7 +6936,7 @@ static bool HandleInstantiationFailure(JSContext* cx, CallArgs args,
// The exported function inherits an implicit strict context if the module
// also inherited it somehow.
if (metadata.strict) {
options.setForceStrictMode();
options.strictOption = true;
}
AutoStableStringChars stableChars(cx);

Просмотреть файл

@ -92,11 +92,9 @@ nsresult AsyncScriptCompiler::Start(
mCharset = aOptions.mCharset;
CompileOptions options(aCx);
options.setFile(mURL.get()).setNoScriptRval(!aOptions.mHasReturnValue);
if (!aOptions.mLazilyParse) {
options.setForceFullParse();
}
options.setFile(mURL.get())
.setNoScriptRval(!aOptions.mHasReturnValue)
.setCanLazilyParse(aOptions.mLazilyParse);
if (NS_WARN_IF(!mOptions.copy(aCx, options))) {
return NS_ERROR_OUT_OF_MEMORY;