diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 79d58d2f5ee8..ff1461c73795 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -1640,7 +1640,7 @@ JS_SetNativeStackQuota(JSContext* cx, size_t systemCodeStackSize, size_t trusted SetNativeStackQuotaAndLimit(cx, JS::StackForTrustedScript, trustedScriptStackSize); SetNativeStackQuotaAndLimit(cx, JS::StackForUntrustedScript, untrustedScriptStackSize); - if (cx->isCooperativelyScheduled()) + if (cx->isMainThreadContext()) cx->initJitStackLimit(); } diff --git a/js/src/threading/ProtectedData.cpp b/js/src/threading/ProtectedData.cpp index 69ed663b609e..b5baf9347379 100644 --- a/js/src/threading/ProtectedData.cpp +++ b/js/src/threading/ProtectedData.cpp @@ -38,14 +38,9 @@ CheckThreadLocal::check() const { JSContext* cx = TlsContext.get(); MOZ_ASSERT(cx); - - // As for CheckZone, in a cooperatively scheduled runtime the active - // thread is permitted access to thread local state for other suspended - // threads in the same runtime. - if (cx->isCooperativelyScheduled()) - MOZ_ASSERT(CurrentThreadCanAccessRuntime(cx->runtime())); - else - MOZ_ASSERT(id == ThisThread::GetId()); + MOZ_ASSERT_IF(cx->isMainThreadContext(), + CurrentThreadCanAccessRuntime(cx->runtime())); + MOZ_ASSERT(id == ThisThread::GetId()); } template diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index 01fed75af133..b9dfdc8ef727 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -2224,7 +2224,7 @@ HelperThread::threadLoop() JSContext cx(nullptr, JS::ContextOptions()); { AutoEnterOOMUnsafeRegion oomUnsafe; - if (!cx.init(ContextKind::Background)) + if (!cx.init(ContextKind::HelperThread)) oomUnsafe.crash("HelperThread cx.init()"); } cx.setHelperThread(this); diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp index 6e3f88dfaf29..1d9b1160db8c 100644 --- a/js/src/vm/JSContext.cpp +++ b/js/src/vm/JSContext.cpp @@ -100,7 +100,7 @@ bool JSContext::init(ContextKind kind) { // Skip most of the initialization if this thread will not be running JS. - if (kind == ContextKind::Cooperative) { + if (kind == ContextKind::MainThread) { if (!regexpStack.ref().init()) return false; @@ -153,7 +153,7 @@ js::NewContext(uint32_t maxBytes, uint32_t maxNurseryBytes, JSRuntime* parentRun return nullptr; } - if (!cx->init(ContextKind::Cooperative)) { + if (!cx->init(ContextKind::MainThread)) { runtime->destroyRuntime(); js_delete(cx); js_delete(runtime); @@ -1220,7 +1220,7 @@ JSContext::alreadyReportedError() JSContext::JSContext(JSRuntime* runtime, const JS::ContextOptions& options) : runtime_(runtime), - kind_(ContextKind::Background), + kind_(ContextKind::HelperThread), helperThread_(nullptr), options_(options), arenas_(nullptr), @@ -1318,7 +1318,7 @@ JSContext::~JSContext() { // Clear the ContextKind first, so that ProtectedData checks will allow us to // destroy this context even if the runtime is already gone. - kind_ = ContextKind::Background; + kind_ = ContextKind::HelperThread; /* Free the stuff hanging off of cx. */ MOZ_ASSERT(!resolvingList); diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h index da50d3af015a..2b6870959c12 100644 --- a/js/src/vm/JSContext.h +++ b/js/src/vm/JSContext.h @@ -80,8 +80,11 @@ extern MOZ_THREAD_LOCAL(JSContext*) TlsContext; enum class ContextKind { - Cooperative, - Background + // Context for the main thread of a JSRuntime. + MainThread, + + // Context for a helper thread. + HelperThread }; #ifdef DEBUG @@ -122,7 +125,7 @@ struct JSContext : public JS::RootingContext, // currently operating on. void setRuntime(JSRuntime* rt); - bool isCooperativelyScheduled() const { return kind_ == js::ContextKind::Cooperative; } + bool isMainThreadContext() const { return kind_ == js::ContextKind::MainThread; } inline js::gc::ArenaLists* arenas() const { return arenas_; }