Bug 1559821 - teach JSContext about parse tasks r=jonco

Added a ParseTask pointer to JSContext, set/removed during ParseTask::runTask

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
kriswright 2019-06-20 22:43:59 +00:00
Родитель 32cc8bf833
Коммит e1dfee9d67
2 изменённых файлов: 15 добавлений и 0 удалений

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

@ -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);

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

@ -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<js::FreeOp> 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.