зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1284808 - Rename RuntimeOptions to ContextOptions and move it to the context. r=luke,baku
--HG-- extra : rebase_source : acd82642a27b36b98bf1bf34c29d33c7e0b57dea
This commit is contained in:
Родитель
587bf3d8eb
Коммит
a53a99aab6
|
@ -58,7 +58,7 @@ public:
|
|||
explicit CallbackObject(JSContext* aCx, JS::Handle<JSObject*> aCallback,
|
||||
nsIGlobalObject* aIncumbentGlobal)
|
||||
{
|
||||
if (aCx && JS::RuntimeOptionsRef(aCx).asyncStack()) {
|
||||
if (aCx && JS::ContextOptionsRef(aCx).asyncStack()) {
|
||||
JS::RootedObject stack(aCx);
|
||||
if (!JS::CaptureCurrentStack(aCx, &stack)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
|
@ -230,7 +230,7 @@ protected:
|
|||
nsIGlobalObject* aIncumbentGlobal,
|
||||
const FastCallbackConstructor&)
|
||||
{
|
||||
if (aCx && JS::RuntimeOptionsRef(aCx).asyncStack()) {
|
||||
if (aCx && JS::ContextOptionsRef(aCx).asyncStack()) {
|
||||
JS::RootedObject stack(aCx);
|
||||
if (!JS::CaptureCurrentStack(aCx, &stack)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
|
|
|
@ -261,7 +261,7 @@ GenerateSharedWorkerKey(const nsACString& aScriptSpec, const nsACString& aName,
|
|||
}
|
||||
|
||||
void
|
||||
LoadRuntimeOptions(const char* aPrefName, void* /* aClosure */)
|
||||
LoadContextOptions(const char* aPrefName, void* /* aClosure */)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
|
@ -291,9 +291,9 @@ LoadRuntimeOptions(const char* aPrefName, void* /* aClosure */)
|
|||
}
|
||||
#endif
|
||||
|
||||
// Runtime options.
|
||||
JS::RuntimeOptions runtimeOptions;
|
||||
runtimeOptions.setAsmJS(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs")))
|
||||
// Context options.
|
||||
JS::ContextOptions contextOptions;
|
||||
contextOptions.setAsmJS(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs")))
|
||||
.setWasm(GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm")))
|
||||
.setThrowOnAsmJSValidationFailure(GetWorkerPref<bool>(
|
||||
NS_LITERAL_CSTRING("throw_on_asmjs_validation_failure")))
|
||||
|
@ -304,10 +304,10 @@ LoadRuntimeOptions(const char* aPrefName, void* /* aClosure */)
|
|||
.setWerror(GetWorkerPref<bool>(NS_LITERAL_CSTRING("werror")))
|
||||
.setExtraWarnings(GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict")));
|
||||
|
||||
RuntimeService::SetDefaultRuntimeOptions(runtimeOptions);
|
||||
RuntimeService::SetDefaultContextOptions(contextOptions);
|
||||
|
||||
if (rts) {
|
||||
rts->UpdateAllWorkerRuntimeOptions();
|
||||
rts->UpdateAllWorkerContextOptions();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,7 +758,7 @@ InitJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
|
|||
|
||||
JSContext* workerCx = JS_GetContext(aRuntime);
|
||||
|
||||
JS::RuntimeOptionsRef(aRuntime) = settings.runtimeOptions;
|
||||
JS::ContextOptionsRef(workerCx) = settings.contextOptions;
|
||||
|
||||
JSSettings::JSGCSettingsArray& gcSettings = settings.gcSettings;
|
||||
|
||||
|
@ -1711,7 +1711,7 @@ RuntimeService::Init()
|
|||
|
||||
// Initialize JSSettings.
|
||||
if (!sDefaultJSSettings.gcSettings[0].IsSet()) {
|
||||
sDefaultJSSettings.runtimeOptions = JS::RuntimeOptions();
|
||||
sDefaultJSSettings.contextOptions = JS::ContextOptions();
|
||||
sDefaultJSSettings.chrome.maxScriptRuntime = -1;
|
||||
sDefaultJSSettings.chrome.compartmentOptions.behaviors().setVersion(JSVERSION_LATEST);
|
||||
sDefaultJSSettings.content.maxScriptRuntime = MAX_SCRIPT_RUN_TIME_SEC;
|
||||
|
@ -1789,10 +1789,10 @@ RuntimeService::Init()
|
|||
#undef WORKER_PREF
|
||||
|
||||
NS_FAILED(Preferences::RegisterCallbackAndCall(
|
||||
LoadRuntimeOptions,
|
||||
LoadContextOptions,
|
||||
PREF_WORKERS_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::RegisterCallback(LoadRuntimeOptions,
|
||||
NS_FAILED(Preferences::RegisterCallback(LoadContextOptions,
|
||||
PREF_JS_OPTIONS_PREFIX,
|
||||
nullptr))) {
|
||||
NS_WARNING("Failed to register pref callbacks!");
|
||||
|
@ -1931,10 +1931,10 @@ RuntimeService::Cleanup()
|
|||
NS_ASSERTION(!mWindowMap.Count(), "All windows should have been released!");
|
||||
|
||||
if (mObserved) {
|
||||
if (NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeOptions,
|
||||
if (NS_FAILED(Preferences::UnregisterCallback(LoadContextOptions,
|
||||
PREF_JS_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeOptions,
|
||||
NS_FAILED(Preferences::UnregisterCallback(LoadContextOptions,
|
||||
PREF_WORKERS_OPTIONS_PREFIX,
|
||||
nullptr)) ||
|
||||
|
||||
|
@ -2287,9 +2287,9 @@ RuntimeService::NoteIdleThread(WorkerThread* aThread)
|
|||
}
|
||||
|
||||
void
|
||||
RuntimeService::UpdateAllWorkerRuntimeOptions()
|
||||
RuntimeService::UpdateAllWorkerContextOptions()
|
||||
{
|
||||
BROADCAST_ALL_WORKERS(UpdateRuntimeOptions, sDefaultJSSettings.runtimeOptions);
|
||||
BROADCAST_ALL_WORKERS(UpdateContextOptions, sDefaultJSSettings.contextOptions);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -168,10 +168,10 @@ public:
|
|||
}
|
||||
|
||||
static void
|
||||
SetDefaultRuntimeOptions(const JS::RuntimeOptions& aRuntimeOptions)
|
||||
SetDefaultContextOptions(const JS::ContextOptions& aContextOptions)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
sDefaultJSSettings.runtimeOptions = aRuntimeOptions;
|
||||
sDefaultJSSettings.contextOptions = aContextOptions;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -184,7 +184,7 @@ public:
|
|||
UpdatePlatformOverridePreference(const nsAString& aValue);
|
||||
|
||||
void
|
||||
UpdateAllWorkerRuntimeOptions();
|
||||
UpdateAllWorkerContextOptions();
|
||||
|
||||
void
|
||||
UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages);
|
||||
|
|
|
@ -1442,23 +1442,22 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
class UpdateRuntimeOptionsRunnable final : public WorkerControlRunnable
|
||||
class UpdateContextOptionsRunnable final : public WorkerControlRunnable
|
||||
{
|
||||
JS::RuntimeOptions mRuntimeOptions;
|
||||
JS::ContextOptions mContextOptions;
|
||||
|
||||
public:
|
||||
UpdateRuntimeOptionsRunnable(
|
||||
WorkerPrivate* aWorkerPrivate,
|
||||
const JS::RuntimeOptions& aRuntimeOptions)
|
||||
UpdateContextOptionsRunnable(WorkerPrivate* aWorkerPrivate,
|
||||
const JS::ContextOptions& aContextOptions)
|
||||
: WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
|
||||
mRuntimeOptions(aRuntimeOptions)
|
||||
mContextOptions(aContextOptions)
|
||||
{ }
|
||||
|
||||
private:
|
||||
virtual bool
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
aWorkerPrivate->UpdateRuntimeOptionsInternal(aCx, mRuntimeOptions);
|
||||
aWorkerPrivate->UpdateContextOptionsInternal(aCx, mContextOptions);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -3051,18 +3050,18 @@ WorkerPrivateParent<Derived>::PostMessageToServiceWorker(
|
|||
|
||||
template <class Derived>
|
||||
void
|
||||
WorkerPrivateParent<Derived>::UpdateRuntimeOptions(
|
||||
const JS::RuntimeOptions& aRuntimeOptions)
|
||||
WorkerPrivateParent<Derived>::UpdateContextOptions(
|
||||
const JS::ContextOptions& aContextOptions)
|
||||
{
|
||||
AssertIsOnParentThread();
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
mJSSettings.runtimeOptions = aRuntimeOptions;
|
||||
mJSSettings.contextOptions = aContextOptions;
|
||||
}
|
||||
|
||||
RefPtr<UpdateRuntimeOptionsRunnable> runnable =
|
||||
new UpdateRuntimeOptionsRunnable(ParentAsWorkerPrivate(), aRuntimeOptions);
|
||||
RefPtr<UpdateContextOptionsRunnable> runnable =
|
||||
new UpdateContextOptionsRunnable(ParentAsWorkerPrivate(), aContextOptions);
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to update worker context options!");
|
||||
}
|
||||
|
@ -6309,16 +6308,16 @@ WorkerPrivate::RescheduleTimeoutTimer(JSContext* aCx)
|
|||
}
|
||||
|
||||
void
|
||||
WorkerPrivate::UpdateRuntimeOptionsInternal(
|
||||
WorkerPrivate::UpdateContextOptionsInternal(
|
||||
JSContext* aCx,
|
||||
const JS::RuntimeOptions& aRuntimeOptions)
|
||||
const JS::ContextOptions& aContextOptions)
|
||||
{
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
JS::RuntimeOptionsRef(aCx) = aRuntimeOptions;
|
||||
JS::ContextOptionsRef(aCx) = aContextOptions;
|
||||
|
||||
for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
|
||||
mChildWorkers[index]->UpdateRuntimeOptions(aRuntimeOptions);
|
||||
mChildWorkers[index]->UpdateContextOptions(aContextOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ public:
|
|||
ErrorResult& aRv);
|
||||
|
||||
void
|
||||
UpdateRuntimeOptions(const JS::RuntimeOptions& aRuntimeOptions);
|
||||
UpdateContextOptions(const JS::ContextOptions& aContextOptions);
|
||||
|
||||
void
|
||||
UpdateLanguages(const nsTArray<nsString>& aLanguages);
|
||||
|
@ -1168,7 +1168,7 @@ public:
|
|||
}
|
||||
|
||||
void
|
||||
UpdateRuntimeOptionsInternal(JSContext* aCx, const JS::RuntimeOptions& aRuntimeOptions);
|
||||
UpdateContextOptionsInternal(JSContext* aCx, const JS::ContextOptions& aContextOptions);
|
||||
|
||||
void
|
||||
UpdateLanguagesInternal(const nsTArray<nsString>& aLanguages);
|
||||
|
|
|
@ -141,7 +141,7 @@ struct JSSettings
|
|||
JSContentChromeSettings chrome;
|
||||
JSContentChromeSettings content;
|
||||
JSGCSettingsArray gcSettings;
|
||||
JS::RuntimeOptions runtimeOptions;
|
||||
JS::ContextOptions contextOptions;
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
uint8_t gcZeal;
|
||||
|
|
|
@ -8600,7 +8600,7 @@ js::IsAsmJSCompilationAvailable(JSContext* cx, unsigned argc, Value* vp)
|
|||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
// See EstablishPreconditions.
|
||||
bool available = HasCompilerSupport(cx) && cx->runtime()->options().asmJS();
|
||||
bool available = HasCompilerSupport(cx) && cx->options().asmJS();
|
||||
|
||||
args.rval().set(BooleanValue(available));
|
||||
return true;
|
||||
|
|
|
@ -1150,7 +1150,7 @@ DecodeUnknownSections(Decoder& d)
|
|||
bool
|
||||
CompileArgs::init(ExclusiveContext* cx)
|
||||
{
|
||||
alwaysBaseline = cx->compartment()->runtimeFromAnyThread()->options().wasmAlwaysBaseline();
|
||||
alwaysBaseline = cx->options().wasmAlwaysBaseline();
|
||||
return assumptions.init(SignalUsage(cx), cx->buildIdOp());
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ wasm::Eval(JSContext* cx, Handle<TypedArrayObject*> code, HandleObject importObj
|
|||
static bool
|
||||
InstantiateModule(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
MOZ_ASSERT(cx->runtime()->options().wasm());
|
||||
MOZ_ASSERT(cx->options().wasm());
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (!args.get(0).isObject() || !args.get(0).toObject().is<TypedArrayObject>()) {
|
||||
|
@ -209,7 +209,7 @@ const Class js::WasmClass = {
|
|||
JSObject*
|
||||
js::InitWasmClass(JSContext* cx, HandleObject global)
|
||||
{
|
||||
MOZ_ASSERT(cx->runtime()->options().wasm());
|
||||
MOZ_ASSERT(cx->options().wasm());
|
||||
|
||||
RootedObject proto(cx, global->as<GlobalObject>().getOrCreateObjectPrototype(cx));
|
||||
if (!proto)
|
||||
|
@ -649,7 +649,7 @@ InitConstructor(JSContext* cx, HandleObject global, HandleObject wasm, const cha
|
|||
JSObject*
|
||||
js::InitWebAssemblyClass(JSContext* cx, HandleObject global)
|
||||
{
|
||||
MOZ_ASSERT(cx->runtime()->options().wasm());
|
||||
MOZ_ASSERT(cx->options().wasm());
|
||||
|
||||
RootedObject proto(cx, global->as<GlobalObject>().getOrCreateObjectPrototype(cx));
|
||||
if (!proto)
|
||||
|
|
|
@ -134,7 +134,7 @@ PromiseObject::create(JSContext* cx, HandleObject executor, HandleObject proto /
|
|||
// control flow was for some unexpected results. Frightfully expensive,
|
||||
// but oh well.
|
||||
RootedObject stack(cx);
|
||||
if (cx->runtime()->options().asyncStack() || cx->compartment()->isDebuggee()) {
|
||||
if (cx->options().asyncStack() || cx->compartment()->isDebuggee()) {
|
||||
if (!JS::CaptureCurrentStack(cx, &stack, 0))
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ PromiseObject::onSettled(JSContext* cx)
|
|||
{
|
||||
Rooted<PromiseObject*> promise(cx, this);
|
||||
RootedObject stack(cx);
|
||||
if (cx->runtime()->options().asyncStack() || cx->compartment()->isDebuggee()) {
|
||||
if (cx->options().asyncStack() || cx->compartment()->isDebuggee()) {
|
||||
if (!JS::CaptureCurrentStack(cx, &stack, 0)) {
|
||||
cx->clearPendingException();
|
||||
return;
|
||||
|
|
|
@ -507,7 +507,7 @@ static bool
|
|||
WasmIsSupported(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setBoolean(wasm::HasCompilerSupport(cx) && cx->runtime()->options().wasm());
|
||||
args.rval().setBoolean(wasm::HasCompilerSupport(cx) && cx->options().wasm());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -569,7 +569,7 @@ WasmTextToBinary(JSContext* cx, unsigned argc, Value* vp)
|
|||
static bool
|
||||
WasmBinaryToText(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
MOZ_ASSERT(cx->runtime()->options().wasm());
|
||||
MOZ_ASSERT(cx->options().wasm());
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (!args.get(0).isObject() || !args.get(0).toObject().is<TypedArrayObject>()) {
|
||||
|
|
|
@ -1772,7 +1772,7 @@ IsNativeRegExpEnabled(JSContext* cx)
|
|||
#ifdef JS_CODEGEN_NONE
|
||||
return false;
|
||||
#else
|
||||
return cx->runtime()->options().nativeRegExp();
|
||||
return cx->options().nativeRegExp();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -515,7 +515,7 @@ IsBaselineEnabled(JSContext* cx)
|
|||
#ifdef JS_CODEGEN_NONE
|
||||
return false;
|
||||
#else
|
||||
return cx->runtime()->options().baseline();
|
||||
return cx->options().baseline();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ IsIonEnabled(JSContext* cx)
|
|||
#if defined(JS_CODEGEN_NONE) || defined(JS_CODEGEN_ARM64)
|
||||
return false;
|
||||
#else
|
||||
return cx->runtime()->options().ion() &&
|
||||
cx->runtime()->options().baseline() &&
|
||||
return cx->options().ion() &&
|
||||
cx->options().baseline() &&
|
||||
cx->runtime()->jitSupportsFloatingPoint;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ BEGIN_TEST(testChromeBuffer)
|
|||
*/
|
||||
{
|
||||
// Disable the JIT because if we don't this test fails. See bug 1160414.
|
||||
JS::RuntimeOptions oldOptions = JS::RuntimeOptionsRef(rt);
|
||||
JS::RuntimeOptionsRef(rt).setIon(false).setBaseline(false);
|
||||
JS::ContextOptions oldOptions = JS::ContextOptionsRef(cx);
|
||||
JS::ContextOptionsRef(cx).setIon(false).setBaseline(false);
|
||||
{
|
||||
JSAutoCompartment ac(cx, trusted_glob);
|
||||
const char* paramName = "x";
|
||||
|
@ -102,7 +102,7 @@ BEGIN_TEST(testChromeBuffer)
|
|||
JS::RootedValue rval(cx);
|
||||
CHECK(JS_CallFunction(cx, nullptr, fun, JS::HandleValueArray(v), &rval));
|
||||
CHECK(rval.toInt32() == 100);
|
||||
JS::RuntimeOptionsRef(rt) = oldOptions;
|
||||
JS::ContextOptionsRef(cx) = oldOptions;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -35,8 +35,8 @@ countIonScripts(JSObject* global)
|
|||
bool
|
||||
testPreserveJitCode(bool preserveJitCode, unsigned remainingIonScripts)
|
||||
{
|
||||
rt->options().setBaseline(true);
|
||||
rt->options().setIon(true);
|
||||
cx->options().setBaseline(true);
|
||||
cx->options().setIon(true);
|
||||
rt->setOffthreadIonCompilationEnabled(false);
|
||||
|
||||
RootedObject global(cx, createTestGlobal(preserveJitCode));
|
||||
|
|
|
@ -145,7 +145,7 @@ END_TEST(testProfileStrings_isCalledWithInterpreter)
|
|||
BEGIN_TEST(testProfileStrings_isCalledWithJIT)
|
||||
{
|
||||
CHECK(initialize(cx));
|
||||
JS::RuntimeOptionsRef(cx).setBaseline(true)
|
||||
JS::ContextOptionsRef(cx).setBaseline(true)
|
||||
.setIon(true);
|
||||
|
||||
EXEC("function g() { var p = new Prof(); p.test_fn(); }");
|
||||
|
@ -197,7 +197,7 @@ END_TEST(testProfileStrings_isCalledWithJIT)
|
|||
BEGIN_TEST(testProfileStrings_isCalledWhenError)
|
||||
{
|
||||
CHECK(initialize(cx));
|
||||
JS::RuntimeOptionsRef(cx).setBaseline(true)
|
||||
JS::ContextOptionsRef(cx).setBaseline(true)
|
||||
.setIon(true);
|
||||
|
||||
EXEC("function check2() { throw 'a'; }");
|
||||
|
@ -221,7 +221,7 @@ END_TEST(testProfileStrings_isCalledWhenError)
|
|||
BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
|
||||
{
|
||||
CHECK(initialize(cx));
|
||||
JS::RuntimeOptionsRef(cx).setBaseline(true)
|
||||
JS::ContextOptionsRef(cx).setBaseline(true)
|
||||
.setIon(true);
|
||||
|
||||
EXEC("function b(p) { p.test_fn(); }");
|
||||
|
|
|
@ -614,16 +614,10 @@ JS_StringToVersion(const char* string)
|
|||
return JSVERSION_UNKNOWN;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JS::RuntimeOptions&)
|
||||
JS::RuntimeOptionsRef(JSRuntime* rt)
|
||||
JS_PUBLIC_API(JS::ContextOptions&)
|
||||
JS::ContextOptionsRef(JSContext* cx)
|
||||
{
|
||||
return rt->options();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JS::RuntimeOptions&)
|
||||
JS::RuntimeOptionsRef(JSContext* cx)
|
||||
{
|
||||
return cx->runtime()->options();
|
||||
return cx->options();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
|
@ -1749,9 +1743,9 @@ JS_GetConstructor(JSContext* cx, HandleObject proto)
|
|||
}
|
||||
|
||||
bool
|
||||
JS::CompartmentBehaviors::extraWarnings(JSRuntime* rt) const
|
||||
JS::CompartmentBehaviors::extraWarnings(JSContext* cx) const
|
||||
{
|
||||
return extraWarningsOverride_.get(rt->options().extraWarnings());
|
||||
return extraWarningsOverride_.get(cx->options().extraWarnings());
|
||||
}
|
||||
|
||||
JS::CompartmentCreationOptions&
|
||||
|
@ -3884,16 +3878,16 @@ JS::CompileOptions::CompileOptions(JSContext* cx, JSVersion version)
|
|||
{
|
||||
this->version = (version != JSVERSION_UNKNOWN) ? version : cx->findVersion();
|
||||
|
||||
strictOption = cx->runtime()->options().strictMode();
|
||||
strictOption = cx->options().strictMode();
|
||||
extraWarningsOption = cx->compartment()->behaviors().extraWarnings(cx);
|
||||
werrorOption = cx->runtime()->options().werror();
|
||||
if (!cx->runtime()->options().asmJS())
|
||||
werrorOption = cx->options().werror();
|
||||
if (!cx->options().asmJS())
|
||||
asmJSOption = AsmJSOption::Disabled;
|
||||
else if (cx->compartment()->debuggerObservesAsmJS())
|
||||
asmJSOption = AsmJSOption::DisabledByDebugger;
|
||||
else
|
||||
asmJSOption = AsmJSOption::Enabled;
|
||||
throwOnAsmJSValidationFailureOption = cx->runtime()->options().throwOnAsmJSValidationFailure();
|
||||
throwOnAsmJSValidationFailureOption = cx->options().throwOnAsmJSValidationFailure();
|
||||
}
|
||||
|
||||
enum SyntacticScopeOption { HasSyntacticScope, HasNonSyntacticScope };
|
||||
|
@ -4903,7 +4897,7 @@ JS::AutoSetAsyncStackForNewCalls::AutoSetAsyncStackForNewCalls(
|
|||
// The option determines whether we actually use the new values at this
|
||||
// point. It will not affect restoring the previous values when the object
|
||||
// is destroyed, so if the option changes it won't cause consistency issues.
|
||||
if (!cx->runtime()->options().asyncStack())
|
||||
if (!cx->options().asyncStack())
|
||||
return;
|
||||
|
||||
SavedFrame* asyncStack = &stack->as<SavedFrame>();
|
||||
|
@ -6082,20 +6076,20 @@ JS_SetGlobalJitCompilerOption(JSContext* cx, JSJitCompilerOption opt, uint32_t v
|
|||
break;
|
||||
case JSJITCOMPILER_ION_ENABLE:
|
||||
if (value == 1) {
|
||||
JS::RuntimeOptionsRef(rt).setIon(true);
|
||||
JS::ContextOptionsRef(cx).setIon(true);
|
||||
JitSpew(js::jit::JitSpew_IonScripts, "Enable ion");
|
||||
} else if (value == 0) {
|
||||
JS::RuntimeOptionsRef(rt).setIon(false);
|
||||
JS::ContextOptionsRef(cx).setIon(false);
|
||||
JitSpew(js::jit::JitSpew_IonScripts, "Disable ion");
|
||||
}
|
||||
break;
|
||||
case JSJITCOMPILER_BASELINE_ENABLE:
|
||||
if (value == 1) {
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(true);
|
||||
JS::ContextOptionsRef(cx).setBaseline(true);
|
||||
ReleaseAllJITCode(rt->defaultFreeOp());
|
||||
JitSpew(js::jit::JitSpew_BaselineScripts, "Enable baseline");
|
||||
} else if (value == 0) {
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(false);
|
||||
JS::ContextOptionsRef(cx).setBaseline(false);
|
||||
ReleaseAllJITCode(rt->defaultFreeOp());
|
||||
JitSpew(js::jit::JitSpew_BaselineScripts, "Disable baseline");
|
||||
}
|
||||
|
@ -6148,9 +6142,9 @@ JS_GetGlobalJitCompilerOption(JSContext* cx, JSJitCompilerOption opt)
|
|||
case JSJITCOMPILER_ION_FORCE_IC:
|
||||
return jit::JitOptions.forceInlineCaches;
|
||||
case JSJITCOMPILER_ION_ENABLE:
|
||||
return JS::RuntimeOptionsRef(rt).ion();
|
||||
return JS::ContextOptionsRef(cx).ion();
|
||||
case JSJITCOMPILER_BASELINE_ENABLE:
|
||||
return JS::RuntimeOptionsRef(rt).baseline();
|
||||
return JS::ContextOptionsRef(cx).baseline();
|
||||
case JSJITCOMPILER_OFFTHREAD_COMPILATION_ENABLE:
|
||||
return rt->canUseOffthreadIonCompilation();
|
||||
case JSJITCOMPILER_SIGNALS_ENABLE:
|
||||
|
|
|
@ -1074,9 +1074,9 @@ JS_StringToVersion(const char* string);
|
|||
|
||||
namespace JS {
|
||||
|
||||
class JS_PUBLIC_API(RuntimeOptions) {
|
||||
class JS_PUBLIC_API(ContextOptions) {
|
||||
public:
|
||||
RuntimeOptions()
|
||||
ContextOptions()
|
||||
: baseline_(true),
|
||||
ion_(true),
|
||||
asmJS_(true),
|
||||
|
@ -1095,121 +1095,121 @@ class JS_PUBLIC_API(RuntimeOptions) {
|
|||
}
|
||||
|
||||
bool baseline() const { return baseline_; }
|
||||
RuntimeOptions& setBaseline(bool flag) {
|
||||
ContextOptions& setBaseline(bool flag) {
|
||||
baseline_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions& toggleBaseline() {
|
||||
ContextOptions& toggleBaseline() {
|
||||
baseline_ = !baseline_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool ion() const { return ion_; }
|
||||
RuntimeOptions& setIon(bool flag) {
|
||||
ContextOptions& setIon(bool flag) {
|
||||
ion_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions& toggleIon() {
|
||||
ContextOptions& toggleIon() {
|
||||
ion_ = !ion_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool asmJS() const { return asmJS_; }
|
||||
RuntimeOptions& setAsmJS(bool flag) {
|
||||
ContextOptions& setAsmJS(bool flag) {
|
||||
asmJS_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions& toggleAsmJS() {
|
||||
ContextOptions& toggleAsmJS() {
|
||||
asmJS_ = !asmJS_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool wasm() const { return wasm_; }
|
||||
RuntimeOptions& setWasm(bool flag) {
|
||||
ContextOptions& setWasm(bool flag) {
|
||||
wasm_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions& toggleWasm() {
|
||||
ContextOptions& toggleWasm() {
|
||||
wasm_ = !wasm_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool wasmAlwaysBaseline() const { return wasmAlwaysBaseline_; }
|
||||
RuntimeOptions& setWasmAlwaysBaseline(bool flag) {
|
||||
ContextOptions& setWasmAlwaysBaseline(bool flag) {
|
||||
wasmAlwaysBaseline_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions& toggleWasmAlwaysBaseline() {
|
||||
ContextOptions& toggleWasmAlwaysBaseline() {
|
||||
wasmAlwaysBaseline_ = !wasmAlwaysBaseline_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool throwOnAsmJSValidationFailure() const { return throwOnAsmJSValidationFailure_; }
|
||||
RuntimeOptions& setThrowOnAsmJSValidationFailure(bool flag) {
|
||||
ContextOptions& setThrowOnAsmJSValidationFailure(bool flag) {
|
||||
throwOnAsmJSValidationFailure_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions& toggleThrowOnAsmJSValidationFailure() {
|
||||
ContextOptions& toggleThrowOnAsmJSValidationFailure() {
|
||||
throwOnAsmJSValidationFailure_ = !throwOnAsmJSValidationFailure_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool nativeRegExp() const { return nativeRegExp_; }
|
||||
RuntimeOptions& setNativeRegExp(bool flag) {
|
||||
ContextOptions& setNativeRegExp(bool flag) {
|
||||
nativeRegExp_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool unboxedArrays() const { return unboxedArrays_; }
|
||||
RuntimeOptions& setUnboxedArrays(bool flag) {
|
||||
ContextOptions& setUnboxedArrays(bool flag) {
|
||||
unboxedArrays_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool asyncStack() const { return asyncStack_; }
|
||||
RuntimeOptions& setAsyncStack(bool flag) {
|
||||
ContextOptions& setAsyncStack(bool flag) {
|
||||
asyncStack_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool throwOnDebuggeeWouldRun() const { return throwOnDebuggeeWouldRun_; }
|
||||
RuntimeOptions& setThrowOnDebuggeeWouldRun(bool flag) {
|
||||
ContextOptions& setThrowOnDebuggeeWouldRun(bool flag) {
|
||||
throwOnDebuggeeWouldRun_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool dumpStackOnDebuggeeWouldRun() const { return dumpStackOnDebuggeeWouldRun_; }
|
||||
RuntimeOptions& setDumpStackOnDebuggeeWouldRun(bool flag) {
|
||||
ContextOptions& setDumpStackOnDebuggeeWouldRun(bool flag) {
|
||||
dumpStackOnDebuggeeWouldRun_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool werror() const { return werror_; }
|
||||
RuntimeOptions& setWerror(bool flag) {
|
||||
ContextOptions& setWerror(bool flag) {
|
||||
werror_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions& toggleWerror() {
|
||||
ContextOptions& toggleWerror() {
|
||||
werror_ = !werror_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool strictMode() const { return strictMode_; }
|
||||
RuntimeOptions& setStrictMode(bool flag) {
|
||||
ContextOptions& setStrictMode(bool flag) {
|
||||
strictMode_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions& toggleStrictMode() {
|
||||
ContextOptions& toggleStrictMode() {
|
||||
strictMode_ = !strictMode_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool extraWarnings() const { return extraWarnings_; }
|
||||
RuntimeOptions& setExtraWarnings(bool flag) {
|
||||
ContextOptions& setExtraWarnings(bool flag) {
|
||||
extraWarnings_ = flag;
|
||||
return *this;
|
||||
}
|
||||
RuntimeOptions& toggleExtraWarnings() {
|
||||
ContextOptions& toggleExtraWarnings() {
|
||||
extraWarnings_ = !extraWarnings_;
|
||||
return *this;
|
||||
}
|
||||
|
@ -1231,11 +1231,8 @@ class JS_PUBLIC_API(RuntimeOptions) {
|
|||
bool extraWarnings_ : 1;
|
||||
};
|
||||
|
||||
JS_PUBLIC_API(RuntimeOptions&)
|
||||
RuntimeOptionsRef(JSRuntime* rt);
|
||||
|
||||
JS_PUBLIC_API(RuntimeOptions&)
|
||||
RuntimeOptionsRef(JSContext* cx);
|
||||
JS_PUBLIC_API(ContextOptions&)
|
||||
ContextOptionsRef(JSContext* cx);
|
||||
|
||||
/**
|
||||
* Initialize the runtime's self-hosted code. Embeddings should call this
|
||||
|
@ -2309,7 +2306,7 @@ class JS_PUBLIC_API(CompartmentBehaviors)
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool extraWarnings(JSRuntime* rt) const;
|
||||
bool extraWarnings(JSContext* cx) const;
|
||||
Override& extraWarningsOverride() { return extraWarningsOverride_; }
|
||||
|
||||
bool getSingletonsAsTemplates() const {
|
||||
|
@ -4130,7 +4127,7 @@ JS_DecompileFunction(JSContext* cx, JS::Handle<JSFunction*> fun, unsigned indent
|
|||
* Why a runtime option? The alternative is to add APIs duplicating those
|
||||
* for the other value of flags, and that doesn't seem worth the code bloat
|
||||
* cost. Such new entry points would probably have less obvious names, too, so
|
||||
* would not tend to be used. The RuntimeOptionsRef adjustment, OTOH, can be
|
||||
* would not tend to be used. The ContextOptionsRef adjustment, OTOH, can be
|
||||
* more easily hacked into existing code that does not depend on the bug; such
|
||||
* code can continue to use the familiar JS::Evaluate, etc., entry points.
|
||||
*/
|
||||
|
|
|
@ -324,7 +324,7 @@ checkReportFlags(JSContext* cx, unsigned* flags)
|
|||
}
|
||||
|
||||
/* Warnings become errors when JSOPTION_WERROR is set. */
|
||||
if (JSREPORT_IS_WARNING(*flags) && cx->runtime()->options().werror())
|
||||
if (JSREPORT_IS_WARNING(*flags) && cx->options().werror())
|
||||
*flags &= ~JSREPORT_WARNING;
|
||||
|
||||
return false;
|
||||
|
@ -845,10 +845,12 @@ js::GetErrorMessage(void* userRef, const unsigned errorNumber)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ExclusiveContext::ExclusiveContext(JSRuntime* rt, PerThreadData* pt, ContextKind kind)
|
||||
ExclusiveContext::ExclusiveContext(JSRuntime* rt, PerThreadData* pt, ContextKind kind,
|
||||
const JS::ContextOptions& options)
|
||||
: ContextFriendFields(rt),
|
||||
helperThread_(nullptr),
|
||||
contextKind_(kind),
|
||||
options_(options),
|
||||
perThreadData(pt),
|
||||
arenas_(nullptr),
|
||||
enterCompartmentDepth_(0)
|
||||
|
@ -871,7 +873,7 @@ ExclusiveContext::recoverFromOutOfMemory()
|
|||
}
|
||||
|
||||
JSContext::JSContext(JSRuntime* parentRuntime)
|
||||
: ExclusiveContext(this, &this->JSRuntime::mainThread, Context_JS),
|
||||
: ExclusiveContext(this, &this->JSRuntime::mainThread, Context_JS, JS::ContextOptions()),
|
||||
JSRuntime(parentRuntime),
|
||||
throwing(false),
|
||||
unwrappedException_(this),
|
||||
|
|
|
@ -117,10 +117,16 @@ class ExclusiveContext : public ContextFriendFields,
|
|||
private:
|
||||
ContextKind contextKind_;
|
||||
|
||||
protected:
|
||||
// Background threads get a read-only copy of the main thread's
|
||||
// ContextOptions.
|
||||
JS::ContextOptions options_;
|
||||
|
||||
public:
|
||||
PerThreadData* perThreadData;
|
||||
|
||||
ExclusiveContext(JSRuntime* rt, PerThreadData* pt, ContextKind kind);
|
||||
ExclusiveContext(JSRuntime* rt, PerThreadData* pt, ContextKind kind,
|
||||
const JS::ContextOptions& options);
|
||||
|
||||
bool isJSContext() const {
|
||||
return contextKind_ == Context_JS;
|
||||
|
@ -153,6 +159,10 @@ class ExclusiveContext : public ContextFriendFields,
|
|||
return isJSContext();
|
||||
}
|
||||
|
||||
const JS::ContextOptions& options() const {
|
||||
return options_;
|
||||
}
|
||||
|
||||
protected:
|
||||
js::gc::ArenaLists* arenas_;
|
||||
|
||||
|
@ -385,6 +395,10 @@ struct JSContext : public js::ExclusiveContext,
|
|||
*/
|
||||
JSVersion findVersion() const;
|
||||
|
||||
JS::ContextOptions& options() {
|
||||
return options_;
|
||||
}
|
||||
|
||||
js::LifoAlloc& tempLifoAlloc() { return runtime()->tempLifoAlloc; }
|
||||
|
||||
unsigned outstandingRequests;/* number of JS_BeginRequest calls
|
||||
|
|
|
@ -550,7 +550,7 @@ js::ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp,
|
|||
|
||||
if (exnType == JSEXN_WARN) {
|
||||
// werror must be enabled, so we use JSEXN_ERR.
|
||||
MOZ_ASSERT(cx->runtime()->options().werror());
|
||||
MOZ_ASSERT(cx->options().werror());
|
||||
exnType = JSEXN_ERR;
|
||||
}
|
||||
|
||||
|
|
|
@ -1021,7 +1021,7 @@ Options(JSContext* cx, unsigned argc, Value* vp)
|
|||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
JS::RuntimeOptions oldRuntimeOptions = JS::RuntimeOptionsRef(cx);
|
||||
JS::ContextOptions oldContextOptions = JS::ContextOptionsRef(cx);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
JSString* str = JS::ToString(cx, args[i]);
|
||||
if (!str)
|
||||
|
@ -1033,13 +1033,13 @@ Options(JSContext* cx, unsigned argc, Value* vp)
|
|||
return false;
|
||||
|
||||
if (strcmp(opt.ptr(), "strict") == 0)
|
||||
JS::RuntimeOptionsRef(cx).toggleExtraWarnings();
|
||||
JS::ContextOptionsRef(cx).toggleExtraWarnings();
|
||||
else if (strcmp(opt.ptr(), "werror") == 0)
|
||||
JS::RuntimeOptionsRef(cx).toggleWerror();
|
||||
JS::ContextOptionsRef(cx).toggleWerror();
|
||||
else if (strcmp(opt.ptr(), "throw_on_asmjs_validation_failure") == 0)
|
||||
JS::RuntimeOptionsRef(cx).toggleThrowOnAsmJSValidationFailure();
|
||||
JS::ContextOptionsRef(cx).toggleThrowOnAsmJSValidationFailure();
|
||||
else if (strcmp(opt.ptr(), "strict_mode") == 0)
|
||||
JS::RuntimeOptionsRef(cx).toggleStrictMode();
|
||||
JS::ContextOptionsRef(cx).toggleStrictMode();
|
||||
else {
|
||||
JS_ReportError(cx,
|
||||
"unknown option name '%s'."
|
||||
|
@ -1052,19 +1052,19 @@ Options(JSContext* cx, unsigned argc, Value* vp)
|
|||
|
||||
char* names = strdup("");
|
||||
bool found = false;
|
||||
if (names && oldRuntimeOptions.extraWarnings()) {
|
||||
if (names && oldContextOptions.extraWarnings()) {
|
||||
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "strict");
|
||||
found = true;
|
||||
}
|
||||
if (names && oldRuntimeOptions.werror()) {
|
||||
if (names && oldContextOptions.werror()) {
|
||||
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "werror");
|
||||
found = true;
|
||||
}
|
||||
if (names && oldRuntimeOptions.throwOnAsmJSValidationFailure()) {
|
||||
if (names && oldContextOptions.throwOnAsmJSValidationFailure()) {
|
||||
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "throw_on_asmjs_validation_failure");
|
||||
found = true;
|
||||
}
|
||||
if (names && oldRuntimeOptions.strictMode()) {
|
||||
if (names && oldContextOptions.strictMode()) {
|
||||
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "strict_mode");
|
||||
found = true;
|
||||
}
|
||||
|
@ -2922,7 +2922,7 @@ struct WorkerInput
|
|||
}
|
||||
};
|
||||
|
||||
static void SetWorkerRuntimeOptions(JSRuntime* rt);
|
||||
static void SetWorkerContextOptions(JSContext* cx);
|
||||
|
||||
static void
|
||||
WorkerMain(void* arg)
|
||||
|
@ -2949,7 +2949,7 @@ WorkerMain(void* arg)
|
|||
JS_SetFutexCanWait(cx);
|
||||
JS::SetWarningReporter(cx, WarningReporter);
|
||||
JS_InitDestroyPrincipalsCallback(cx, ShellPrincipals::destroy);
|
||||
SetWorkerRuntimeOptions(rt);
|
||||
SetWorkerContextOptions(cx);
|
||||
|
||||
if (!JS::InitSelfHostedCode(cx)) {
|
||||
JS_DestroyRuntime(rt);
|
||||
|
@ -6647,7 +6647,7 @@ ProcessArgs(JSContext* cx, OptionParser* op)
|
|||
ShellRuntime* sr = GetShellRuntime(cx);
|
||||
|
||||
if (op->getBoolOption('s'))
|
||||
JS::RuntimeOptionsRef(cx).toggleExtraWarnings();
|
||||
JS::ContextOptionsRef(cx).toggleExtraWarnings();
|
||||
|
||||
/* |scriptArgs| gets bound on the global before any code is run. */
|
||||
if (!BindScriptArgs(cx, op))
|
||||
|
@ -6720,7 +6720,7 @@ ProcessArgs(JSContext* cx, OptionParser* op)
|
|||
}
|
||||
|
||||
static bool
|
||||
SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
|
||||
SetContextOptions(JSContext* cx, const OptionParser& op)
|
||||
{
|
||||
enableBaseline = !op.getBoolOption("no-baseline");
|
||||
enableIon = !op.getBoolOption("no-ion");
|
||||
|
@ -6729,7 +6729,7 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
|
|||
enableUnboxedArrays = op.getBoolOption("unboxed-arrays");
|
||||
enableWasmAlwaysBaseline = op.getBoolOption("wasm-always-baseline");
|
||||
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(enableBaseline)
|
||||
JS::ContextOptionsRef(cx).setBaseline(enableBaseline)
|
||||
.setIon(enableIon)
|
||||
.setAsmJS(enableAsmJS)
|
||||
.setWasm(true)
|
||||
|
@ -6912,7 +6912,7 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
|
|||
else if (strcmp(str, "on") != 0)
|
||||
return OptionFailure("ion-offthread-compile", str);
|
||||
}
|
||||
rt->setOffthreadIonCompilationEnabled(offthreadCompilation);
|
||||
cx->setOffthreadIonCompilationEnabled(offthreadCompilation);
|
||||
|
||||
if (op.getStringOption("ion-parallel-compile")) {
|
||||
fprintf(stderr, "--ion-parallel-compile is deprecated. Please use --ion-offthread-compile instead.\n");
|
||||
|
@ -6964,14 +6964,14 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
|
|||
printTiming = op.getBoolOption('b');
|
||||
enableCodeCoverage = op.getBoolOption("code-coverage");
|
||||
enableDisassemblyDumps = op.getBoolOption('D');
|
||||
rt->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
|
||||
cx->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
|
||||
|
||||
jsCacheDir = op.getStringOption("js-cache");
|
||||
if (jsCacheDir) {
|
||||
if (!op.getBoolOption("no-js-cache-per-process"))
|
||||
jsCacheDir = JS_smprintf("%s/%u", jsCacheDir, (unsigned)getpid());
|
||||
else
|
||||
jsCacheDir = JS_strdup(rt, jsCacheDir);
|
||||
jsCacheDir = JS_strdup(cx, jsCacheDir);
|
||||
if (!jsCacheDir)
|
||||
return false;
|
||||
jsCacheAsmJSPath = JS_smprintf("%s/asmjs.cache", jsCacheDir);
|
||||
|
@ -6984,10 +6984,10 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
|
|||
#ifdef JS_GC_ZEAL
|
||||
const char* zealStr = op.getStringOption("gc-zeal");
|
||||
if (zealStr) {
|
||||
if (!rt->gc.parseAndSetZeal(zealStr))
|
||||
if (!cx->gc.parseAndSetZeal(zealStr))
|
||||
return false;
|
||||
uint32_t nextScheduled;
|
||||
rt->gc.getZealBits(&gZealBits, &gZealFrequency, &nextScheduled);
|
||||
cx->gc.getZealBits(&gZealBits, &gZealFrequency, &nextScheduled);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -6995,30 +6995,30 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
|
|||
}
|
||||
|
||||
static void
|
||||
SetWorkerRuntimeOptions(JSRuntime* rt)
|
||||
SetWorkerContextOptions(JSContext* cx)
|
||||
{
|
||||
// Copy option values from the main thread.
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(enableBaseline)
|
||||
JS::ContextOptionsRef(cx).setBaseline(enableBaseline)
|
||||
.setIon(enableIon)
|
||||
.setAsmJS(enableAsmJS)
|
||||
.setWasm(true)
|
||||
.setWasmAlwaysBaseline(enableWasmAlwaysBaseline)
|
||||
.setNativeRegExp(enableNativeRegExp)
|
||||
.setUnboxedArrays(enableUnboxedArrays);
|
||||
rt->setOffthreadIonCompilationEnabled(offthreadCompilation);
|
||||
rt->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
|
||||
cx->setOffthreadIonCompilationEnabled(offthreadCompilation);
|
||||
cx->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
if (gZealBits && gZealFrequency) {
|
||||
#define ZEAL_MODE(_, value) \
|
||||
if (gZealBits & (1 << value)) \
|
||||
rt->gc.setZeal(value, gZealFrequency);
|
||||
cx->gc.setZeal(value, gZealFrequency);
|
||||
JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE)
|
||||
#undef ZEAL_MODE
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_SetNativeStackQuota(JS_GetContext(rt), gMaxStackSize);
|
||||
JS_SetNativeStackQuota(cx, gMaxStackSize);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -7386,7 +7386,7 @@ main(int argc, char** argv, char** envp)
|
|||
// Waiting is allowed on the shell's main thread, for now.
|
||||
JS_SetFutexCanWait(cx);
|
||||
JS::SetWarningReporter(cx, WarningReporter);
|
||||
if (!SetRuntimeOptions(rt, op))
|
||||
if (!SetContextOptions(cx, op))
|
||||
return 1;
|
||||
|
||||
JS_SetGCParameter(cx, JSGC_MAX_BYTES, 0xffffffff);
|
||||
|
|
|
@ -337,11 +337,11 @@ class MOZ_RAII js::EnterDebuggeeNoExecute
|
|||
// warning or an error if there is a lock that locks it.
|
||||
static bool reportIfFoundInStack(JSContext* cx, HandleScript script) {
|
||||
if (EnterDebuggeeNoExecute* nx = findInStack(cx)) {
|
||||
bool warning = !cx->runtime()->options().throwOnDebuggeeWouldRun();
|
||||
bool warning = !cx->options().throwOnDebuggeeWouldRun();
|
||||
if (!warning || !nx->reported_) {
|
||||
AutoCompartment ac(cx, nx->debugger().toJSObject());
|
||||
nx->reported_ = true;
|
||||
if (cx->runtime()->options().dumpStackOnDebuggeeWouldRun()) {
|
||||
if (cx->options().dumpStackOnDebuggeeWouldRun()) {
|
||||
fprintf(stdout, "Dumping stack for DebuggeeWouldRun:\n");
|
||||
DumpBacktrace(cx);
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ js::GlobalObject::getTypedObjectModule() const {
|
|||
GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key)
|
||||
{
|
||||
if (key == JSProto_Wasm || key == JSProto_WebAssembly)
|
||||
return !cx->runtime()->options().wasm();
|
||||
return !cx->options().wasm();
|
||||
|
||||
#ifdef ENABLE_SHARED_ARRAY_BUFFER
|
||||
// Return true if the given constructor has been disabled at run-time.
|
||||
|
|
|
@ -484,7 +484,7 @@ js::StartOffThreadParseScript(JSContext* cx, const ReadOnlyCompileOptions& optio
|
|||
|
||||
ScopedJSDeletePtr<ExclusiveContext> helpercx(
|
||||
cx->new_<ExclusiveContext>(cx->runtime(), (PerThreadData*) nullptr,
|
||||
ExclusiveContext::Context_Exclusive));
|
||||
ExclusiveContext::Context_Exclusive, cx->options()));
|
||||
if (!helpercx)
|
||||
return false;
|
||||
|
||||
|
@ -521,7 +521,7 @@ js::StartOffThreadParseModule(JSContext* cx, const ReadOnlyCompileOptions& optio
|
|||
|
||||
ScopedJSDeletePtr<ExclusiveContext> helpercx(
|
||||
cx->new_<ExclusiveContext>(cx->runtime(), (PerThreadData*) nullptr,
|
||||
ExclusiveContext::Context_Exclusive));
|
||||
ExclusiveContext::Context_Exclusive, cx->options()));
|
||||
if (!helpercx)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -1471,7 +1471,7 @@ ObjectGroup::allocationSiteGroup(JSContext* cx, JSScript* scriptArg, jsbytecode*
|
|||
|
||||
if (kind == JSProto_Array &&
|
||||
(JSOp(*pc) == JSOP_NEWARRAY || IsCallPC(pc)) &&
|
||||
cx->runtime()->options().unboxedArrays())
|
||||
cx->options().unboxedArrays())
|
||||
{
|
||||
PreliminaryObjectArrayWithTemplate* preliminaryObjects =
|
||||
cx->new_<PreliminaryObjectArrayWithTemplate>(nullptr);
|
||||
|
|
|
@ -1247,7 +1247,6 @@ struct JSRuntime : public JS::shadow::Runtime,
|
|||
void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::RuntimeSizes* runtime);
|
||||
|
||||
private:
|
||||
JS::RuntimeOptions options_;
|
||||
const js::Class* windowProxyClass_;
|
||||
|
||||
// Settings for how helper threads can be used.
|
||||
|
@ -1279,13 +1278,6 @@ struct JSRuntime : public JS::shadow::Runtime,
|
|||
autoWritableJitCodeActive_ = b;
|
||||
}
|
||||
|
||||
const JS::RuntimeOptions& options() const {
|
||||
return options_;
|
||||
}
|
||||
JS::RuntimeOptions& options() {
|
||||
return options_;
|
||||
}
|
||||
|
||||
const js::Class* maybeWindowProxyClass() const {
|
||||
return windowProxyClass_;
|
||||
}
|
||||
|
|
|
@ -1930,7 +1930,7 @@ js::TryConvertToUnboxedLayout(ExclusiveContext* cx, Shape* templateShape,
|
|||
if (isArray) {
|
||||
#ifdef NIGHTLY_BUILD
|
||||
if (!getenv("JS_OPTION_USE_UNBOXED_ARRAYS")) {
|
||||
if (!group->runtimeFromAnyThread()->options().unboxedArrays())
|
||||
if (!cx->options().unboxedArrays())
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -3000,27 +3000,12 @@ nsXPCComponents_Utils::Dispatch(HandleValue runnableArg, HandleValue scope,
|
|||
return NS_OK; \
|
||||
}
|
||||
|
||||
#define GENERATE_JSRUNTIMEOPTION_GETTER_SETTER(_attr, _getter, _setter) \
|
||||
NS_IMETHODIMP \
|
||||
nsXPCComponents_Utils::Get## _attr(JSContext* cx, bool* aValue) \
|
||||
{ \
|
||||
*aValue = RuntimeOptionsRef(cx)._getter(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
nsXPCComponents_Utils::Set## _attr(JSContext* cx, bool aValue) \
|
||||
{ \
|
||||
RuntimeOptionsRef(cx)._setter(aValue); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
GENERATE_JSRUNTIMEOPTION_GETTER_SETTER(Strict, extraWarnings, setExtraWarnings)
|
||||
GENERATE_JSRUNTIMEOPTION_GETTER_SETTER(Werror, werror, setWerror)
|
||||
GENERATE_JSRUNTIMEOPTION_GETTER_SETTER(Strict_mode, strictMode, setStrictMode)
|
||||
GENERATE_JSRUNTIMEOPTION_GETTER_SETTER(Ion, ion, setIon)
|
||||
GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Strict, extraWarnings, setExtraWarnings)
|
||||
GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Werror, werror, setWerror)
|
||||
GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Strict_mode, strictMode, setStrictMode)
|
||||
GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Ion, ion, setIon)
|
||||
|
||||
#undef GENERATE_JSCONTEXTOPTION_GETTER_SETTER
|
||||
#undef GENERATE_JSRUNTIMEOPTION_GETTER_SETTER
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::SetGCZeal(int32_t aValue, JSContext* cx)
|
||||
|
|
|
@ -1561,7 +1561,6 @@ static void
|
|||
ReloadPrefsCallback(const char* pref, void* data)
|
||||
{
|
||||
XPCJSRuntime* runtime = reinterpret_cast<XPCJSRuntime*>(data);
|
||||
JSRuntime* rt = runtime->Runtime();
|
||||
JSContext* cx = runtime->Context();
|
||||
|
||||
bool safeMode = false;
|
||||
|
@ -1616,7 +1615,7 @@ ReloadPrefsCallback(const char* pref, void* data)
|
|||
}
|
||||
#endif // JS_GC_ZEAL
|
||||
|
||||
JS::RuntimeOptionsRef(rt).setBaseline(useBaseline)
|
||||
JS::ContextOptionsRef(cx).setBaseline(useBaseline)
|
||||
.setIon(useIon)
|
||||
.setAsmJS(useAsmJS)
|
||||
.setWasm(useWasm)
|
||||
|
|
|
@ -485,7 +485,7 @@ static bool
|
|||
Options(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
RuntimeOptions oldRuntimeOptions = RuntimeOptionsRef(cx);
|
||||
ContextOptions oldContextOptions = ContextOptionsRef(cx);
|
||||
|
||||
for (unsigned i = 0; i < args.length(); ++i) {
|
||||
JSString* str = ToString(cx, args[i]);
|
||||
|
@ -497,11 +497,11 @@ Options(JSContext* cx, unsigned argc, Value* vp)
|
|||
return false;
|
||||
|
||||
if (strcmp(opt.ptr(), "strict") == 0)
|
||||
RuntimeOptionsRef(cx).toggleExtraWarnings();
|
||||
ContextOptionsRef(cx).toggleExtraWarnings();
|
||||
else if (strcmp(opt.ptr(), "werror") == 0)
|
||||
RuntimeOptionsRef(cx).toggleWerror();
|
||||
ContextOptionsRef(cx).toggleWerror();
|
||||
else if (strcmp(opt.ptr(), "strict_mode") == 0)
|
||||
RuntimeOptionsRef(cx).toggleStrictMode();
|
||||
ContextOptionsRef(cx).toggleStrictMode();
|
||||
else {
|
||||
JS_ReportError(cx, "unknown option name '%s'. The valid names are "
|
||||
"strict, werror, and strict_mode.", opt.ptr());
|
||||
|
@ -510,21 +510,21 @@ Options(JSContext* cx, unsigned argc, Value* vp)
|
|||
}
|
||||
|
||||
char* names = nullptr;
|
||||
if (oldRuntimeOptions.extraWarnings()) {
|
||||
if (oldContextOptions.extraWarnings()) {
|
||||
names = JS_sprintf_append(names, "%s", "strict");
|
||||
if (!names) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (oldRuntimeOptions.werror()) {
|
||||
if (oldContextOptions.werror()) {
|
||||
names = JS_sprintf_append(names, "%s%s", names ? "," : "", "werror");
|
||||
if (!names) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (names && oldRuntimeOptions.strictMode()) {
|
||||
if (names && oldContextOptions.strictMode()) {
|
||||
names = JS_sprintf_append(names, "%s%s", names ? "," : "", "strict_mode");
|
||||
if (!names) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
|
@ -961,13 +961,13 @@ ProcessArgsForCompartment(JSContext* cx, char** argv, int argc)
|
|||
return;
|
||||
break;
|
||||
case 'S':
|
||||
RuntimeOptionsRef(cx).toggleWerror();
|
||||
ContextOptionsRef(cx).toggleWerror();
|
||||
MOZ_FALLTHROUGH; // because -S implies -s
|
||||
case 's':
|
||||
RuntimeOptionsRef(cx).toggleExtraWarnings();
|
||||
ContextOptionsRef(cx).toggleExtraWarnings();
|
||||
break;
|
||||
case 'I':
|
||||
RuntimeOptionsRef(cx).toggleIon()
|
||||
ContextOptionsRef(cx).toggleIon()
|
||||
.toggleAsmJS()
|
||||
.toggleWasm();
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче