Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: src/compiler-dispatcher/compiler-dispatcher.cc

Issue 2686673002: [Compiler] Avoid blocking on inner function parallel compilation. (Closed)
Patch Set: Add another test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler-dispatcher/compiler-dispatcher.cc
diff --git a/src/compiler-dispatcher/compiler-dispatcher.cc b/src/compiler-dispatcher/compiler-dispatcher.cc
index b1c5b9d9d012b9bbeb2529f1c1de823d554d0fa6..c760fe8e7f9fe0bdf6ddeeb15202f083f72416bf 100644
--- a/src/compiler-dispatcher/compiler-dispatcher.cc
+++ b/src/compiler-dispatcher/compiler-dispatcher.cc
@@ -288,8 +288,8 @@ bool CompilerDispatcher::EnqueueAndStep(Handle<SharedFunctionInfo> function) {
}
bool CompilerDispatcher::Enqueue(
- Handle<SharedFunctionInfo> function, FunctionLiteral* literal,
- std::shared_ptr<Zone> parse_zone,
+ Handle<Script> script, Handle<SharedFunctionInfo> function,
+ FunctionLiteral* literal, std::shared_ptr<Zone> parse_zone,
std::shared_ptr<DeferredHandles> parse_handles,
std::shared_ptr<DeferredHandles> compile_handles) {
if (!CanEnqueue(function)) return false;
@@ -302,8 +302,8 @@ bool CompilerDispatcher::Enqueue(
}
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
- isolate_, tracer_.get(), function, literal, parse_zone, parse_handles,
- compile_handles, max_stack_size_));
+ isolate_, tracer_.get(), script, function, literal, parse_zone,
+ parse_handles, compile_handles, max_stack_size_));
std::pair<int, int> key(Script::cast(function->script())->id(),
function->function_literal_id());
jobs_.insert(std::make_pair(key, std::move(job)));
@@ -312,11 +312,12 @@ bool CompilerDispatcher::Enqueue(
}
bool CompilerDispatcher::EnqueueAndStep(
- Handle<SharedFunctionInfo> function, FunctionLiteral* literal,
- std::shared_ptr<Zone> parse_zone,
+ Handle<Script> script, Handle<SharedFunctionInfo> function,
+ FunctionLiteral* literal, std::shared_ptr<Zone> parse_zone,
std::shared_ptr<DeferredHandles> parse_handles,
std::shared_ptr<DeferredHandles> compile_handles) {
- if (!Enqueue(function, literal, parse_zone, parse_handles, compile_handles)) {
+ if (!Enqueue(script, function, literal, parse_zone, parse_handles,
+ compile_handles)) {
return false;
}
@@ -340,6 +341,9 @@ bool CompilerDispatcher::IsEnqueued(Handle<SharedFunctionInfo> function) const {
void CompilerDispatcher::WaitForJobIfRunningOnBackground(
CompilerDispatcherJob* job) {
+ RuntimeCallTimerScope runtimeTimer(
+ isolate_, &RuntimeCallStats::CompileWaitForDispatcher);
+
base::LockGuard<base::Mutex> lock(&mutex_);
if (running_background_jobs_.find(job) == running_background_jobs_.end()) {
pending_background_jobs_.erase(job);
@@ -354,16 +358,6 @@ void CompilerDispatcher::WaitForJobIfRunningOnBackground(
DCHECK(running_background_jobs_.find(job) == running_background_jobs_.end());
}
-bool CompilerDispatcher::FinishNow(CompilerDispatcherJob* job) {
- WaitForJobIfRunningOnBackground(job);
- while (!IsFinished(job)) {
- DoNextStepOnMainThread(isolate_, job, ExceptionHandling::kThrow);
- }
- bool result = job->status() != CompileJobStatus::kFailed;
- job->ResetOnMainThread();
- return result;
-}
-
bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
JobMap::const_iterator job = GetJobFor(function);
CHECK(job != jobs_.end());
@@ -374,7 +368,12 @@ bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
PrintF(" now\n");
}
- bool result = FinishNow(job->second.get());
+ WaitForJobIfRunningOnBackground(job->second.get());
+ while (!IsFinished(job->second.get())) {
+ DoNextStepOnMainThread(isolate_, job->second.get(),
+ ExceptionHandling::kThrow);
+ }
+ bool result = job->second->status() != CompileJobStatus::kFailed;
if (trace_compiler_dispatcher_) {
PrintF("CompilerDispatcher: finished working on ");
@@ -383,6 +382,7 @@ bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
tracer_->DumpStatistics();
}
+ job->second->ResetOnMainThread();
jobs_.erase(job);
if (jobs_.empty()) {
base::LockGuard<base::Mutex> lock(&mutex_);
@@ -391,30 +391,6 @@ bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
return result;
}
-bool CompilerDispatcher::FinishAllNow() {
- if (trace_compiler_dispatcher_) {
- PrintF("CompilerDispatcher: finishing all jobs now\n");
- }
-
- bool result = true;
- for (auto& it : jobs_) {
- result &= FinishNow(it.second.get());
- }
-
- if (trace_compiler_dispatcher_) {
- PrintF("CompilerDispatcher: finished all jobs\n");
- }
-
- jobs_.clear();
- {
- base::LockGuard<base::Mutex> lock(&mutex_);
- DCHECK(pending_background_jobs_.empty());
- DCHECK(running_background_jobs_.empty());
- abort_ = false;
- }
- return result;
-}
-
void CompilerDispatcher::AbortAll(BlockingBehavior blocking) {
bool background_tasks_running =
task_manager_->TryAbortAll() == CancelableTaskManager::kTaskRunning;

Powered by Google App Engine
This is Rietveld 408576698