зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1452982 part 12 - Clean up ContextKind and CheckThreadLocal. r=jonco
This commit is contained in:
Родитель
050bda2db5
Коммит
3635c4e66f
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <AllowedHelperThread Helper>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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_; }
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче