| Index: src/compiler.cc
|
| diff --git a/src/compiler.cc b/src/compiler.cc
|
| index 32c3a6b2ca15214bd6e7b05bbf9415422d0e36da..02687312e03b8e8f5b63caab8d805b479219a3e9 100644
|
| --- a/src/compiler.cc
|
| +++ b/src/compiler.cc
|
| @@ -240,11 +240,11 @@
|
| // ----------------------------------------------------------------------------
|
| // Implementation of CompilationJob
|
|
|
| -CompilationJob::Status CompilationJob::PrepareJob() {
|
| - DCHECK(ThreadId::Current().Equals(info()->isolate()->thread_id()));
|
| +CompilationJob::Status CompilationJob::CreateGraph() {
|
| DisallowJavascriptExecution no_js(isolate());
|
| -
|
| - if (FLAG_trace_opt && info()->IsOptimizing()) {
|
| + DCHECK(info()->IsOptimizing());
|
| +
|
| + if (FLAG_trace_opt) {
|
| OFStream os(stdout);
|
| os << "[compiling method " << Brief(*info()->closure()) << " using "
|
| << compiler_name_;
|
| @@ -253,34 +253,34 @@
|
| }
|
|
|
| // Delegate to the underlying implementation.
|
| - DCHECK(state() == State::kReadyToPrepare);
|
| - ScopedTimer t(&time_taken_to_prepare_);
|
| - return UpdateState(PrepareJobImpl(), State::kReadyToExecute);
|
| -}
|
| -
|
| -CompilationJob::Status CompilationJob::ExecuteJob() {
|
| + DCHECK_EQ(SUCCEEDED, last_status());
|
| + ScopedTimer t(&time_taken_to_create_graph_);
|
| + return SetLastStatus(CreateGraphImpl());
|
| +}
|
| +
|
| +CompilationJob::Status CompilationJob::OptimizeGraph() {
|
| DisallowHeapAllocation no_allocation;
|
| DisallowHandleAllocation no_handles;
|
| DisallowHandleDereference no_deref;
|
| DisallowCodeDependencyChange no_dependency_change;
|
|
|
| // Delegate to the underlying implementation.
|
| - DCHECK(state() == State::kReadyToExecute);
|
| - ScopedTimer t(&time_taken_to_execute_);
|
| - return UpdateState(ExecuteJobImpl(), State::kReadyToFinalize);
|
| -}
|
| -
|
| -CompilationJob::Status CompilationJob::FinalizeJob() {
|
| - DCHECK(ThreadId::Current().Equals(info()->isolate()->thread_id()));
|
| + DCHECK_EQ(SUCCEEDED, last_status());
|
| + ScopedTimer t(&time_taken_to_optimize_);
|
| + return SetLastStatus(OptimizeGraphImpl());
|
| +}
|
| +
|
| +CompilationJob::Status CompilationJob::GenerateCode() {
|
| DisallowCodeDependencyChange no_dependency_change;
|
| DisallowJavascriptExecution no_js(isolate());
|
| DCHECK(!info()->dependencies()->HasAborted());
|
|
|
| // Delegate to the underlying implementation.
|
| - DCHECK(state() == State::kReadyToFinalize);
|
| - ScopedTimer t(&time_taken_to_finalize_);
|
| - return UpdateState(FinalizeJobImpl(), State::kSucceeded);
|
| -}
|
| + DCHECK_EQ(SUCCEEDED, last_status());
|
| + ScopedTimer t(&time_taken_to_codegen_);
|
| + return SetLastStatus(GenerateCodeImpl());
|
| +}
|
| +
|
|
|
| namespace {
|
|
|
| @@ -341,16 +341,15 @@
|
| }
|
|
|
| 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_prepare_.InMillisecondsF();
|
| - double ms_optimize = time_taken_to_execute_.InMillisecondsF();
|
| - double ms_codegen = time_taken_to_finalize_.InMillisecondsF();
|
| + 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();
|
| if (FLAG_trace_opt) {
|
| PrintF("[optimizing ");
|
| function->ShortPrint();
|
| @@ -366,12 +365,14 @@
|
| 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_prepare_,
|
| - time_taken_to_execute_,
|
| - time_taken_to_finalize_);
|
| + isolate()->GetHStatistics()->IncrementSubtotals(time_taken_to_create_graph_,
|
| + time_taken_to_optimize_,
|
| + time_taken_to_codegen_);
|
| }
|
| }
|
|
|
| @@ -672,9 +673,9 @@
|
| TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
|
| isolate, &tracing::TraceEventStatsTable::RecompileSynchronous);
|
|
|
| - if (job->PrepareJob() != CompilationJob::SUCCEEDED ||
|
| - job->ExecuteJob() != CompilationJob::SUCCEEDED ||
|
| - job->FinalizeJob() != CompilationJob::SUCCEEDED) {
|
| + if (job->CreateGraph() != CompilationJob::SUCCEEDED ||
|
| + job->OptimizeGraph() != CompilationJob::SUCCEEDED ||
|
| + job->GenerateCode() != CompilationJob::SUCCEEDED) {
|
| if (FLAG_trace_opt) {
|
| PrintF("[aborted optimizing ");
|
| info->closure()->ShortPrint();
|
| @@ -735,7 +736,7 @@
|
| TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
|
| isolate, &tracing::TraceEventStatsTable::RecompileSynchronous);
|
|
|
| - if (job->PrepareJob() != CompilationJob::SUCCEEDED) return false;
|
| + if (job->CreateGraph() != CompilationJob::SUCCEEDED) return false;
|
| isolate->optimizing_compile_dispatcher()->QueueForOptimization(job);
|
|
|
| if (FLAG_trace_concurrent_recompilation) {
|
| @@ -1911,12 +1912,12 @@
|
| // 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->state() == CompilationJob::State::kReadyToFinalize) {
|
| + if (job->last_status() == CompilationJob::SUCCEEDED) {
|
| if (shared->optimization_disabled()) {
|
| job->RetryOptimization(kOptimizationDisabled);
|
| } else if (info->dependencies()->HasAborted()) {
|
| job->RetryOptimization(kBailedOutDueToDependencyChange);
|
| - } else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) {
|
| + } else if (job->GenerateCode() == CompilationJob::SUCCEEDED) {
|
| job->RecordOptimizationStats();
|
| RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info);
|
| if (shared->SearchOptimizedCodeMap(info->context()->native_context(),
|
| @@ -1933,7 +1934,7 @@
|
| }
|
| }
|
|
|
| - DCHECK(job->state() == CompilationJob::State::kFailed);
|
| + DCHECK(job->last_status() != CompilationJob::SUCCEEDED);
|
| if (FLAG_trace_opt) {
|
| PrintF("[aborted optimizing ");
|
| info->closure()->ShortPrint();
|
|
|