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

Unified Diff: src/compiler.cc

Issue 2251673003: Revert of [Interpreter] Introduce InterpreterCompilationJob (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_peekhole
Patch Set: Created 4 years, 4 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.h ('k') | src/compiler-dispatcher/optimizing-compile-dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 9e5e3916c9d3009dda66aab31340ddbf3f0c92ae..54ea359c6598631674cb232499c4defd9409ba21 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,69 +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);
-}
-
-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();
- if (FLAG_trace_opt) {
- PrintF("[optimizing ");
- function->ShortPrint();
- PrintF(" - took %0.3f, %0.3f, %0.3f ms]\n", ms_creategraph, ms_optimize,
- ms_codegen);
- }
- if (FLAG_trace_opt_stats) {
- static double compilation_time = 0.0;
- static int compiled_functions = 0;
- static int code_size = 0;
-
- compilation_time += (ms_creategraph + ms_optimize + ms_codegen);
- 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);
- }
- if (FLAG_hydrogen_stats) {
- isolate()->GetHStatistics()->IncrementSubtotals(time_taken_to_prepare_,
- time_taken_to_execute_,
- time_taken_to_finalize_);
- }
-}
+ DCHECK_EQ(SUCCEEDED, last_status());
+ ScopedTimer t(&time_taken_to_codegen_);
+ return SetLastStatus(GenerateCodeImpl());
+}
+
namespace {
@@ -335,7 +300,6 @@
} // namespace
-// static
void CompilationJob::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) {
// TODO(turbofan): Move this to pipeline.cc once Crankshaft dies.
Isolate* const isolate = code->GetIsolate();
@@ -376,6 +340,42 @@
code->set_can_have_weak_objects(true);
}
+void CompilationJob::RecordOptimizationStats() {
+ 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();
+ if (FLAG_trace_opt) {
+ PrintF("[optimizing ");
+ function->ShortPrint();
+ PrintF(" - took %0.3f, %0.3f, %0.3f ms]\n", ms_creategraph, ms_optimize,
+ ms_codegen);
+ }
+ if (FLAG_trace_opt_stats) {
+ static double compilation_time = 0.0;
+ static int compiled_functions = 0;
+ static int code_size = 0;
+
+ compilation_time += (ms_creategraph + ms_optimize + ms_codegen);
+ 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);
+ }
+ if (FLAG_hydrogen_stats) {
+ isolate()->GetHStatistics()->IncrementSubtotals(time_taken_to_create_graph_,
+ time_taken_to_optimize_,
+ time_taken_to_codegen_);
+ }
+}
+
// ----------------------------------------------------------------------------
// Local helper methods that make up the compilation pipeline.
@@ -672,9 +672,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 +735,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) {
@@ -1907,12 +1907,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(),
@@ -1929,7 +1929,7 @@
}
}
- DCHECK(job->state() == CompilationJob::State::kFailed);
+ DCHECK(job->last_status() != CompilationJob::SUCCEEDED);
if (FLAG_trace_opt) {
PrintF("[aborted optimizing ");
info->closure()->ShortPrint();
« no previous file with comments | « src/compiler.h ('k') | src/compiler-dispatcher/optimizing-compile-dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698