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:
Jan de Mooij 2016-07-07 08:15:15 +02:00
Родитель 587bf3d8eb
Коммит a53a99aab6
32 изменённых файлов: 172 добавлений и 190 удалений

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

@ -58,7 +58,7 @@ public:
explicit CallbackObject(JSContext* aCx, JS::Handle<JSObject*> aCallback, explicit CallbackObject(JSContext* aCx, JS::Handle<JSObject*> aCallback,
nsIGlobalObject* aIncumbentGlobal) nsIGlobalObject* aIncumbentGlobal)
{ {
if (aCx && JS::RuntimeOptionsRef(aCx).asyncStack()) { if (aCx && JS::ContextOptionsRef(aCx).asyncStack()) {
JS::RootedObject stack(aCx); JS::RootedObject stack(aCx);
if (!JS::CaptureCurrentStack(aCx, &stack)) { if (!JS::CaptureCurrentStack(aCx, &stack)) {
JS_ClearPendingException(aCx); JS_ClearPendingException(aCx);
@ -230,7 +230,7 @@ protected:
nsIGlobalObject* aIncumbentGlobal, nsIGlobalObject* aIncumbentGlobal,
const FastCallbackConstructor&) const FastCallbackConstructor&)
{ {
if (aCx && JS::RuntimeOptionsRef(aCx).asyncStack()) { if (aCx && JS::ContextOptionsRef(aCx).asyncStack()) {
JS::RootedObject stack(aCx); JS::RootedObject stack(aCx);
if (!JS::CaptureCurrentStack(aCx, &stack)) { if (!JS::CaptureCurrentStack(aCx, &stack)) {
JS_ClearPendingException(aCx); JS_ClearPendingException(aCx);

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

@ -261,7 +261,7 @@ GenerateSharedWorkerKey(const nsACString& aScriptSpec, const nsACString& aName,
} }
void void
LoadRuntimeOptions(const char* aPrefName, void* /* aClosure */) LoadContextOptions(const char* aPrefName, void* /* aClosure */)
{ {
AssertIsOnMainThread(); AssertIsOnMainThread();
@ -291,9 +291,9 @@ LoadRuntimeOptions(const char* aPrefName, void* /* aClosure */)
} }
#endif #endif
// Runtime options. // Context options.
JS::RuntimeOptions runtimeOptions; JS::ContextOptions contextOptions;
runtimeOptions.setAsmJS(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs"))) contextOptions.setAsmJS(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs")))
.setWasm(GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm"))) .setWasm(GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm")))
.setThrowOnAsmJSValidationFailure(GetWorkerPref<bool>( .setThrowOnAsmJSValidationFailure(GetWorkerPref<bool>(
NS_LITERAL_CSTRING("throw_on_asmjs_validation_failure"))) 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"))) .setWerror(GetWorkerPref<bool>(NS_LITERAL_CSTRING("werror")))
.setExtraWarnings(GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict"))); .setExtraWarnings(GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict")));
RuntimeService::SetDefaultRuntimeOptions(runtimeOptions); RuntimeService::SetDefaultContextOptions(contextOptions);
if (rts) { if (rts) {
rts->UpdateAllWorkerRuntimeOptions(); rts->UpdateAllWorkerContextOptions();
} }
} }
@ -758,7 +758,7 @@ InitJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
JSContext* workerCx = JS_GetContext(aRuntime); JSContext* workerCx = JS_GetContext(aRuntime);
JS::RuntimeOptionsRef(aRuntime) = settings.runtimeOptions; JS::ContextOptionsRef(workerCx) = settings.contextOptions;
JSSettings::JSGCSettingsArray& gcSettings = settings.gcSettings; JSSettings::JSGCSettingsArray& gcSettings = settings.gcSettings;
@ -1711,7 +1711,7 @@ RuntimeService::Init()
// Initialize JSSettings. // Initialize JSSettings.
if (!sDefaultJSSettings.gcSettings[0].IsSet()) { if (!sDefaultJSSettings.gcSettings[0].IsSet()) {
sDefaultJSSettings.runtimeOptions = JS::RuntimeOptions(); sDefaultJSSettings.contextOptions = JS::ContextOptions();
sDefaultJSSettings.chrome.maxScriptRuntime = -1; sDefaultJSSettings.chrome.maxScriptRuntime = -1;
sDefaultJSSettings.chrome.compartmentOptions.behaviors().setVersion(JSVERSION_LATEST); sDefaultJSSettings.chrome.compartmentOptions.behaviors().setVersion(JSVERSION_LATEST);
sDefaultJSSettings.content.maxScriptRuntime = MAX_SCRIPT_RUN_TIME_SEC; sDefaultJSSettings.content.maxScriptRuntime = MAX_SCRIPT_RUN_TIME_SEC;
@ -1789,10 +1789,10 @@ RuntimeService::Init()
#undef WORKER_PREF #undef WORKER_PREF
NS_FAILED(Preferences::RegisterCallbackAndCall( NS_FAILED(Preferences::RegisterCallbackAndCall(
LoadRuntimeOptions, LoadContextOptions,
PREF_WORKERS_OPTIONS_PREFIX, PREF_WORKERS_OPTIONS_PREFIX,
nullptr)) || nullptr)) ||
NS_FAILED(Preferences::RegisterCallback(LoadRuntimeOptions, NS_FAILED(Preferences::RegisterCallback(LoadContextOptions,
PREF_JS_OPTIONS_PREFIX, PREF_JS_OPTIONS_PREFIX,
nullptr))) { nullptr))) {
NS_WARNING("Failed to register pref callbacks!"); NS_WARNING("Failed to register pref callbacks!");
@ -1931,10 +1931,10 @@ RuntimeService::Cleanup()
NS_ASSERTION(!mWindowMap.Count(), "All windows should have been released!"); NS_ASSERTION(!mWindowMap.Count(), "All windows should have been released!");
if (mObserved) { if (mObserved) {
if (NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeOptions, if (NS_FAILED(Preferences::UnregisterCallback(LoadContextOptions,
PREF_JS_OPTIONS_PREFIX, PREF_JS_OPTIONS_PREFIX,
nullptr)) || nullptr)) ||
NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeOptions, NS_FAILED(Preferences::UnregisterCallback(LoadContextOptions,
PREF_WORKERS_OPTIONS_PREFIX, PREF_WORKERS_OPTIONS_PREFIX,
nullptr)) || nullptr)) ||
@ -2287,9 +2287,9 @@ RuntimeService::NoteIdleThread(WorkerThread* aThread)
} }
void void
RuntimeService::UpdateAllWorkerRuntimeOptions() RuntimeService::UpdateAllWorkerContextOptions()
{ {
BROADCAST_ALL_WORKERS(UpdateRuntimeOptions, sDefaultJSSettings.runtimeOptions); BROADCAST_ALL_WORKERS(UpdateContextOptions, sDefaultJSSettings.contextOptions);
} }
void void

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

@ -168,10 +168,10 @@ public:
} }
static void static void
SetDefaultRuntimeOptions(const JS::RuntimeOptions& aRuntimeOptions) SetDefaultContextOptions(const JS::ContextOptions& aContextOptions)
{ {
AssertIsOnMainThread(); AssertIsOnMainThread();
sDefaultJSSettings.runtimeOptions = aRuntimeOptions; sDefaultJSSettings.contextOptions = aContextOptions;
} }
void void
@ -184,7 +184,7 @@ public:
UpdatePlatformOverridePreference(const nsAString& aValue); UpdatePlatformOverridePreference(const nsAString& aValue);
void void
UpdateAllWorkerRuntimeOptions(); UpdateAllWorkerContextOptions();
void void
UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages); 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: public:
UpdateRuntimeOptionsRunnable( UpdateContextOptionsRunnable(WorkerPrivate* aWorkerPrivate,
WorkerPrivate* aWorkerPrivate, const JS::ContextOptions& aContextOptions)
const JS::RuntimeOptions& aRuntimeOptions)
: WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount), : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
mRuntimeOptions(aRuntimeOptions) mContextOptions(aContextOptions)
{ } { }
private: private:
virtual bool virtual bool
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
{ {
aWorkerPrivate->UpdateRuntimeOptionsInternal(aCx, mRuntimeOptions); aWorkerPrivate->UpdateContextOptionsInternal(aCx, mContextOptions);
return true; return true;
} }
}; };
@ -3051,18 +3050,18 @@ WorkerPrivateParent<Derived>::PostMessageToServiceWorker(
template <class Derived> template <class Derived>
void void
WorkerPrivateParent<Derived>::UpdateRuntimeOptions( WorkerPrivateParent<Derived>::UpdateContextOptions(
const JS::RuntimeOptions& aRuntimeOptions) const JS::ContextOptions& aContextOptions)
{ {
AssertIsOnParentThread(); AssertIsOnParentThread();
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
mJSSettings.runtimeOptions = aRuntimeOptions; mJSSettings.contextOptions = aContextOptions;
} }
RefPtr<UpdateRuntimeOptionsRunnable> runnable = RefPtr<UpdateContextOptionsRunnable> runnable =
new UpdateRuntimeOptionsRunnable(ParentAsWorkerPrivate(), aRuntimeOptions); new UpdateContextOptionsRunnable(ParentAsWorkerPrivate(), aContextOptions);
if (!runnable->Dispatch()) { if (!runnable->Dispatch()) {
NS_WARNING("Failed to update worker context options!"); NS_WARNING("Failed to update worker context options!");
} }
@ -6309,16 +6308,16 @@ WorkerPrivate::RescheduleTimeoutTimer(JSContext* aCx)
} }
void void
WorkerPrivate::UpdateRuntimeOptionsInternal( WorkerPrivate::UpdateContextOptionsInternal(
JSContext* aCx, JSContext* aCx,
const JS::RuntimeOptions& aRuntimeOptions) const JS::ContextOptions& aContextOptions)
{ {
AssertIsOnWorkerThread(); AssertIsOnWorkerThread();
JS::RuntimeOptionsRef(aCx) = aRuntimeOptions; JS::ContextOptionsRef(aCx) = aContextOptions;
for (uint32_t index = 0; index < mChildWorkers.Length(); index++) { for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
mChildWorkers[index]->UpdateRuntimeOptions(aRuntimeOptions); mChildWorkers[index]->UpdateContextOptions(aContextOptions);
} }
} }

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

