Commit b8e9bd40 authored by Wiktor Garbacz's avatar Wiktor Garbacz Committed by Commit Bot

[compiler-dispatcher] Finish jobs not running in background first.

As jobs are picked up in the same order by background tasks as they are
when FinishAll is called it may happen that the main thread just waits
for background threads without doing any work. So first run jobs, that
are not running in background, to completion and then wait for remaining
jobs to finish.

BUG=v8:6093

Change-Id: Ica83db2a504771b633cfdfc4e95e1ac8e43111d6
Reviewed-on: https://chromium-review.googlesource.com/488244Reviewed-by: 's avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Wiktor Garbacz <wiktorg@google.com>
Cr-Commit-Position: refs/heads/master@{#45017}
parent 00912d73
......@@ -473,14 +473,31 @@ bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
JobMap::const_iterator job = GetJobFor(function);
CHECK(job != jobs_.end());
bool result = FinishNow(job->second.get());
if (!job->second->shared().is_null()) {
shared_to_job_id_.Delete(job->second->shared());
}
RemoveIfFinished(job);
return result;
}
void CompilerDispatcher::FinishAllNow() {
// First finish all jobs not running in background
for (auto it = jobs_.cbegin(); it != jobs_.cend();) {
CompilerDispatcherJob* job = it->second.get();
bool is_running_in_background;
{
base::LockGuard<base::Mutex> lock(&mutex_);
is_running_in_background =
running_background_jobs_.find(job) != running_background_jobs_.end();
pending_background_jobs_.erase(job);
}
if (!is_running_in_background) {
while (!IsFinished(job)) {
DoNextStepOnMainThread(isolate_, job, ExceptionHandling::kThrow);
}
it = RemoveIfFinished(it);
} else {
++it;
}
}
// Potentially wait for jobs that were running in background
for (auto it = jobs_.cbegin(); it != jobs_.cend();
it = RemoveIfFinished(it)) {
FinishNow(it->second.get());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment