Bug 1840996 - Add PrefableCompileOptions and use it in ContextOptions and CompileOptions. r=bthrall
Differential Revision: https://phabricator.services.mozilla.com/D182458
This commit is contained in:
@@ -117,6 +117,93 @@ enum class DelazificationOption : uint8_t {
|
||||
class JS_PUBLIC_API InstantiateOptions;
|
||||
class JS_PUBLIC_API DecodeOptions;
|
||||
|
||||
// Compilation-specific part of JS::ContextOptions which is supposed to be
|
||||
// configured by user prefs.
|
||||
class JS_PUBLIC_API PrefableCompileOptions {
|
||||
public:
|
||||
PrefableCompileOptions()
|
||||
: importAssertions_(false),
|
||||
sourcePragmas_(true),
|
||||
throwOnAsmJSValidationFailure_(false) {}
|
||||
|
||||
bool importAssertions() const { return importAssertions_; }
|
||||
PrefableCompileOptions& setImportAssertions(bool enabled) {
|
||||
importAssertions_ = enabled;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Enable/disable support for parsing '//(#@) source(Mapping)?URL=' pragmas.
|
||||
bool sourcePragmas() const { return sourcePragmas_; }
|
||||
PrefableCompileOptions& setSourcePragmas(bool flag) {
|
||||
sourcePragmas_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
AsmJSOption asmJSOption() const { return asmJSOption_; }
|
||||
PrefableCompileOptions& setAsmJS(bool flag) {
|
||||
asmJSOption_ =
|
||||
flag ? AsmJSOption::Enabled : AsmJSOption::DisabledByAsmJSPref;
|
||||
return *this;
|
||||
}
|
||||
PrefableCompileOptions& setAsmJSOption(AsmJSOption option) {
|
||||
asmJSOption_ = option;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool throwOnAsmJSValidationFailure() const {
|
||||
return throwOnAsmJSValidationFailure_;
|
||||
}
|
||||
PrefableCompileOptions& setThrowOnAsmJSValidationFailure(bool flag) {
|
||||
throwOnAsmJSValidationFailure_ = flag;
|
||||
return *this;
|
||||
}
|
||||
PrefableCompileOptions& toggleThrowOnAsmJSValidationFailure() {
|
||||
throwOnAsmJSValidationFailure_ = !throwOnAsmJSValidationFailure_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(DEBUG) || defined(JS_JITSPEW)
|
||||
template <typename Printer>
|
||||
void dumpWith(Printer& print) const {
|
||||
# define PrintFields_(Name) print(#Name, Name)
|
||||
PrintFields_(importAssertions_);
|
||||
PrintFields_(sourcePragmas_);
|
||||
PrintFields_(throwOnAsmJSValidationFailure_);
|
||||
# undef PrintFields_
|
||||
|
||||
switch (asmJSOption_) {
|
||||
case AsmJSOption::Enabled:
|
||||
print("asmJSOption_", "AsmJSOption::Enabled");
|
||||
break;
|
||||
case AsmJSOption::DisabledByAsmJSPref:
|
||||
print("asmJSOption_", "AsmJSOption::DisabledByAsmJSPref");
|
||||
break;
|
||||
case AsmJSOption::DisabledByLinker:
|
||||
print("asmJSOption_", "AsmJSOption::DisabledByLinker");
|
||||
break;
|
||||
case AsmJSOption::DisabledByNoWasmCompiler:
|
||||
print("asmJSOption_", "AsmJSOption::DisabledByNoWasmCompiler");
|
||||
break;
|
||||
case AsmJSOption::DisabledByDebugger:
|
||||
print("asmJSOption_", "AsmJSOption::DisabledByDebugger");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // defined(DEBUG) || defined(JS_JITSPEW)
|
||||
|
||||
private:
|
||||
// ==== Syntax-related options. ====
|
||||
bool importAssertions_ : 1;
|
||||
|
||||
// The context has specified that source pragmas should be parsed.
|
||||
bool sourcePragmas_ : 1;
|
||||
|
||||
// ==== asm.js options. ====
|
||||
bool throwOnAsmJSValidationFailure_ : 1;
|
||||
|
||||
AsmJSOption asmJSOption_ = AsmJSOption::DisabledByAsmJSPref;
|
||||
};
|
||||
|
||||
/**
|
||||
* The common base class for the CompileOptions hierarchy.
|
||||
*
|
||||
@@ -161,9 +248,6 @@ class JS_PUBLIC_API TransitiveCompileOptions {
|
||||
// The Realm of this script is configured to use fdlibm math library.
|
||||
bool alwaysUseFdlibm_ = false;
|
||||
|
||||
// The context has specified that source pragmas should be parsed.
|
||||
bool sourcePragmas_ = true;
|
||||
|
||||
// Flag used to bypass the filename validation callback.
|
||||
// See also SetFilenameValidationCallback.
|
||||
bool skipFilenameValidation_ = false;
|
||||
@@ -187,8 +271,6 @@ class JS_PUBLIC_API TransitiveCompileOptions {
|
||||
|
||||
public:
|
||||
bool selfHostingMode = false;
|
||||
AsmJSOption asmJSOption = AsmJSOption::DisabledByAsmJSPref;
|
||||
bool throwOnAsmJSValidationFailureOption = false;
|
||||
bool forceAsync = false;
|
||||
bool discardSource = false;
|
||||
bool sourceIsLazy = false;
|
||||
@@ -199,8 +281,6 @@ class JS_PUBLIC_API TransitiveCompileOptions {
|
||||
// modules loaded with ChromeUtils.importModule.
|
||||
bool topLevelAwait = true;
|
||||
|
||||
bool importAssertions = false;
|
||||
|
||||
// When decoding from XDR into a Stencil, directly reference data in the
|
||||
// buffer (where possible) instead of copying it. This is an optional
|
||||
// performance optimization, and may also reduce memory if the buffer is going
|
||||
@@ -240,6 +320,8 @@ class JS_PUBLIC_API TransitiveCompileOptions {
|
||||
// WARNING: This option will eventually be removed.
|
||||
bool deoptimizeModuleGlobalVars = false;
|
||||
|
||||
PrefableCompileOptions prefableOptions_;
|
||||
|
||||
/**
|
||||
* |introductionType| is a statically allocated C string. See JSScript.h
|
||||
* for more information.
|
||||
@@ -301,7 +383,17 @@ class JS_PUBLIC_API TransitiveCompileOptions {
|
||||
DelazificationOption eagerDelazificationStrategy() const {
|
||||
return eagerDelazificationStrategy_;
|
||||
}
|
||||
bool sourcePragmas() const { return sourcePragmas_; }
|
||||
|
||||
bool importAssertions() const { return prefableOptions_.importAssertions(); }
|
||||
bool sourcePragmas() const { return prefableOptions_.sourcePragmas(); }
|
||||
bool throwOnAsmJSValidationFailure() const {
|
||||
return prefableOptions_.throwOnAsmJSValidationFailure();
|
||||
}
|
||||
AsmJSOption asmJSOption() const { return prefableOptions_.asmJSOption(); }
|
||||
void setAsmJSOption(AsmJSOption option) {
|
||||
prefableOptions_.setAsmJSOption(option);
|
||||
}
|
||||
|
||||
JS::ConstUTF8CharsZ filename() const { return filename_; }
|
||||
JS::ConstUTF8CharsZ introducerFilename() const { return introducerFilename_; }
|
||||
const char16_t* sourceMapURL() const { return sourceMapURL_; }
|
||||
@@ -319,21 +411,17 @@ class JS_PUBLIC_API TransitiveCompileOptions {
|
||||
PrintFields_(mutedErrors_);
|
||||
PrintFields_(forceStrictMode_);
|
||||
PrintFields_(alwaysUseFdlibm_);
|
||||
PrintFields_(sourcePragmas_);
|
||||
PrintFields_(skipFilenameValidation_);
|
||||
PrintFields_(hideScriptFromDebugger_);
|
||||
PrintFields_(deferDebugMetadata_);
|
||||
PrintFields_(eagerDelazificationStrategy_);
|
||||
PrintFields_(selfHostingMode);
|
||||
PrintFields_(asmJSOption);
|
||||
PrintFields_(throwOnAsmJSValidationFailureOption);
|
||||
PrintFields_(forceAsync);
|
||||
PrintFields_(discardSource);
|
||||
PrintFields_(sourceIsLazy);
|
||||
PrintFields_(allowHTMLComments);
|
||||
PrintFields_(nonSyntacticScope);
|
||||
PrintFields_(topLevelAwait);
|
||||
PrintFields_(importAssertions);
|
||||
PrintFields_(borrowBuffer);
|
||||
PrintFields_(usePinnedBytecode);
|
||||
PrintFields_(allocateInstantiationStorage);
|
||||
@@ -343,6 +431,8 @@ class JS_PUBLIC_API TransitiveCompileOptions {
|
||||
PrintFields_(introductionOffset);
|
||||
PrintFields_(hasIntroductionInfo);
|
||||
# undef PrintFields_
|
||||
|
||||
prefableOptions_.dumpWith(print);
|
||||
}
|
||||
#endif // defined(DEBUG) || defined(JS_JITSPEW)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user