@ -353,7 +353,7 @@ public:
ErrorResult& aRv); ErrorResult& aRv);
void void
UpdateRuntimeOptions(const JS::RuntimeOptions& aRuntimeOptions); UpdateContextOptions(const JS::ContextOptions& aContextOptions);
void void
UpdateLanguages(const nsTArray<nsString>& aLanguages); UpdateLanguages(const nsTArray<nsString>& aLanguages);
@ -1168,7 +1168,7 @@ public:
} }
void void
UpdateRuntimeOptionsInternal(JSContext* aCx, const JS::RuntimeOptions& aRuntimeOptions); UpdateContextOptionsInternal(JSContext* aCx, const JS::ContextOptions& aContextOptions);
void void
UpdateLanguagesInternal(const nsTArray<nsString>& aLanguages); UpdateLanguagesInternal(const nsTArray<nsString>& aLanguages);

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

@ -141,7 +141,7 @@ struct JSSettings
JSContentChromeSettings chrome; JSContentChromeSettings chrome;
JSContentChromeSettings content; JSContentChromeSettings content;
JSGCSettingsArray gcSettings; JSGCSettingsArray gcSettings;
JS::RuntimeOptions runtimeOptions; JS::ContextOptions contextOptions;
#ifdef JS_GC_ZEAL #ifdef JS_GC_ZEAL
uint8_t gcZeal; uint8_t gcZeal;

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

@ -8600,7 +8600,7 @@ js::IsAsmJSCompilationAvailable(JSContext* cx, unsigned argc, Value* vp)
CallArgs args = CallArgsFromVp(argc, vp); CallArgs args = CallArgsFromVp(argc, vp);
// See EstablishPreconditions. // See EstablishPreconditions.
bool available = HasCompilerSupport(cx) && cx->runtime()->options().asmJS(); bool available = HasCompilerSupport(cx) && cx->options().asmJS();
args.rval().set(BooleanValue(available)); args.rval().set(BooleanValue(available));
return true; return true;

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

@ -1150,7 +1150,7 @@ DecodeUnknownSections(Decoder& d)
bool bool
CompileArgs::init(ExclusiveContext* cx) CompileArgs::init(ExclusiveContext* cx)
{ {
alwaysBaseline = cx->compartment()->runtimeFromAnyThread()->options().wasmAlwaysBaseline(); alwaysBaseline = cx->options().wasmAlwaysBaseline();
return assumptions.init(SignalUsage(cx), cx->buildIdOp()); return assumptions.init(SignalUsage(cx), cx->buildIdOp());
} }

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

