Bug 1559821 - 2: switch parse task checks for new parse task pointer, cleanup instances of HelperThread() leftover r=jonco

Removed helperthread_ and its associated functions since they are no longer used & cleaned up a few missed checks that used it. Changed helperThread()->parseTask() checks to look for cx->parseTask() instead.

Differential Revision: https://phabricator.services.mozilla.com/D35491

--HG--
extra : moz-landing-system : lando
This commit is contained in:
kriswright 2019-06-20 23:08:59 +00:00
Родитель e1dfee9d67
Коммит c3a19591ea
4 изменённых файлов: 16 добавлений и 37 удалений

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

@ -95,7 +95,7 @@ class MOZ_RAII AutoAssertReportedException {
return;
}
ParseTask* task = cx_->helperThread()->parseTask();
ParseTask* task = cx_->parseTask();
MOZ_ASSERT(task->outOfMemory || task->overRecursed ||
!task->errors.empty());
}

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

@ -1070,7 +1070,7 @@ void js::EnqueuePendingParseTasksAfterGC(JSRuntime* rt) {
#ifdef DEBUG
bool js::CurrentThreadIsParseThread() {
JSContext* cx = TlsContext.get();
return cx->helperThread() && cx->helperThread()->parseTask();
return cx->isHelperThreadContext() && cx->parseTask();
}
#endif
@ -1771,7 +1771,7 @@ ParseTask* GlobalHelperThreadState::removeFinishedParseTask(
UniquePtr<ParseTask> GlobalHelperThreadState::finishParseTaskCommon(
JSContext* cx, ParseTaskKind kind, JS::OffThreadToken* token) {
MOZ_ASSERT(!cx->helperThread());
MOZ_ASSERT(!cx->isHelperThreadContext());
MOZ_ASSERT(cx->realm());
Rooted<UniquePtr<ParseTask>> parseTask(cx,
@ -2169,30 +2169,28 @@ bool JSContext::addPendingCompileError(js::CompileError** error) {
if (!errorPtr) {
return false;
}
ParseTask* parseTask = helperThread()->parseTask();
if (!parseTask->errors.append(std::move(errorPtr))) {
if (!parseTask_->errors.append(std::move(errorPtr))) {
ReportOutOfMemory(this);
return false;
}
*error = parseTask->errors.back().get();
*error = parseTask_->errors.back().get();
return true;
}
bool JSContext::isCompileErrorPending() const {
ParseTask* parseTask = helperThread()->parseTask();
return parseTask->errors.length() > 0;
return parseTask_->errors.length() > 0;
}
void JSContext::addPendingOverRecursed() {
if (helperThread()->parseTask()) {
helperThread()->parseTask()->overRecursed = true;
if (parseTask_) {
parseTask_->overRecursed = true;
}
}
void JSContext::addPendingOutOfMemory() {
// Keep in sync with recoverFromOutOfMemory.
if (helperThread()->parseTask()) {
helperThread()->parseTask()->outOfMemory = true;
if (parseTask_) {
parseTask_->outOfMemory = true;
}
}
@ -2271,7 +2269,7 @@ bool js::EnqueueOffThreadCompression(JSContext* cx,
auto& pending = HelperThreadState().compressionPendingList(lock);
if (!pending.append(std::move(task))) {
if (!cx->helperThread()) {
if (!cx->isHelperThreadContext()) {
ReportOutOfMemory(cx);
}
return false;
@ -2437,18 +2435,6 @@ void GlobalHelperThreadState::trace(JSTracer* trc) {
}
}
void JSContext::setHelperThread(HelperThread* thread) {
if (helperThread_) {
nurserySuppressions_--;
}
helperThread_ = thread;
if (helperThread_) {
nurserySuppressions_++;
}
}
// Definition of helper thread tasks.
//
// Priority is determined by the order they're listed here.
@ -2504,7 +2490,7 @@ void HelperThread::threadLoop() {
oomUnsafe.crash("HelperThread cx.init()");
}
}
cx.setHelperThread(this);
gc::AutoSuppressNurseryCellAlloc noNurseryAlloc(&cx);
JS_SetNativeStackQuota(&cx, HELPER_STACK_QUOTA);
while (!terminate) {

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

@ -1002,9 +1002,9 @@ JS_FRIEND_API const JSErrorFormatString* js::GetErrorMessage(
}
void JSContext::recoverFromOutOfMemory() {
if (helperThread()) {
if (isHelperThreadContext()) {
// Keep in sync with addPendingOutOfMemory.
if (ParseTask* task = helperThread()->parseTask()) {
if (ParseTask* task = parseTask()) {
task->outOfMemory = false;
}
} else {
@ -1197,9 +1197,9 @@ JS::OOM JSContext::reportedOOM;
mozilla::GenericErrorResult<OOM&> JSContext::alreadyReportedOOM() {
#ifdef DEBUG
if (helperThread()) {
if (isHelperThreadContext()) {
// Keep in sync with addPendingOutOfMemory.
if (ParseTask* task = helperThread()->parseTask()) {
if (ParseTask* task = parseTask()) {
MOZ_ASSERT(task->outOfMemory);
}
} else {
@ -1221,7 +1221,6 @@ mozilla::GenericErrorResult<JS::Error&> JSContext::alreadyReportedError() {
JSContext::JSContext(JSRuntime* runtime, const JS::ContextOptions& options)
: runtime_(runtime),
kind_(ContextKind::HelperThread),
helperThread_(nullptr),
options_(options),
freeLists_(nullptr),
defaultFreeOp_(runtime, true),

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

@ -158,9 +158,6 @@ struct JSContext : public JS::RootingContext,
js::UnprotectedData<JSRuntime*> runtime_;
js::WriteOnceData<js::ContextKind> kind_;
// The thread on which this context is running if this is not the main thread.
js::ThreadData<js::HelperThread*> helperThread_;
friend class js::gc::AutoSuppressNurseryCellAlloc;
js::ThreadData<size_t> nurserySuppressions_;
@ -333,9 +330,6 @@ struct JSContext : public JS::RootingContext,
inline void leaveRealm(JS::Realm* oldRealm);
void setHelperThread(js::HelperThread* helperThread);
js::HelperThread* helperThread() const { return helperThread_; }
void setParseTask(js::ParseTask* parseTask) { parseTask_ = parseTask; }
js::ParseTask* parseTask() const { return parseTask_; }