mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1559659 - 3. Get rid of per-thread jscontext instantiation and use the global pool instead r=jandem
Got rid of the per-thread JSContext created at the start of each thread. Tasks that require JSContext (ParseTasks, IonBuilder, Wasm tier 2 generators, GCParallel) now request an unused context to set to their thread. Tasks which do not use JSContext will not request one. Differential Revision: https://phabricator.services.mozilla.com/D37495 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
027905e475
commit
3fa5b30ce3
@ -1142,6 +1142,7 @@ AbortReasonOr<Ok> IonBuilder::buildInline(IonBuilder* callerBuilder,
|
||||
void IonBuilder::runTask() {
|
||||
// This is the entry point when ion compiles are run offthread.
|
||||
JSRuntime* rt = script()->runtimeFromAnyThread();
|
||||
AutoSetHelperThreadContext usesContext;
|
||||
|
||||
TraceLoggerThread* logger = TraceLoggerForCurrentThread();
|
||||
TraceLoggerEvent event(TraceLogger_AnnotateScripts, script());
|
||||
|
@ -543,11 +543,14 @@ size_t ParseTask::sizeOfExcludingThis(
|
||||
}
|
||||
|
||||
void ParseTask::runTask() {
|
||||
AutoSetHelperThreadContext usesContext;
|
||||
|
||||
JSContext* cx = TlsContext.get();
|
||||
JSRuntime* runtime = parseGlobal->runtimeFromAnyThread();
|
||||
|
||||
AutoSetContextRuntime ascr(runtime);
|
||||
AutoSetContextParse parsetask(this);
|
||||
gc::AutoSuppressNurseryCellAlloc noNurseryAlloc(cx);
|
||||
|
||||
Zone* zone = parseGlobal->zoneFromAnyThread();
|
||||
zone->setHelperThreadOwnerContext(cx);
|
||||
@ -1765,11 +1768,11 @@ void js::GCParallelTask::runFromMainThread(JSRuntime* rt) {
|
||||
void js::GCParallelTask::runFromHelperThread(AutoLockHelperThreadState& lock) {
|
||||
MOZ_ASSERT(isDispatched(lock));
|
||||
|
||||
AutoSetContextRuntime ascr(runtime());
|
||||
gc::AutoSetThreadIsPerformingGC performingGC;
|
||||
|
||||
{
|
||||
AutoUnlockHelperThreadState parallelSection(lock);
|
||||
AutoSetHelperThreadContext usesContext;
|
||||
AutoSetContextRuntime ascr(runtime());
|
||||
gc::AutoSetThreadIsPerformingGC performingGC;
|
||||
TimeStamp timeStart = ReallyNow();
|
||||
runTask();
|
||||
duration_ = TimeSince(timeStart);
|
||||
@ -2173,7 +2176,6 @@ void HelperThread::handleIonWorkload(AutoLockHelperThreadState& locked) {
|
||||
|
||||
{
|
||||
AutoUnlockHelperThreadState unlock(locked);
|
||||
AutoSetContextRuntime ascr(rt);
|
||||
|
||||
builder->runTask();
|
||||
}
|
||||
@ -2541,22 +2543,9 @@ void HelperThread::threadLoop() {
|
||||
|
||||
ensureRegisteredWithProfiler();
|
||||
|
||||
JSContext cx(nullptr, JS::ContextOptions());
|
||||
{
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
cx.setHelperThread(lock);
|
||||
if (!cx.init(ContextKind::HelperThread)) {
|
||||
oomUnsafe.crash("HelperThread cx.init()");
|
||||
}
|
||||
}
|
||||
gc::AutoSuppressNurseryCellAlloc noNurseryAlloc(&cx);
|
||||
JS_SetNativeStackQuota(&cx, HELPER_STACK_QUOTA);
|
||||
|
||||
while (!terminate) {
|
||||
MOZ_ASSERT(idle());
|
||||
|
||||
maybeFreeUnusedMemory(&cx);
|
||||
|
||||
// The selectors may depend on the HelperThreadState not changing
|
||||
// between task selection and task execution, in particular, on new
|
||||
// tasks not being added (because of the lifo structure of the work
|
||||
|
@ -62,6 +62,7 @@ class Module::Tier2GeneratorTaskImpl : public Tier2GeneratorTask {
|
||||
void cancel() override { cancelled_ = true; }
|
||||
|
||||
void runTask() override {
|
||||
AutoSetHelperThreadContext usesContext;
|
||||
CompileTier2(*compileArgs_, bytecode_->bytes, *module_, &cancelled_);
|
||||
}
|
||||
ThreadType threadType() override {
|
||||
|
Loading…
Reference in New Issue
Block a user