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

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

Issue 2611313002: [complier] Enable parallel eager inner function compilation with compiler dispatcher. (Closed)
Patch Set: Rebase Created 3 years, 11 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
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher.h ('k') | src/compiler-dispatcher/compiler-dispatcher-job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler-dispatcher/compiler-dispatcher.cc
diff --git a/src/compiler-dispatcher/compiler-dispatcher.cc b/src/compiler-dispatcher/compiler-dispatcher.cc
index 70edce9673f2df635a1dda2e8f4f92be84276ae6..4f137c687e1da1f2d1a4890f018250245b0c6792 100644
--- a/src/compiler-dispatcher/compiler-dispatcher.cc
+++ b/src/compiler-dispatcher/compiler-dispatcher.cc
@@ -8,6 +8,7 @@
#include "include/v8.h"
#include "src/base/platform/time.h"
#include "src/cancelable-task.h"
+#include "src/compilation-info.h"
#include "src/compiler-dispatcher/compiler-dispatcher-job.h"
#include "src/compiler-dispatcher/compiler-dispatcher-tracer.h"
#include "src/flags.h"
@@ -36,7 +37,11 @@ bool DoNextStepOnMainThread(Isolate* isolate, CompilerDispatcherJob* job,
job->FinalizeParsingOnMainThread();
break;
- case CompileJobStatus::kReadyToAnalyse:
+ case CompileJobStatus::kReadyToAnalyze:
+ job->AnalyzeOnMainThread();
+ break;
+
+ case CompileJobStatus::kAnalyzed:
job->PrepareToCompileOnMainThread();
break;
@@ -224,7 +229,7 @@ CompilerDispatcher::~CompilerDispatcher() {
task_manager_->CancelAndWait();
}
-bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function) {
+bool CompilerDispatcher::CanEnqueue(Handle<SharedFunctionInfo> function) {
if (!IsEnabled()) return false;
DCHECK(FLAG_ignition);
@@ -245,12 +250,17 @@ bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function) {
return false;
}
+ return true;
+}
+
+bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function) {
+ if (!CanEnqueue(function)) return false;
if (IsEnqueued(function)) return true;
if (trace_compiler_dispatcher_) {
PrintF("CompilerDispatcher: enqueuing ");
function->ShortPrint();
- PrintF("\n");
+ PrintF(" for parse and compile\n");
}
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
@@ -277,11 +287,44 @@ bool CompilerDispatcher::EnqueueAndStep(Handle<SharedFunctionInfo> function) {
return true;
}
-bool CompilerDispatcher::IsEnabled() const {
- v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_);
- return FLAG_compiler_dispatcher && platform_->IdleTasksEnabled(v8_isolate);
+bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function,
+ FunctionLiteral* literal) {
+ if (!CanEnqueue(function)) return false;
+ if (IsEnqueued(function)) return true;
+
+ if (trace_compiler_dispatcher_) {
+ PrintF("CompilerDispatcher: enqueuing ");
+ function->ShortPrint();
+ PrintF(" for compile\n");
+ }
+
+ std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
+ isolate_, tracer_.get(), function, literal, 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)));
+ ScheduleIdleTaskIfNeeded();
+ return true;
+}
+
+bool CompilerDispatcher::EnqueueAndStep(Handle<SharedFunctionInfo> function,
+ FunctionLiteral* literal) {
+ if (!Enqueue(function, literal)) return false;
+
+ if (trace_compiler_dispatcher_) {
+ PrintF("CompilerDispatcher: stepping ");
+ function->ShortPrint();
+ PrintF("\n");
+ }
+ JobMap::const_iterator job = GetJobFor(function);
+ DoNextStepOnMainThread(isolate_, job->second.get(),
+ ExceptionHandling::kSwallow);
+ ConsiderJobForBackgroundProcessing(job->second.get());
+ return true;
}
+bool CompilerDispatcher::IsEnabled() const { return FLAG_compiler_dispatcher; }
+
bool CompilerDispatcher::IsEnqueued(Handle<SharedFunctionInfo> function) const {
return GetJobFor(function) != jobs_.end();
}
@@ -302,6 +345,16 @@ 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());
@@ -312,12 +365,7 @@ bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
PrintF(" now\n");
}
- WaitForJobIfRunningOnBackground(job->second.get());
- while (!IsFinished(job->second.get())) {
- DoNextStepOnMainThread(isolate_, job->second.get(),
- ExceptionHandling::kThrow);
- }
- bool result = job->second->status() != CompileJobStatus::kFailed;
+ bool result = FinishNow(job->second.get());
if (trace_compiler_dispatcher_) {
PrintF("CompilerDispatcher: finished working on ");
@@ -326,7 +374,6 @@ bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
tracer_->DumpStatistics();
}
- job->second->ResetOnMainThread();
jobs_.erase(job);
if (jobs_.empty()) {
base::LockGuard<base::Mutex> lock(&mutex_);
@@ -335,6 +382,30 @@ 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;
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher.h ('k') | src/compiler-dispatcher/compiler-dispatcher-job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698