diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index ec9744bde365..0c0e3c3d9ea5 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -428,6 +428,13 @@ struct MOZ_RAII AutoSetContextRuntime { ~AutoSetContextRuntime() { TlsContext.get()->setRuntime(nullptr); } }; +struct MOZ_RAII AutoSetContextParse { + explicit AutoSetContextParse(ParseTask* task) { + TlsContext.get()->setParseTask(task); + } + ~AutoSetContextParse() { TlsContext.get()->setParseTask(nullptr); } +}; + static const JSClass parseTaskGlobalClass = {"internal-parse-task-global", JSCLASS_GLOBAL_FLAGS, &JS::DefaultGlobalClassOps}; @@ -494,6 +501,7 @@ void ParseTask::runTask() { JSRuntime* runtime = parseGlobal->runtimeFromAnyThread(); AutoSetContextRuntime ascr(runtime); + AutoSetContextParse parsetask(this); Zone* zone = parseGlobal->zoneFromAnyThread(); zone->setHelperThreadOwnerContext(cx); diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h index 5d4376728432..37bcc53af85e 100644 --- a/js/src/vm/JSContext.h +++ b/js/src/vm/JSContext.h @@ -74,6 +74,8 @@ struct AutoResolving; struct HelperThread; +struct ParseTask; + class InternalJobQueue : public JS::JobQueue { public: explicit InternalJobQueue(JSContext* cx) @@ -177,6 +179,8 @@ struct JSContext : public JS::RootingContext, js::ThreadData defaultFreeOp_; + js::ParseTask* parseTask_; + public: // This is used by helper threads to change the runtime their context is // currently operating on. @@ -332,6 +336,9 @@ struct JSContext : public JS::RootingContext, void setHelperThread(js::HelperThread* helperThread); js::HelperThread* helperThread() const { return helperThread_; } + void setParseTask(js::ParseTask* parseTask) { parseTask_ = parseTask; } + js::ParseTask* parseTask() const { return parseTask_; } + bool isNurseryAllocSuppressed() const { return nurserySuppressions_; } // Threads may freely access any data in their realm, compartment and zone.