Bug 1575055 - Unify JS::CompileOptions::canLazilyParse and forceFullParse_. r=jandem

If either the Realm or the request needs full-parsing, we disable lazy
parsing.

Differential Revision: https://phabricator.services.mozilla.com/D42560

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ted Campbell 2019-08-22 13:07:57 +00:00
Родитель 3cab8e70c6
Коммит 179e9bf7ab
7 изменённых файлов: 15 добавлений и 15 удалений

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

@ -114,7 +114,6 @@ class JS_PUBLIC_API TransitiveCompileOptions {
public: public:
// POD options. // POD options.
bool selfHostingMode = false; bool selfHostingMode = false;
bool canLazilyParse = true;
bool extraWarningsOption = false; bool extraWarningsOption = false;
bool werrorOption = false; bool werrorOption = false;
AsmJSOption asmJSOption = AsmJSOption::Disabled; AsmJSOption asmJSOption = AsmJSOption::Disabled;
@ -408,11 +407,6 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
return *this; return *this;
} }
CompileOptions& setCanLazilyParse(bool clp) {
canLazilyParse = clp;
return *this;
}
CompileOptions& setSourceIsLazy(bool l) { CompileOptions& setSourceIsLazy(bool l) {
sourceIsLazy = l; sourceIsLazy = l;
return *this; return *this;
@ -447,6 +441,11 @@ class MOZ_STACK_CLASS JS_PUBLIC_API CompileOptions final
CompileOptions& setIntroductionInfoToCaller(JSContext* cx, CompileOptions& setIntroductionInfoToCaller(JSContext* cx,
const char* introductionType); const char* introductionType);
CompileOptions& setForceFullParse() {
forceFullParse_ = true;
return *this;
}
CompileOptions& setForceStrictMode() { CompileOptions& setForceStrictMode() {
forceStrictMode_ = true; forceStrictMode_ = true;
return *this; return *this;

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

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

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

@ -402,8 +402,8 @@ bool BytecodeCompiler::createScriptSource(
} }
bool BytecodeCompiler::canLazilyParse() const { bool BytecodeCompiler::canLazilyParse() const {
return options.canLazilyParse && !options.discardSource && return !options.discardSource && !options.sourceIsLazy &&
!options.sourceIsLazy && !options.forceFullParse(); !options.forceFullParse();
} }
template <typename Unit> template <typename Unit>

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

@ -3527,7 +3527,6 @@ void JS::TransitiveCompileOptions::copyPODTransitiveOptions(
forceFullParse_ = rhs.forceFullParse_; forceFullParse_ = rhs.forceFullParse_;
forceStrictMode_ = rhs.forceStrictMode_; forceStrictMode_ = rhs.forceStrictMode_;
selfHostingMode = rhs.selfHostingMode; selfHostingMode = rhs.selfHostingMode;
canLazilyParse = rhs.canLazilyParse;
extraWarningsOption = rhs.extraWarningsOption; extraWarningsOption = rhs.extraWarningsOption;
werrorOption = rhs.werrorOption; werrorOption = rhs.werrorOption;
asmJSOption = rhs.asmJSOption; asmJSOption = rhs.asmJSOption;

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

@ -942,7 +942,7 @@ static bool InitModuleLoader(JSContext* cx) {
options.setIntroductionType("shell module loader"); options.setIntroductionType("shell module loader");
options.setFileAndLine("shell/ModuleLoader.js", 1); options.setFileAndLine("shell/ModuleLoader.js", 1);
options.setSelfHostingMode(false); options.setSelfHostingMode(false);
options.setCanLazilyParse(false); options.setForceFullParse();
options.werrorOption = true; options.werrorOption = true;
options.setForceStrictMode(); options.setForceStrictMode();

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

@ -2626,7 +2626,7 @@ void js::FillSelfHostingCompileOptions(CompileOptions& options) {
options.setIntroductionType("self-hosted"); options.setIntroductionType("self-hosted");
options.setFileAndLine("self-hosted", 1); options.setFileAndLine("self-hosted", 1);
options.setSelfHostingMode(true); options.setSelfHostingMode(true);
options.setCanLazilyParse(false); options.setForceFullParse();
options.werrorOption = true; options.werrorOption = true;
options.extraWarningsOption = true; options.extraWarningsOption = true;
options.setForceStrictMode(); options.setForceStrictMode();

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

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