@ -157,7 +157,7 @@ wasm::Eval(JSContext* cx, Handle<TypedArrayObject*> code, HandleObject importObj
static bool static bool
InstantiateModule(JSContext* cx, unsigned argc, Value* vp) InstantiateModule(JSContext* cx, unsigned argc, Value* vp)
{ {
MOZ_ASSERT(cx->runtime()->options().wasm()); MOZ_ASSERT(cx->options().wasm());
CallArgs args = CallArgsFromVp(argc, vp); CallArgs args = CallArgsFromVp(argc, vp);
if (!args.get(0).isObject() || !args.get(0).toObject().is<TypedArrayObject>()) { if (!args.get(0).isObject() || !args.get(0).toObject().is<TypedArrayObject>()) {
@ -209,7 +209,7 @@ const Class js::WasmClass = {
JSObject* JSObject*
js::InitWasmClass(JSContext* cx, HandleObject global) 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)); RootedObject proto(cx, global->as<GlobalObject>().getOrCreateObjectPrototype(cx));
if (!proto) if (!proto)
@ -649,7 +649,7 @@ InitConstructor(JSContext* cx, HandleObject global, HandleObject wasm, const cha
JSObject* JSObject*
js::InitWebAssemblyClass(JSContext* cx, HandleObject global) 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)); RootedObject proto(cx, global->as<GlobalObject>().getOrCreateObjectPrototype(cx));
if (!proto) if (!proto)

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

@ -134,7 +134,7 @@ PromiseObject::create(JSContext* cx, HandleObject executor, HandleObject proto /
// control flow was for some unexpected results. Frightfully expensive, // control flow was for some unexpected results. Frightfully expensive,
// but oh well. // but oh well.
RootedObject stack(cx); RootedObject stack(cx);
if (cx->runtime()->options().asyncStack() || cx->compartment()->isDebuggee()) { if (cx->options().asyncStack() || cx->compartment()->isDebuggee()) {
if (!JS::CaptureCurrentStack(cx, &stack, 0)) if (!JS::CaptureCurrentStack(cx, &stack, 0))
return nullptr; return nullptr;
} }
@ -424,7 +424,7 @@ PromiseObject::onSettled(JSContext* cx)
{ {
Rooted<PromiseObject*> promise(cx, this); Rooted<PromiseObject*> promise(cx, this);
RootedObject stack(cx); RootedObject stack(cx);
if (cx->runtime()->options().asyncStack() || cx->compartment()->isDebuggee()) { if (cx->options().asyncStack() || cx->compartment()->isDebuggee()) {
if (!JS::CaptureCurrentStack(cx, &stack, 0)) { if (!JS::CaptureCurrentStack(cx, &stack, 0)) {
cx->clearPendingException(); cx->clearPendingException();
return; return;

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

@ -507,7 +507,7 @@ static bool
WasmIsSupported(JSContext* cx, unsigned argc, Value* vp) WasmIsSupported(JSContext* cx, unsigned argc, Value* vp)
{ {
CallArgs args = CallArgsFromVp(argc, 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; return true;
} }
@ -569,7 +569,7 @@ WasmTextToBinary(JSContext* cx, unsigned argc, Value* vp)
static bool static bool
WasmBinaryToText(JSContext* cx, unsigned argc, Value* vp) WasmBinaryToText(JSContext* cx, unsigned argc, Value* vp)
{ {
MOZ_ASSERT(cx->runtime()->options().wasm()); MOZ_ASSERT(cx->options().wasm());
CallArgs args = CallArgsFromVp(argc, vp); CallArgs args = CallArgsFromVp(argc, vp);
if (!args.get(0).isObject() || !args.get(0).toObject().is<TypedArrayObject>()) { if (!args.get(0).isObject() || !args.get(0).toObject().is<TypedArrayObject>()) {

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

@ -1772,7 +1772,7 @@ IsNativeRegExpEnabled(JSContext* cx)
#ifdef JS_CODEGEN_NONE #ifdef JS_CODEGEN_NONE
return false; return false;
#else #else
return cx->runtime()->options().nativeRegExp(); return cx->options().nativeRegExp();
#endif #endif
} }

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

@ -515,7 +515,7 @@ IsBaselineEnabled(JSContext* cx)
#ifdef JS_CODEGEN_NONE #ifdef JS_CODEGEN_NONE
return false; return false;
#else #else
return cx->runtime()->options().baseline(); return cx->options().baseline();
#endif #endif
} }

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

@ -167,8 +167,8 @@ IsIonEnabled(JSContext* cx)
#if defined(JS_CODEGEN_NONE) || defined(JS_CODEGEN_ARM64) #if defined(JS_CODEGEN_NONE) || defined(JS_CODEGEN_ARM64)
return false; return false;
#else #else
return cx->runtime()->options().ion() && return cx->options().ion() &&
cx->runtime()->options().baseline() && cx->options().baseline() &&
cx->runtime()->jitSupportsFloatingPoint; cx->runtime()->jitSupportsFloatingPoint;
#endif #endif
} }

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

@ -64,8 +64,8 @@ BEGIN_TEST(testChromeBuffer)
*/ */
{ {
// Disable the JIT because if we don't this test fails. See bug 1160414. // Disable the JIT because if we don't this test fails. See bug 1160414.
JS::RuntimeOptions oldOptions = JS::RuntimeOptionsRef(rt); JS::ContextOptions oldOptions = JS::ContextOptionsRef(cx);
JS::RuntimeOptionsRef(rt).setIon(false).setBaseline(false); JS::ContextOptionsRef(cx).setIon(false).setBaseline(false);
{ {
JSAutoCompartment ac(cx, trusted_glob); JSAutoCompartment ac(cx, trusted_glob);
const char* paramName = "x"; const char* paramName = "x";
@ -102,7 +102,7 @@ BEGIN_TEST(testChromeBuffer)
JS::RootedValue rval(cx); JS::RootedValue rval(cx);
CHECK(JS_CallFunction(cx, nullptr, fun, JS::HandleValueArray(v), &rval)); CHECK(JS_CallFunction(cx, nullptr, fun, JS::HandleValueArray(v), &rval));
CHECK(rval.toInt32() == 100); CHECK(rval.toInt32() == 100);
JS::RuntimeOptionsRef(rt) = oldOptions; JS::ContextOptionsRef(cx) = oldOptions;
} }
/* /*

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

@ -35,8 +35,8 @@ countIonScripts(JSObject* global)
bool bool
testPreserveJitCode(bool preserveJitCode, unsigned remainingIonScripts) testPreserveJitCode(bool preserveJitCode, unsigned remainingIonScripts)
{ {
rt->options().setBaseline(true); cx->options().setBaseline(true);
rt->options().setIon(true); cx->options().setIon(true);
rt->setOffthreadIonCompilationEnabled(false); rt->setOffthreadIonCompilationEnabled(false);
RootedObject global(cx, createTestGlobal(preserveJitCode)); RootedObject global(cx, createTestGlobal(preserveJitCode));

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

@ -145,7 +145,7 @@ END_TEST(testProfileStrings_isCalledWithInterpreter)
BEGIN_TEST(testProfileStrings_isCalledWithJIT) BEGIN_TEST(testProfileStrings_isCalledWithJIT)
{ {
CHECK(initialize(cx)); CHECK(initialize(cx));
JS::RuntimeOptionsRef(cx).setBaseline(true) JS::ContextOptionsRef(cx).setBaseline(true)
.setIon(true); .setIon(true);
EXEC("function g() { var p = new Prof(); p.test_fn(); }"); EXEC("function g() { var p = new Prof(); p.test_fn(); }");
@ -197,7 +197,7 @@ END_TEST(testProfileStrings_isCalledWithJIT)
BEGIN_TEST(testProfileStrings_isCalledWhenError) BEGIN_TEST(testProfileStrings_isCalledWhenError)
{ {
CHECK(initialize(cx)); CHECK(initialize(cx));
JS::RuntimeOptionsRef(cx).setBaseline(true) JS::ContextOptionsRef(cx).setBaseline(true)
.setIon(true); .setIon(true);
EXEC("function check2() { throw 'a'; }"); EXEC("function check2() { throw 'a'; }");
@ -221,7 +221,7 @@ END_TEST(testProfileStrings_isCalledWhenError)
BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly) BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
{ {
CHECK(initialize(cx)); CHECK(initialize(cx));
JS::RuntimeOptionsRef(cx).setBaseline(true) JS::ContextOptionsRef(cx).setBaseline(true)
.setIon(true); .setIon(true);
EXEC("function b(p) { p.test_fn(); }"); EXEC("function b(p) { p.test_fn(); }");

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

@ -614,16 +614,10 @@ JS_StringToVersion(const char* string)
return JSVERSION_UNKNOWN; return JSVERSION_UNKNOWN;
} }
JS_PUBLIC_API(JS::RuntimeOptions&) JS_PUBLIC_API(JS::ContextOptions&)
JS::RuntimeOptionsRef(JSRuntime* rt) JS::ContextOptionsRef(JSContext* cx)
{ {
return rt->options(); return cx->options();
}
JS_PUBLIC_API(JS::RuntimeOptions&)
JS::RuntimeOptionsRef(JSContext* cx)
{
return cx->runtime()->options();
} }
JS_PUBLIC_API(bool) JS_PUBLIC_API(bool)
@ -1749,9 +1743,9 @@ JS_GetConstructor(JSContext* cx, HandleObject proto)
} }
bool 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& JS::CompartmentCreationOptions&
@ -3884,16 +3878,16 @@ JS::CompileOptions::CompileOptions(JSContext* cx, JSVersion version)
{ {
this->version = (version != JSVERSION_UNKNOWN) ? version : cx->findVersion(); this->version = (version != JSVERSION_UNKNOWN) ? version : cx->findVersion();
strictOption = cx->runtime()->options().strictMode(); strictOption = cx->options().strictMode();
extraWarningsOption = cx->compartment()->behaviors().extraWarnings(cx); extraWarningsOption = cx->compartment()->behaviors().extraWarnings(cx);
werrorOption = cx->runtime()->options().werror(); werrorOption = cx->options().werror();
if (!cx->runtime()->options().asmJS()) if (!cx->options().asmJS())
asmJSOption = AsmJSOption::Disabled; asmJSOption = AsmJSOption::Disabled;
else if (cx->compartment()->debuggerObservesAsmJS()) else if (cx->compartment()->debuggerObservesAsmJS())
asmJSOption = AsmJSOption::DisabledByDebugger; asmJSOption = AsmJSOption::DisabledByDebugger;
else else
asmJSOption = AsmJSOption::Enabled; asmJSOption = AsmJSOption::Enabled;
throwOnAsmJSValidationFailureOption = cx->runtime()->options().throwOnAsmJSValidationFailure(); throwOnAsmJSValidationFailureOption = cx->options().throwOnAsmJSValidationFailure();
} }
enum SyntacticScopeOption { HasSyntacticScope, HasNonSyntacticScope }; enum SyntacticScopeOption { HasSyntacticScope, HasNonSyntacticScope };
@ -4903,7 +4897,7 @@ JS::AutoSetAsyncStackForNewCalls::AutoSetAsyncStackForNewCalls(
// The option determines whether we actually use the new values at this // The option determines whether we actually use the new values at this
// point. It will not affect restoring the previous values when the object // 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. // is destroyed, so if the option changes it won't cause consistency issues.
if (!cx->runtime()->options().asyncStack()) if (!cx->options().asyncStack())
return; return;
SavedFrame* asyncStack = &stack->as<SavedFrame>(); SavedFrame* asyncStack = &stack->as<SavedFrame>();
@ -6082,20 +6076,20 @@ JS_SetGlobalJitCompilerOption(JSContext* cx, JSJitCompilerOption opt, uint32_t v
break; break;
case JSJITCOMPILER_ION_ENABLE: case JSJITCOMPILER_ION_ENABLE:
if (value == 1) { if (value == 1) {
JS::RuntimeOptionsRef(rt).setIon(true); JS::ContextOptionsRef(cx).setIon(true);
JitSpew(js::jit::JitSpew_IonScripts, "Enable ion"); JitSpew(js::jit::JitSpew_IonScripts, "Enable ion");
} else if (value == 0) { } else if (value == 0) {
JS::RuntimeOptionsRef(rt).setIon(false); JS::ContextOptionsRef(cx).setIon(false);
JitSpew(js::jit::JitSpew_IonScripts, "Disable ion"); JitSpew(js::jit::JitSpew_IonScripts, "Disable ion");
} }
break; break;
case JSJITCOMPILER_BASELINE_ENABLE: case JSJITCOMPILER_BASELINE_ENABLE:
if (value == 1) { if (value == 1) {
JS::RuntimeOptionsRef(rt).setBaseline(true); JS::ContextOptionsRef(cx).setBaseline(true);
ReleaseAllJITCode(rt->defaultFreeOp()); ReleaseAllJITCode(rt->defaultFreeOp());
JitSpew(js::jit::JitSpew_BaselineScripts, "Enable baseline"); JitSpew(js::jit::JitSpew_BaselineScripts, "Enable baseline");
} else if (value == 0) { } else if (value == 0) {
JS::RuntimeOptionsRef(rt).setBaseline(false); JS::ContextOptionsRef(cx).setBaseline(false);
ReleaseAllJITCode(rt->defaultFreeOp()); ReleaseAllJITCode(rt->defaultFreeOp());
JitSpew(js::jit::JitSpew_BaselineScripts, "Disable baseline"); JitSpew(js::jit::JitSpew_BaselineScripts, "Disable baseline");
} }
@ -6148,9 +6142,9 @@ JS_GetGlobalJitCompilerOption(JSContext* cx, JSJitCompilerOption opt)
case JSJITCOMPILER_ION_FORCE_IC: case JSJITCOMPILER_ION_FORCE_IC:
return jit::JitOptions.forceInlineCaches; return jit::JitOptions.forceInlineCaches;
case JSJITCOMPILER_ION_ENABLE: case JSJITCOMPILER_ION_ENABLE:
return JS::RuntimeOptionsRef(rt).ion(); return JS::ContextOptionsRef(cx).ion();
case JSJITCOMPILER_BASELINE_ENABLE: case JSJITCOMPILER_BASELINE_ENABLE:
return JS::RuntimeOptionsRef(rt).baseline(); return JS::ContextOptionsRef(cx).baseline();
case JSJITCOMPILER_OFFTHREAD_COMPILATION_ENABLE: case JSJITCOMPILER_OFFTHREAD_COMPILATION_ENABLE:
return rt->canUseOffthreadIonCompilation(); return rt->canUseOffthreadIonCompilation();
case JSJITCOMPILER_SIGNALS_ENABLE: case JSJITCOMPILER_SIGNALS_ENABLE:

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

@ -1074,9 +1074,9 @@ JS_StringToVersion(const char* string);
namespace JS { namespace JS {
class JS_PUBLIC_API(RuntimeOptions) { class JS_PUBLIC_API(ContextOptions) {
public: public:
RuntimeOptions() ContextOptions()
: baseline_(true), : baseline_(true),
ion_(true), ion_(true),
asmJS_(true), asmJS_(true),
@ -1095,121 +1095,121 @@ class JS_PUBLIC_API(RuntimeOptions) {
} }
bool baseline() const { return baseline_; } bool baseline() const { return baseline_; }
RuntimeOptions& setBaseline(bool flag) { ContextOptions& setBaseline(bool flag) {
baseline_ = flag; baseline_ = flag;
return *this; return *this;
} }
RuntimeOptions& toggleBaseline() { ContextOptions& toggleBaseline() {
baseline_ = !baseline_; baseline_ = !baseline_;
return *this; return *this;
} }
bool ion() const { return ion_; } bool ion() const { return ion_; }
RuntimeOptions& setIon(bool flag) { ContextOptions& setIon(bool flag) {
ion_ = flag; ion_ = flag;
return *this; return *this;
} }
RuntimeOptions& toggleIon() { ContextOptions& toggleIon() {
ion_ = !ion_; ion_ = !ion_;
return *this; return *this;
} }
bool asmJS() const { return asmJS_; } bool asmJS() const { return asmJS_; }
RuntimeOptions& setAsmJS(bool flag) { ContextOptions& setAsmJS(bool flag) {
asmJS_ = flag; asmJS_ = flag;
return *this; return *this;
} }
RuntimeOptions& toggleAsmJS() { ContextOptions& toggleAsmJS() {
asmJS_ = !asmJS_; asmJS_ = !asmJS_;
return *this; return *this;
} }
bool wasm() const { return wasm_; } bool wasm() const { return wasm_; }
RuntimeOptions& setWasm(bool flag) { ContextOptions& setWasm(bool flag) {
wasm_ = flag; wasm_ = flag;
return *this; return *this;
} }
RuntimeOptions& toggleWasm() { ContextOptions& toggleWasm() {
wasm_ = !wasm_; wasm_ = !wasm_;
return *this; return *this;
} }
bool wasmAlwaysBaseline() const { return wasmAlwaysBaseline_; } bool wasmAlwaysBaseline() const { return wasmAlwaysBaseline_; }
RuntimeOptions& setWasmAlwaysBaseline(bool flag) { ContextOptions& setWasmAlwaysBaseline(bool flag) {
wasmAlwaysBaseline_ = flag; wasmAlwaysBaseline_ = flag;
return *this; return *this;
} }
RuntimeOptions& toggleWasmAlwaysBaseline() { ContextOptions& toggleWasmAlwaysBaseline() {
wasmAlwaysBaseline_ = !wasmAlwaysBaseline_; wasmAlwaysBaseline_ = !wasmAlwaysBaseline_;
return *this; return *this;
} }
bool throwOnAsmJSValidationFailure() const { return throwOnAsmJSValidationFailure_; } bool throwOnAsmJSValidationFailure() const { return throwOnAsmJSValidationFailure_; }
RuntimeOptions& setThrowOnAsmJSValidationFailure(bool flag) { ContextOptions& setThrowOnAsmJSValidationFailure(bool flag) {
throwOnAsmJSValidationFailure_ = flag; throwOnAsmJSValidationFailure_ = flag;
return *this; return *this;
} }
RuntimeOptions& toggleThrowOnAsmJSValidationFailure() { ContextOptions& toggleThrowOnAsmJSValidationFailure() {
throwOnAsmJSValidationFailure_ = !throwOnAsmJSValidationFailure_; throwOnAsmJSValidationFailure_ = !throwOnAsmJSValidationFailure_;
return *this; return *this;
} }
bool nativeRegExp() const { return nativeRegExp_; } bool nativeRegExp() const { return nativeRegExp_; }
RuntimeOptions& setNativeRegExp(bool flag) { ContextOptions& setNativeRegExp(bool flag) {
nativeRegExp_ = flag; nativeRegExp_ = flag;
return *this; return *this;
} }
bool unboxedArrays() const { return unboxedArrays_; } bool unboxedArrays() const { return unboxedArrays_; }
RuntimeOptions& setUnboxedArrays(bool flag) { ContextOptions& setUnboxedArrays(bool flag) {
unboxedArrays_ = flag; unboxedArrays_ = flag;
return *this; return *this;
} }
bool asyncStack() const { return asyncStack_; } bool asyncStack() const { return asyncStack_; }
RuntimeOptions& setAsyncStack(bool flag) { ContextOptions& setAsyncStack(bool flag) {
asyncStack_ = flag; asyncStack_ = flag;
return *this; return *this;
} }
bool throwOnDebuggeeWouldRun() const { return throwOnDebuggeeWouldRun_; } bool throwOnDebuggeeWouldRun() const { return throwOnDebuggeeWouldRun_; }
RuntimeOptions& setThrowOnDebuggeeWouldRun(bool flag) { ContextOptions& setThrowOnDebuggeeWouldRun(bool flag) {
throwOnDebuggeeWouldRun_ = flag; throwOnDebuggeeWouldRun_ = flag;
return *this; return *this;
} }
bool dumpStackOnDebuggeeWouldRun() const { return dumpStackOnDebuggeeWouldRun_; } bool dumpStackOnDebuggeeWouldRun() const { return dumpStackOnDebuggeeWouldRun_; }
RuntimeOptions& setDumpStackOnDebuggeeWouldRun(bool flag) { ContextOptions& setDumpStackOnDebuggeeWouldRun(bool flag) {
dumpStackOnDebuggeeWouldRun_ = flag; dumpStackOnDebuggeeWouldRun_ = flag;
return *this; return *this;
} }
bool werror() const { return werror_; } bool werror() const { return werror_; }
RuntimeOptions& setWerror(bool flag) { ContextOptions& setWerror(bool flag) {
werror_ = flag; werror_ = flag;
return *this; return *this;
} }
RuntimeOptions& toggleWerror() { ContextOptions& toggleWerror() {
werror_ = !werror_; werror_ = !werror_;
return *this; return *this;
} }
bool strictMode() const { return strictMode_; } bool strictMode() const { return strictMode_; }
RuntimeOptions& setStrictMode(bool flag) { ContextOptions& setStrictMode(bool flag) {
strictMode_ = flag; strictMode_ = flag;
return *this; return *this;
} }
RuntimeOptions& toggleStrictMode() { ContextOptions& toggleStrictMode() {
strictMode_ = !strictMode_; strictMode_ = !strictMode_;
return *this; return *this;
} }
bool extraWarnings() const { return extraWarnings_; } bool extraWarnings() const { return extraWarnings_; }
RuntimeOptions& setExtraWarnings(bool flag) { ContextOptions& setExtraWarnings(bool flag) {
extraWarnings_ = flag; extraWarnings_ = flag;
return *this; return *this;
} }
RuntimeOptions& toggleExtraWarnings() { ContextOptions& toggleExtraWarnings() {
extraWarnings_ = !extraWarnings_; extraWarnings_ = !extraWarnings_;
return *this; return *this;
} }
@ -1231,11 +1231,8 @@ class JS_PUBLIC_API(RuntimeOptions) {
bool extraWarnings_ : 1; bool extraWarnings_ : 1;
}; };
JS_PUBLIC_API(RuntimeOptions&) JS_PUBLIC_API(ContextOptions&)
RuntimeOptionsRef(JSRuntime* rt); ContextOptionsRef(JSContext* cx);
JS_PUBLIC_API(RuntimeOptions&)
RuntimeOptionsRef(JSContext* cx);
/** /**
* Initialize the runtime's self-hosted code. Embeddings should call this * Initialize the runtime's self-hosted code. Embeddings should call this
@ -2309,7 +2306,7 @@ class JS_PUBLIC_API(CompartmentBehaviors)
return *this; return *this;
} }
bool extraWarnings(JSRuntime* rt) const; bool extraWarnings(JSContext* cx) const;
Override& extraWarningsOverride() { return extraWarningsOverride_; } Override& extraWarningsOverride() { return extraWarningsOverride_; }
bool getSingletonsAsTemplates() const { 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 * 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 * 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 * 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 * 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. * 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. */ /* 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; *flags &= ~JSREPORT_WARNING;
return false; return false;
@ -845,10 +845,12 @@ js::GetErrorMessage(void* userRef, const unsigned errorNumber)
return nullptr; return nullptr;
} }
ExclusiveContext::ExclusiveContext(JSRuntime* rt, PerThreadData* pt, ContextKind kind) ExclusiveContext::ExclusiveContext(JSRuntime* rt, PerThreadData* pt, ContextKind kind,
const JS::ContextOptions& options)
: ContextFriendFields(rt), : ContextFriendFields(rt),
helperThread_(nullptr), helperThread_(nullptr),
contextKind_(kind), contextKind_(kind),
options_(options),
perThreadData(pt), perThreadData(pt),
arenas_(nullptr), arenas_(nullptr),
enterCompartmentDepth_(0) enterCompartmentDepth_(0)
@ -871,7 +873,7 @@ ExclusiveContext::recoverFromOutOfMemory()
} }
JSContext::JSContext(JSRuntime* parentRuntime) JSContext::JSContext(JSRuntime* parentRuntime)
: ExclusiveContext(this, &this->JSRuntime::mainThread, Context_JS), : ExclusiveContext(this, &this->JSRuntime::mainThread, Context_JS, JS::ContextOptions()),
JSRuntime(parentRuntime), JSRuntime(parentRuntime),
throwing(false), throwing(false),
unwrappedException_(this), unwrappedException_(this),

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

@ -117,10 +117,16 @@ class ExclusiveContext : public ContextFriendFields,
private: private:
ContextKind contextKind_; ContextKind contextKind_;
protected:
// Background threads get a read-only copy of the main thread's
// ContextOptions.
JS::ContextOptions options_;
public: public:
PerThreadData* perThreadData; PerThreadData* perThreadData;
ExclusiveContext(JSRuntime* rt, PerThreadData* pt, ContextKind kind); ExclusiveContext(JSRuntime* rt, PerThreadData* pt, ContextKind kind,
const JS::ContextOptions& options);
bool isJSContext() const { bool isJSContext() const {
return contextKind_ == Context_JS; return contextKind_ == Context_JS;
@ -153,6 +159,10 @@ class ExclusiveContext : public ContextFriendFields,
return isJSContext(); return isJSContext();
} }
const JS::ContextOptions& options() const {
return options_;
}
protected: protected:
js::gc::ArenaLists* arenas_; js::gc::ArenaLists* arenas_;
@ -385,6 +395,10 @@ struct JSContext : public js::ExclusiveContext,
*/ */
JSVersion findVersion() const; JSVersion findVersion() const;
JS::ContextOptions& options() {
return options_;
}
js::LifoAlloc& tempLifoAlloc() { return runtime()->tempLifoAlloc; } js::LifoAlloc& tempLifoAlloc() { return runtime()->tempLifoAlloc; }
unsigned outstandingRequests;/* number of JS_BeginRequest calls unsigned outstandingRequests;/* number of JS_BeginRequest calls

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

@ -550,7 +550,7 @@ js::ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp,
if (exnType == JSEXN_WARN) { if (exnType == JSEXN_WARN) {
// werror must be enabled, so we use JSEXN_ERR. // werror must be enabled, so we use JSEXN_ERR.
MOZ_ASSERT(cx->runtime()->options().werror()); MOZ_ASSERT(cx->options().werror());
exnType = JSEXN_ERR; exnType = JSEXN_ERR;
} }

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

@ -1021,7 +1021,7 @@ Options(JSContext* cx, unsigned argc, Value* vp)
{ {
CallArgs args = CallArgsFromVp(argc, 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++) { for (unsigned i = 0; i < args.length(); i++) {
JSString* str = JS::ToString(cx, args[i]); JSString* str = JS::ToString(cx, args[i]);
if (!str) if (!str)
@ -1033,13 +1033,13 @@ Options(JSContext* cx, unsigned argc, Value* vp)
return false; return false;
if (strcmp(opt.ptr(), "strict") == 0) if (strcmp(opt.ptr(), "strict") == 0)
JS::RuntimeOptionsRef(cx).toggleExtraWarnings(); JS::ContextOptionsRef(cx).toggleExtraWarnings();
else if (strcmp(opt.ptr(), "werror") == 0) 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) 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) else if (strcmp(opt.ptr(), "strict_mode") == 0)
JS::RuntimeOptionsRef(cx).toggleStrictMode(); JS::ContextOptionsRef(cx).toggleStrictMode();
else { else {
JS_ReportError(cx, JS_ReportError(cx,
"unknown option name '%s'." "unknown option name '%s'."
@ -1052,19 +1052,19 @@ Options(JSContext* cx, unsigned argc, Value* vp)
char* names = strdup(""); char* names = strdup("");
bool found = false; bool found = false;
if (names && oldRuntimeOptions.extraWarnings()) { if (names && oldContextOptions.extraWarnings()) {
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "strict"); names = JS_sprintf_append(names, "%s%s", found ? "," : "", "strict");
found = true; found = true;
} }
if (names && oldRuntimeOptions.werror()) { if (names && oldContextOptions.werror()) {
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "werror"); names = JS_sprintf_append(names, "%s%s", found ? "," : "", "werror");
found = true; found = true;
} }
if (names && oldRuntimeOptions.throwOnAsmJSValidationFailure()) { if (names && oldContextOptions.throwOnAsmJSValidationFailure()) {
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "throw_on_asmjs_validation_failure"); names = JS_sprintf_append(names, "%s%s", found ? "," : "", "throw_on_asmjs_validation_failure");
found = true; found = true;
} }
if (names && oldRuntimeOptions.strictMode()) { if (names && oldContextOptions.strictMode()) {
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "strict_mode"); names = JS_sprintf_append(names, "%s%s", found ? "," : "", "strict_mode");
found = true; found = true;
} }
@ -2922,7 +2922,7 @@ struct WorkerInput
} }
}; };
static void SetWorkerRuntimeOptions(JSRuntime* rt); static void SetWorkerContextOptions(JSContext* cx);
static void static void
WorkerMain(void* arg) WorkerMain(void* arg)
@ -2949,7 +2949,7 @@ WorkerMain(void* arg)
JS_SetFutexCanWait(cx); JS_SetFutexCanWait(cx);
JS::SetWarningReporter(cx, WarningReporter); JS::SetWarningReporter(cx, WarningReporter);
JS_InitDestroyPrincipalsCallback(cx, ShellPrincipals::destroy); JS_InitDestroyPrincipalsCallback(cx, ShellPrincipals::destroy);
SetWorkerRuntimeOptions(rt); SetWorkerContextOptions(cx);
if (!JS::InitSelfHostedCode(cx)) { if (!JS::InitSelfHostedCode(cx)) {
JS_DestroyRuntime(rt); JS_DestroyRuntime(rt);
@ -6647,7 +6647,7 @@ ProcessArgs(JSContext* cx, OptionParser* op)
ShellRuntime* sr = GetShellRuntime(cx); ShellRuntime* sr = GetShellRuntime(cx);
if (op->getBoolOption('s')) if (op->getBoolOption('s'))
JS::RuntimeOptionsRef(cx).toggleExtraWarnings(); JS::ContextOptionsRef(cx).toggleExtraWarnings();
/* |scriptArgs| gets bound on the global before any code is run. */ /* |scriptArgs| gets bound on the global before any code is run. */
if (!BindScriptArgs(cx, op)) if (!BindScriptArgs(cx, op))
@ -6720,7 +6720,7 @@ ProcessArgs(JSContext* cx, OptionParser* op)
} }
static bool static bool
SetRuntimeOptions(JSRuntime* rt, const OptionParser& op) SetContextOptions(JSContext* cx, const OptionParser& op)
{ {
enableBaseline = !op.getBoolOption("no-baseline"); enableBaseline = !op.getBoolOption("no-baseline");
enableIon = !op.getBoolOption("no-ion"); enableIon = !op.getBoolOption("no-ion");
@ -6729,7 +6729,7 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
enableUnboxedArrays = op.getBoolOption("unboxed-arrays"); enableUnboxedArrays = op.getBoolOption("unboxed-arrays");
enableWasmAlwaysBaseline = op.getBoolOption("wasm-always-baseline"); enableWasmAlwaysBaseline = op.getBoolOption("wasm-always-baseline");
JS::RuntimeOptionsRef(rt).setBaseline(enableBaseline) JS::ContextOptionsRef(cx).setBaseline(enableBaseline)
.setIon(enableIon) .setIon(enableIon)
.setAsmJS(enableAsmJS) .setAsmJS(enableAsmJS)
.setWasm(true) .setWasm(true)
@ -6912,7 +6912,7 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
else if (strcmp(str, "on") != 0) else if (strcmp(str, "on") != 0)
return OptionFailure("ion-offthread-compile", str); return OptionFailure("ion-offthread-compile", str);
} }
rt->setOffthreadIonCompilationEnabled(offthreadCompilation); cx->setOffthreadIonCompilationEnabled(offthreadCompilation);
if (op.getStringOption("ion-parallel-compile")) { if (op.getStringOption("ion-parallel-compile")) {
fprintf(stderr, "--ion-parallel-compile is deprecated. Please use --ion-offthread-compile instead.\n"); 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'); printTiming = op.getBoolOption('b');
enableCodeCoverage = op.getBoolOption("code-coverage"); enableCodeCoverage = op.getBoolOption("code-coverage");
enableDisassemblyDumps = op.getBoolOption('D'); enableDisassemblyDumps = op.getBoolOption('D');
rt->profilingScripts = enableCodeCoverage || enableDisassemblyDumps; cx->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
jsCacheDir = op.getStringOption("js-cache"); jsCacheDir = op.getStringOption("js-cache");
if (jsCacheDir) { if (jsCacheDir) {
if (!op.getBoolOption("no-js-cache-per-process")) if (!op.getBoolOption("no-js-cache-per-process"))
jsCacheDir = JS_smprintf("%s/%u", jsCacheDir, (unsigned)getpid()); jsCacheDir = JS_smprintf("%s/%u", jsCacheDir, (unsigned)getpid());
else else
jsCacheDir = JS_strdup(rt, jsCacheDir); jsCacheDir = JS_strdup(cx, jsCacheDir);
if (!jsCacheDir) if (!jsCacheDir)
return false; return false;
jsCacheAsmJSPath = JS_smprintf("%s/asmjs.cache", jsCacheDir); jsCacheAsmJSPath = JS_smprintf("%s/asmjs.cache", jsCacheDir);
@ -6984,10 +6984,10 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
#ifdef JS_GC_ZEAL #ifdef JS_GC_ZEAL
const char* zealStr = op.getStringOption("gc-zeal"); const char* zealStr = op.getStringOption("gc-zeal");
if (zealStr) { if (zealStr) {
if (!rt->gc.parseAndSetZeal(zealStr)) if (!cx->gc.parseAndSetZeal(zealStr))
return false; return false;
uint32_t nextScheduled; uint32_t nextScheduled;
rt->gc.getZealBits(&gZealBits, &gZealFrequency, &nextScheduled); cx->gc.getZealBits(&gZealBits, &gZealFrequency, &nextScheduled);
} }
#endif #endif
@ -6995,30 +6995,30 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
} }
static void static void
SetWorkerRuntimeOptions(JSRuntime* rt) SetWorkerContextOptions(JSContext* cx)
{ {
// Copy option values from the main thread. // Copy option values from the main thread.
JS::RuntimeOptionsRef(rt).setBaseline(enableBaseline) JS::ContextOptionsRef(cx).setBaseline(enableBaseline)
.setIon(enableIon) .setIon(enableIon)
.setAsmJS(enableAsmJS) .setAsmJS(enableAsmJS)
.setWasm(true) .setWasm(true)
.setWasmAlwaysBaseline(enableWasmAlwaysBaseline) .setWasmAlwaysBaseline(enableWasmAlwaysBaseline)
.setNativeRegExp(enableNativeRegExp) .setNativeRegExp(enableNativeRegExp)
.setUnboxedArrays(enableUnboxedArrays); .setUnboxedArrays(enableUnboxedArrays);
rt->setOffthreadIonCompilationEnabled(offthreadCompilation); cx->setOffthreadIonCompilationEnabled(offthreadCompilation);
rt->profilingScripts = enableCodeCoverage || enableDisassemblyDumps; cx->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
#ifdef JS_GC_ZEAL #ifdef JS_GC_ZEAL
if (gZealBits && gZealFrequency) { if (gZealBits && gZealFrequency) {
#define ZEAL_MODE(_, value) \ #define ZEAL_MODE(_, value) \
if (gZealBits & (1 << value)) \ if (gZealBits & (1 << value)) \
rt->gc.setZeal(value, gZealFrequency); cx->gc.setZeal(value, gZealFrequency);
JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE) JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE)
#undef ZEAL_MODE #undef ZEAL_MODE
} }
#endif #endif
JS_SetNativeStackQuota(JS_GetContext(rt), gMaxStackSize); JS_SetNativeStackQuota(cx, gMaxStackSize);
} }
static int static int
@ -7386,7 +7386,7 @@ main(int argc, char** argv, char** envp)
// Waiting is allowed on the shell's main thread, for now. // Waiting is allowed on the shell's main thread, for now.
JS_SetFutexCanWait(cx); JS_SetFutexCanWait(cx);
JS::SetWarningReporter(cx, WarningReporter); JS::SetWarningReporter(cx, WarningReporter);
if (!SetRuntimeOptions(rt, op)) if (!SetContextOptions(cx, op))
return 1; return 1;
JS_SetGCParameter(cx, JSGC_MAX_BYTES, 0xffffffff); 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. // warning or an error if there is a lock that locks it.
static bool reportIfFoundInStack(JSContext* cx, HandleScript script) { static bool reportIfFoundInStack(JSContext* cx, HandleScript script) {
if (EnterDebuggeeNoExecute* nx = findInStack(cx)) { if (EnterDebuggeeNoExecute* nx = findInStack(cx)) {
bool warning = !cx->runtime()->options().throwOnDebuggeeWouldRun(); bool warning = !cx->options().throwOnDebuggeeWouldRun();
if (!warning || !nx->reported_) { if (!warning || !nx->reported_) {
AutoCompartment ac(cx, nx->debugger().toJSObject()); AutoCompartment ac(cx, nx->debugger().toJSObject());
nx->reported_ = true; nx->reported_ = true;
if (cx->runtime()->options().dumpStackOnDebuggeeWouldRun()) { if (cx->options().dumpStackOnDebuggeeWouldRun()) {
fprintf(stdout, "Dumping stack for DebuggeeWouldRun:\n"); fprintf(stdout, "Dumping stack for DebuggeeWouldRun:\n");
DumpBacktrace(cx); DumpBacktrace(cx);
} }

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

@ -101,7 +101,7 @@ js::GlobalObject::getTypedObjectModule() const {
GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key) GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key)
{ {
if (key == JSProto_Wasm || key == JSProto_WebAssembly) if (key == JSProto_Wasm || key == JSProto_WebAssembly)
return !cx->runtime()->options().wasm(); return !cx->options().wasm();
#ifdef ENABLE_SHARED_ARRAY_BUFFER #ifdef ENABLE_SHARED_ARRAY_BUFFER
// Return true if the given constructor has been disabled at run-time. // 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( ScopedJSDeletePtr<ExclusiveContext> helpercx(
cx->new_<ExclusiveContext>(cx->runtime(), (PerThreadData*) nullptr, cx->new_<ExclusiveContext>(cx->runtime(), (PerThreadData*) nullptr,
ExclusiveContext::Context_Exclusive)); ExclusiveContext::Context_Exclusive, cx->options()));
if (!helpercx) if (!helpercx)
return false; return false;
@ -521,7 +521,7 @@ js::StartOffThreadParseModule(JSContext* cx, const ReadOnlyCompileOptions& optio
ScopedJSDeletePtr<ExclusiveContext> helpercx( ScopedJSDeletePtr<ExclusiveContext> helpercx(
cx->new_<ExclusiveContext>(cx->runtime(), (PerThreadData*) nullptr, cx->new_<ExclusiveContext>(cx->runtime(), (PerThreadData*) nullptr,
ExclusiveContext::Context_Exclusive)); ExclusiveContext::Context_Exclusive, cx->options()));
if (!helpercx) if (!helpercx)
return false; return false;

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

@ -1471,7 +1471,7 @@ ObjectGroup::allocationSiteGroup(JSContext* cx, JSScript* scriptArg, jsbytecode*
if (kind == JSProto_Array && if (kind == JSProto_Array &&
(JSOp(*pc) == JSOP_NEWARRAY || IsCallPC(pc)) && (JSOp(*pc) == JSOP_NEWARRAY || IsCallPC(pc)) &&
cx->runtime()->options().unboxedArrays()) cx->options().unboxedArrays())
{ {
PreliminaryObjectArrayWithTemplate* preliminaryObjects = PreliminaryObjectArrayWithTemplate* preliminaryObjects =
cx->new_<PreliminaryObjectArrayWithTemplate>(nullptr); cx->new_<PreliminaryObjectArrayWithTemplate>(nullptr);

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

@ -1247,7 +1247,6 @@ struct JSRuntime : public JS::shadow::Runtime,
void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::RuntimeSizes* runtime); void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::RuntimeSizes* runtime);
private: private:
JS::RuntimeOptions options_;
const js::Class* windowProxyClass_; const js::Class* windowProxyClass_;
// Settings for how helper threads can be used. // Settings for how helper threads can be used.
@ -1279,13 +1278,6 @@ struct JSRuntime : public JS::shadow::Runtime,
autoWritableJitCodeActive_ = b; autoWritableJitCodeActive_ = b;
} }
const JS::RuntimeOptions& options() const {
return options_;
}
JS::RuntimeOptions& options() {
return options_;
}
const js::Class* maybeWindowProxyClass() const { const js::Class* maybeWindowProxyClass() const {
return windowProxyClass_; return windowProxyClass_;
} }

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

@ -1930,7 +1930,7 @@ js::TryConvertToUnboxedLayout(ExclusiveContext* cx, Shape* templateShape,
if (isArray) { if (isArray) {
#ifdef NIGHTLY_BUILD #ifdef NIGHTLY_BUILD
if (!getenv("JS_OPTION_USE_UNBOXED_ARRAYS")) { if (!getenv("JS_OPTION_USE_UNBOXED_ARRAYS")) {
if (!group->runtimeFromAnyThread()->options().unboxedArrays()) if (!cx->options().unboxedArrays())
return true; return true;
} }
#else #else

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

@ -3000,27 +3000,12 @@ nsXPCComponents_Utils::Dispatch(HandleValue runnableArg, HandleValue scope,
return NS_OK; \ return NS_OK; \
} }
#define GENERATE_JSRUNTIMEOPTION_GETTER_SETTER(_attr, _getter, _setter) \ GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Strict, extraWarnings, setExtraWarnings)
NS_IMETHODIMP \ GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Werror, werror, setWerror)
nsXPCComponents_Utils::Get## _attr(JSContext* cx, bool* aValue) \ GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Strict_mode, strictMode, setStrictMode)
{ \ GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Ion, ion, setIon)
*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)
#undef GENERATE_JSCONTEXTOPTION_GETTER_SETTER #undef GENERATE_JSCONTEXTOPTION_GETTER_SETTER
#undef GENERATE_JSRUNTIMEOPTION_GETTER_SETTER
NS_IMETHODIMP NS_IMETHODIMP
nsXPCComponents_Utils::SetGCZeal(int32_t aValue, JSContext* cx) nsXPCComponents_Utils::SetGCZeal(int32_t aValue, JSContext* cx)

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

@ -1561,7 +1561,6 @@ static void
ReloadPrefsCallback(const char* pref, void* data) ReloadPrefsCallback(const char* pref, void* data)
{ {
XPCJSRuntime* runtime = reinterpret_cast<XPCJSRuntime*>(data); XPCJSRuntime* runtime = reinterpret_cast<XPCJSRuntime*>(data);
JSRuntime* rt = runtime->Runtime();
JSContext* cx = runtime->Context(); JSContext* cx = runtime->Context();
bool safeMode = false; bool safeMode = false;
@ -1616,7 +1615,7 @@ ReloadPrefsCallback(const char* pref, void* data)
} }
#endif // JS_GC_ZEAL #endif // JS_GC_ZEAL
JS::RuntimeOptionsRef(rt).setBaseline(useBaseline) JS::ContextOptionsRef(cx).setBaseline(useBaseline)
.setIon(useIon) .setIon(useIon)
.setAsmJS(useAsmJS) .setAsmJS(useAsmJS)
.setWasm(useWasm) .setWasm(useWasm)

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

@ -485,7 +485,7 @@ static bool
Options(JSContext* cx, unsigned argc, Value* vp) Options(JSContext* cx, unsigned argc, Value* vp)
{ {
JS::CallArgs args = CallArgsFromVp(argc, vp); JS::CallArgs args = CallArgsFromVp(argc, vp);
RuntimeOptions oldRuntimeOptions = RuntimeOptionsRef(cx); ContextOptions oldContextOptions = ContextOptionsRef(cx);
for (unsigned i = 0; i < args.length(); ++i) { for (unsigned i = 0; i < args.length(); ++i) {
JSString* str = ToString(cx, args[i]); JSString* str = ToString(cx, args[i]);
@ -497,11 +497,11 @@ Options(JSContext* cx, unsigned argc, Value* vp)
return false; return false;
if (strcmp(opt.ptr(), "strict") == 0) if (strcmp(opt.ptr(), "strict") == 0)
RuntimeOptionsRef(cx).toggleExtraWarnings(); ContextOptionsRef(cx).toggleExtraWarnings();
else if (strcmp(opt.ptr(), "werror") == 0) else if (strcmp(opt.ptr(), "werror") == 0)
RuntimeOptionsRef(cx).toggleWerror(); ContextOptionsRef(cx).toggleWerror();
else if (strcmp(opt.ptr(), "strict_mode") == 0) else if (strcmp(opt.ptr(), "strict_mode") == 0)
RuntimeOptionsRef(cx).toggleStrictMode(); ContextOptionsRef(cx).toggleStrictMode();
else { else {
JS_ReportError(cx, "unknown option name '%s'. The valid names are " JS_ReportError(cx, "unknown option name '%s'. The valid names are "
"strict, werror, and strict_mode.", opt.ptr()); "strict, werror, and strict_mode.", opt.ptr());
@ -510,21 +510,21 @@ Options(JSContext* cx, unsigned argc, Value* vp)
} }
char* names = nullptr; char* names = nullptr;
if (oldRuntimeOptions.extraWarnings()) { if (oldContextOptions.extraWarnings()) {
names = JS_sprintf_append(names, "%s", "strict"); names = JS_sprintf_append(names, "%s", "strict");
if (!names) { if (!names) {
JS_ReportOutOfMemory(cx); JS_ReportOutOfMemory(cx);
return false; return false;
} }
} }
if (oldRuntimeOptions.werror()) { if (oldContextOptions.werror()) {
names = JS_sprintf_append(names, "%s%s", names ? "," : "", "werror"); names = JS_sprintf_append(names, "%s%s", names ? "," : "", "werror");
if (!names) { if (!names) {
JS_ReportOutOfMemory(cx); JS_ReportOutOfMemory(cx);
return false; return false;
} }
} }
if (names && oldRuntimeOptions.strictMode()) { if (names && oldContextOptions.strictMode()) {
names = JS_sprintf_append(names, "%s%s", names ? "," : "", "strict_mode"); names = JS_sprintf_append(names, "%s%s", names ? "," : "", "strict_mode");
if (!names) { if (!names) {
JS_ReportOutOfMemory(cx); JS_ReportOutOfMemory(cx);
@ -961,13 +961,13 @@ ProcessArgsForCompartment(JSContext* cx, char** argv, int argc)
return; return;
break; break;
case 'S': case 'S':
RuntimeOptionsRef(cx).toggleWerror(); ContextOptionsRef(cx).toggleWerror();
MOZ_FALLTHROUGH; // because -S implies -s MOZ_FALLTHROUGH; // because -S implies -s
case 's': case 's':
RuntimeOptionsRef(cx).toggleExtraWarnings(); ContextOptionsRef(cx).toggleExtraWarnings();
break; break;
case 'I': case 'I':
RuntimeOptionsRef(cx).toggleIon() ContextOptionsRef(cx).toggleIon()
.toggleAsmJS() .toggleAsmJS()
.toggleWasm(); .toggleWasm();
break; break;