Bug 1647115 - Add a runTaskLocked method in SourceCompressionTask. r=jonco

Differential Revision: https://phabricator.services.mozilla.com/D80893
This commit is contained in:
Yoshi Cheng-Hao Huang 2020-06-27 18:25:51 +00:00
Родитель 499048fe86
Коммит 7bf85e3823
3 изменённых файлов: 21 добавлений и 16 удалений

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

@ -2217,13 +2217,9 @@ void HelperThread::handleCompressionWorkload(
currentTask.emplace(task.get());
}
{
AutoUnlockHelperThreadState unlock(locked);
// release the pointer, inside runTask the SourceCompressTask pointer will
// be stored in compressionFinishedList.
task.release()->runTask();
}
// Release the pointer, inside runTaskLocked the SourceCompressTask pointer
// will be stored in compressionFinishedList.
task.release()->runTaskLocked(locked);
currentTask.reset();

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

@ -831,6 +831,7 @@ class SourceCompressionTask : public RunnableTask {
}
void runTask() override;
void runTaskLocked(AutoLockHelperThreadState& locked);
void complete();
ThreadType threadType() override { return ThreadType::THREAD_TYPE_COMPRESS; }

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

@ -2548,21 +2548,29 @@ void ScriptSource::performTaskWork(SourceCompressionTask* task) {
}
void SourceCompressionTask::runTask() {
if (!shouldCancel()) {
TraceLoggerThread* logger = TraceLoggerForCurrentThread();
AutoTraceLog logCompile(logger, TraceLogger_CompressSource);
if (shouldCancel()) {
return;
}
ScriptSource* source = sourceHolder_.get();
MOZ_ASSERT(source->hasUncompressedSource());
TraceLoggerThread* logger = TraceLoggerForCurrentThread();
AutoTraceLog logCompile(logger, TraceLogger_CompressSource);
source->performTaskWork(this);
ScriptSource* source = sourceHolder_.get();
MOZ_ASSERT(source->hasUncompressedSource());
source->performTaskWork(this);
}
void SourceCompressionTask::runTaskLocked(AutoLockHelperThreadState& locked) {
{
AutoUnlockHelperThreadState unlock(locked);
this->runTask();
}
{
AutoLockHelperThreadState lock;
AutoEnterOOMUnsafeRegion oomUnsafe;
if (!HelperThreadState().compressionFinishedList(lock).append(this)) {
oomUnsafe.crash("handleCompressionWorkload");
if (!HelperThreadState().compressionFinishedList(locked).append(this)) {
oomUnsafe.crash("SourceCompressionTask::runTaskLocked");
}
}
}