ported from UXP: Issue #1442 - Part 2: Add a run-time preference for toggling the streams API. https://bugzilla.mozilla.org/show_bug.cgi?id=1272697 (62467428)

This commit is contained in:
2023-10-04 10:46:58 +08:00
parent 783206e5c7
commit b80db24030
5 changed files with 26 additions and 3 deletions
+1
View File
@@ -301,6 +301,7 @@ LoadContextOptions(const char* aPrefName, void* /* aClosure */)
.setNativeRegExp(GetWorkerPref<bool>(NS_LITERAL_CSTRING("native_regexp")))
.setAsyncStack(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asyncstack")))
.setWerror(GetWorkerPref<bool>(NS_LITERAL_CSTRING("werror")))
.setStreams(GetWorkerPref<bool>(NS_LITERAL_CSTRING("streams")))
.setExtraWarnings(GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict")))
.setArrayProtoValues(GetWorkerPref<bool>(
NS_LITERAL_CSTRING("array_prototype_values")));
+11
View File
@@ -1184,6 +1184,16 @@ class JS_PUBLIC_API(ContextOptions) {
return *this;
}
bool streams() const { return streams_; }
ContextOptions& setStreams(bool flag) {
streams_ = flag;
return *this;
}
ContextOptions& toggleStreams() {
streams_ = !streams_;
return *this;
}
bool nativeRegExp() const { return nativeRegExp_; }
ContextOptions& setNativeRegExp(bool flag) {
nativeRegExp_ = flag;
@@ -1273,6 +1283,7 @@ class JS_PUBLIC_API(ContextOptions) {
bool strictMode_ : 1;
bool extraWarnings_ : 1;
bool arrayProtoValues_ : 1;
bool streams_ : 1;
bool forEachStatement_: 1;
};
+7 -2
View File
@@ -319,6 +319,7 @@ static bool enableUnboxedArrays = false;
static bool enableSharedMemory = SHARED_MEMORY_DEFAULT;
static bool enableWasmAlwaysBaseline = false;
static bool enableArrayProtoValues = true;
static bool enableStreams = false;
static bool printTiming = false;
static const char* jsCacheDir = nullptr;
static const char* jsCacheAsmJSPath = nullptr;
@@ -7592,6 +7593,7 @@ SetContextOptions(JSContext* cx, const OptionParser& op)
enableUnboxedArrays = op.getBoolOption("unboxed-arrays");
enableWasmAlwaysBaseline = op.getBoolOption("wasm-always-baseline");
enableArrayProtoValues = !op.getBoolOption("no-array-proto-values");
enableStreams = op.getBoolOption("enable-streams");
JS::ContextOptionsRef(cx).setBaseline(enableBaseline)
.setIon(enableIon)
@@ -7601,7 +7603,8 @@ SetContextOptions(JSContext* cx, const OptionParser& op)
.setWasmAllowDebugging(true)
.setNativeRegExp(enableNativeRegExp)
.setUnboxedArrays(enableUnboxedArrays)
.setArrayProtoValues(enableArrayProtoValues);
.setArrayProtoValues(enableArrayProtoValues)
.setStreams(enableStreams);
if (op.getBoolOption("wasm-check-bce"))
jit::JitOptions.wasmAlwaysCheckBounds = true;
@@ -7874,7 +7877,8 @@ SetWorkerContextOptions(JSContext* cx)
.setWasmAllowDebugging(true)
.setNativeRegExp(enableNativeRegExp)
.setUnboxedArrays(enableUnboxedArrays)
.setArrayProtoValues(enableArrayProtoValues);
.setArrayProtoValues(enableArrayProtoValues)
.setStreams(enableStreams);
cx->setOffthreadIonCompilationEnabled(offthreadCompilation);
cx->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
@@ -8048,6 +8052,7 @@ main(int argc, char** argv, char** envp)
|| !op.addBoolOption('\0', "wasm-always-baseline", "Enable wasm baseline compiler when possible")
|| !op.addBoolOption('\0', "wasm-check-bce", "Always generate wasm bounds check, even redundant ones.")
|| !op.addBoolOption('\0', "no-array-proto-values", "Remove Array.prototype.values")
|| !op.addBoolOption('\0', "enable-streams", "Enable WHATWG Streams")
#ifdef ENABLE_SHARED_ARRAY_BUFFER
|| !op.addStringOption('\0', "shared-memory", "on/off",
"SharedArrayBuffer and Atomics "
+4 -1
View File
@@ -1507,6 +1507,8 @@ ReloadPrefsCallback(const char* pref, void* data)
bool extraWarnings = Preferences::GetBool(JS_OPTIONS_DOT_STR "strict");
bool streams = Preferences::GetBool(JS_OPTIONS_DOT_STR "streams");
bool inlining = Preferences::GetBool(JS_OPTIONS_DOT_STR "ion.inlining");
sSharedMemoryEnabled = Preferences::GetBool(JS_OPTIONS_DOT_STR "shared_memory");
@@ -1529,7 +1531,8 @@ ReloadPrefsCallback(const char* pref, void* data)
.setDumpStackOnDebuggeeWouldRun(dumpStackOnDebuggeeWouldRun)
.setWerror(werror)
.setExtraWarnings(extraWarnings)
.setArrayProtoValues(arrayProtoValues);
.setArrayProtoValues(arrayProtoValues)
.setStreams(streams);
JS_SetParallelParsingEnabled(cx, parallelParsing);
JS_SetOffthreadIonCompilationEnabled(cx, offthreadIonCompilation);
+3
View File
@@ -1401,6 +1401,9 @@ pref("javascript.options.main_thread_stack_quota_cap", 2097152);
// Dynamic module import.
pref("javascript.options.dynamicImport", true);
// Streams API
pref("javascript.options.streams", false);
// advanced prefs
pref("advanced.mailftp", false);
pref("image.animation_mode", "normal");