Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index 02687312e03b8e8f5b63caab8d805b479219a3e9..32c3a6b2ca15214bd6e7b05bbf9415422d0e36da 100644 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -240,11 +240,11 @@ bool CompilationInfo::ExpectsJSReceiverAsReceiver() { |
// ---------------------------------------------------------------------------- |
// Implementation of CompilationJob |
-CompilationJob::Status CompilationJob::CreateGraph() { |
+CompilationJob::Status CompilationJob::PrepareJob() { |
+ DCHECK(ThreadId::Current().Equals(info()->isolate()->thread_id())); |
DisallowJavascriptExecution no_js(isolate()); |
- DCHECK(info()->IsOptimizing()); |
- if (FLAG_trace_opt) { |
+ if (FLAG_trace_opt && info()->IsOptimizing()) { |
OFStream os(stdout); |
os << "[compiling method " << Brief(*info()->closure()) << " using " |
<< compiler_name_; |
@@ -253,35 +253,35 @@ CompilationJob::Status CompilationJob::CreateGraph() { |
} |
// Delegate to the underlying implementation. |
- DCHECK_EQ(SUCCEEDED, last_status()); |
- ScopedTimer t(&time_taken_to_create_graph_); |
- return SetLastStatus(CreateGraphImpl()); |
+ DCHECK(state() == State::kReadyToPrepare); |
+ ScopedTimer t(&time_taken_to_prepare_); |
+ return UpdateState(PrepareJobImpl(), State::kReadyToExecute); |
} |
-CompilationJob::Status CompilationJob::OptimizeGraph() { |
+CompilationJob::Status CompilationJob::ExecuteJob() { |
DisallowHeapAllocation no_allocation; |
DisallowHandleAllocation no_handles; |
DisallowHandleDereference no_deref; |
DisallowCodeDependencyChange no_dependency_change; |
// Delegate to the underlying implementation. |
- DCHECK_EQ(SUCCEEDED, last_status()); |
- ScopedTimer t(&time_taken_to_optimize_); |
- return SetLastStatus(OptimizeGraphImpl()); |
+ DCHECK(state() == State::kReadyToExecute); |
+ ScopedTimer t(&time_taken_to_execute_); |
+ return UpdateState(ExecuteJobImpl(), State::kReadyToFinalize); |
} |
-CompilationJob::Status CompilationJob::GenerateCode() { |
+CompilationJob::Status CompilationJob::FinalizeJob() { |
+ DCHECK(ThreadId::Current().Equals(info()->isolate()->thread_id())); |
DisallowCodeDependencyChange no_dependency_change; |
DisallowJavascriptExecution no_js(isolate()); |
DCHECK(!info()->dependencies()->HasAborted()); |
// Delegate to the underlying implementation. |
- DCHECK_EQ(SUCCEEDED, last_status()); |
- ScopedTimer t(&time_taken_to_codegen_); |
- return SetLastStatus(GenerateCodeImpl()); |
+ DCHECK(state() == State::kReadyToFinalize); |
+ ScopedTimer t(&time_taken_to_finalize_); |
+ return UpdateState(FinalizeJobImpl(), State::kSucceeded); |
} |
- |
namespace { |
void AddWeakObjectToCodeDependency(Isolate* isolate, Handle<HeapObject> object, |
@@ -341,15 +341,16 @@ void CompilationJob::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) { |
} |
void CompilationJob::RecordOptimizationStats() { |
+ DCHECK(info()->IsOptimizing()); |
Handle<JSFunction> function = info()->closure(); |
if (!function->IsOptimized()) { |
// Concurrent recompilation and OSR may race. Increment only once. |
int opt_count = function->shared()->opt_count(); |
function->shared()->set_opt_count(opt_count + 1); |
} |
- double ms_creategraph = time_taken_to_create_graph_.InMillisecondsF(); |
- double ms_optimize = time_taken_to_optimize_.InMillisecondsF(); |
- double ms_codegen = time_taken_to_codegen_.InMillisecondsF(); |
+ double ms_creategraph = time_taken_to_prepare_.InMillisecondsF(); |
+ double ms_optimize = time_taken_to_execute_.InMillisecondsF(); |
+ double ms_codegen = time_taken_to_finalize_.InMillisecondsF(); |
if (FLAG_trace_opt) { |
PrintF("[optimizing "); |
function->ShortPrint(); |
@@ -365,14 +366,12 @@ void CompilationJob::RecordOptimizationStats() { |
compiled_functions++; |
code_size += function->shared()->SourceSize(); |
PrintF("Compiled: %d functions with %d byte source size in %fms.\n", |
- compiled_functions, |
- code_size, |
- compilation_time); |
+ compiled_functions, code_size, compilation_time); |
} |
if (FLAG_hydrogen_stats) { |
- isolate()->GetHStatistics()->IncrementSubtotals(time_taken_to_create_graph_, |
- time_taken_to_optimize_, |
- time_taken_to_codegen_); |
+ isolate()->GetHStatistics()->IncrementSubtotals(time_taken_to_prepare_, |
+ time_taken_to_execute_, |
+ time_taken_to_finalize_); |
} |
} |
@@ -673,9 +672,9 @@ bool GetOptimizedCodeNow(CompilationJob* job) { |
TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
isolate, &tracing::TraceEventStatsTable::RecompileSynchronous); |
- if (job->CreateGraph() != CompilationJob::SUCCEEDED || |
- job->OptimizeGraph() != CompilationJob::SUCCEEDED || |
- job->GenerateCode() != CompilationJob::SUCCEEDED) { |
+ if (job->PrepareJob() != CompilationJob::SUCCEEDED || |
+ job->ExecuteJob() != CompilationJob::SUCCEEDED || |
+ job->FinalizeJob() != CompilationJob::SUCCEEDED) { |
if (FLAG_trace_opt) { |
PrintF("[aborted optimizing "); |
info->closure()->ShortPrint(); |
@@ -736,7 +735,7 @@ bool GetOptimizedCodeLater(CompilationJob* job) { |
TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
isolate, &tracing::TraceEventStatsTable::RecompileSynchronous); |
- if (job->CreateGraph() != CompilationJob::SUCCEEDED) return false; |
+ if (job->PrepareJob() != CompilationJob::SUCCEEDED) return false; |
isolate->optimizing_compile_dispatcher()->QueueForOptimization(job); |
if (FLAG_trace_concurrent_recompilation) { |
@@ -1912,12 +1911,12 @@ void Compiler::FinalizeCompilationJob(CompilationJob* raw_job) { |
// Except when OSR already disabled optimization for some reason. |
// 3) The code may have already been invalidated due to dependency change. |
// 4) Code generation may have failed. |
- if (job->last_status() == CompilationJob::SUCCEEDED) { |
+ if (job->state() == CompilationJob::State::kReadyToFinalize) { |
if (shared->optimization_disabled()) { |
job->RetryOptimization(kOptimizationDisabled); |
} else if (info->dependencies()->HasAborted()) { |
job->RetryOptimization(kBailedOutDueToDependencyChange); |
- } else if (job->GenerateCode() == CompilationJob::SUCCEEDED) { |
+ } else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) { |
job->RecordOptimizationStats(); |
RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); |
if (shared->SearchOptimizedCodeMap(info->context()->native_context(), |
@@ -1934,7 +1933,7 @@ void Compiler::FinalizeCompilationJob(CompilationJob* raw_job) { |
} |
} |
- DCHECK(job->last_status() != CompilationJob::SUCCEEDED); |
+ DCHECK(job->state() == CompilationJob::State::kFailed); |
if (FLAG_trace_opt) { |
PrintF("[aborted optimizing "); |
info->closure()->ShortPrint(); |