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

Unified Diff: src/compiler.cc

Issue 563123004: Unify use-sites of EnsureDeoptimizationSupport. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Decomplicatification (aka. simplify). Created 6 years, 3 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/js-inlining.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 cd8b75b42a5dc912d7a48e3c6f34b3e36bee2fe6..92d675ab1cd277a7ef837179b88208db9f7b4249 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -397,21 +397,8 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
if (FLAG_hydrogen_stats) {
timer.Start();
}
- CompilationInfoWithZone unoptimized(info()->shared_info());
- // Note that we use the same AST that we will use for generating the
- // optimized code.
- unoptimized.SetFunction(info()->function());
- unoptimized.PrepareForCompilation(info()->scope());
- unoptimized.SetContext(info()->context());
- if (should_recompile) unoptimized.EnableDeoptimizationSupport();
- bool succeeded = FullCodeGenerator::MakeCode(&unoptimized);
- if (should_recompile) {
- if (!succeeded) return SetLastStatus(FAILED);
- Handle<SharedFunctionInfo> shared = info()->shared_info();
- shared->EnableDeoptimizationSupport(*unoptimized.code());
- // The existing unoptimized code was replaced with the new one.
- Compiler::RecordFunctionCompilation(
- Logger::LAZY_COMPILE_TAG, &unoptimized, shared);
+ if (!Compiler::EnsureDeoptimizationSupport(info())) {
+ return SetLastStatus(FAILED);
}
if (FLAG_hydrogen_stats) {
isolate()->GetHStatistics()->IncrementFullCodeGen(timer.Elapsed());
@@ -758,6 +745,38 @@ bool Compiler::EnsureCompiled(Handle<JSFunction> function,
}
+// TODO(turbofan): In the future, unoptimized code with deopt support could
+// be generated lazily once deopt is triggered.
+bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
+ if (!info->shared_info()->has_deoptimization_support()) {
+ CompilationInfoWithZone unoptimized(info->shared_info());
+ // Note that we use the same AST that we will use for generating the
+ // optimized code.
+ unoptimized.SetFunction(info->function());
+ unoptimized.PrepareForCompilation(info->scope());
+ unoptimized.SetContext(info->context());
+ unoptimized.EnableDeoptimizationSupport();
+ if (!FullCodeGenerator::MakeCode(&unoptimized)) return false;
+
+ Handle<SharedFunctionInfo> shared = info->shared_info();
+ shared->EnableDeoptimizationSupport(*unoptimized.code());
+ shared->set_feedback_vector(*unoptimized.feedback_vector());
+
+ // The scope info might not have been set if a lazily compiled
+ // function is inlined before being called for the first time.
+ if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) {
+ Handle<ScopeInfo> target_scope_info =
+ ScopeInfo::Create(info->scope(), info->zone());
+ shared->set_scope_info(*target_scope_info);
+ }
+
+ // The existing unoptimized code was replaced with the new one.
+ RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, &unoptimized, shared);
+ }
+ return true;
+}
+
+
// Compile full code for debugging. This code will have debug break slots
// and deoptimization information. Deoptimization information is required
// in case that an optimized version of this function is still activated on
« no previous file with comments | « src/compiler.h ('k') | src/compiler/js-inlining.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698