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

Unified Diff: src/compiler.cc

Issue 660083005: AstNumberingVisitor does the work of AstConstructionVisitor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 8e94f7637ad2cc3c29846dcbb5285ec2785674df..233270aac66f2045f71db537e0772d77bdd060ec 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -291,9 +291,11 @@ bool CompilationInfo::ShouldSelfOptimize() {
void CompilationInfo::PrepareForCompilation(Scope* scope) {
DCHECK(scope_ == NULL);
scope_ = scope;
+}
+
+void CompilationInfo::EnsureFeedbackVector() {
if (feedback_vector_.is_null()) {
- // Allocate the feedback vector too.
feedback_vector_ = isolate()->factory()->NewTypeFeedbackVector(
function()->slot_count(), function()->ic_slot_count());
}
@@ -657,6 +659,7 @@ static bool CompileUnoptimizedCode(CompilationInfo* info) {
if (!isolate->has_pending_exception()) isolate->StackOverflow();
return false;
}
+
return true;
}
@@ -672,8 +675,6 @@ MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon(
FunctionLiteral* lit = info->function();
shared->set_strict_mode(lit->strict_mode());
SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
- shared->set_bailout_reason(lit->dont_optimize_reason());
- shared->set_ast_node_count(lit->ast_node_count());
// Compile unoptimized code.
if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
@@ -747,7 +748,10 @@ static bool CompileOptimizedPrologue(CompilationInfo* info) {
if (!Parser::Parse(info)) return false;
if (!Rewriter::Rewrite(info)) return false;
if (!Scope::Analyze(info)) return false;
- if (!AstNumbering::Renumber(info->function(), info->zone())) return false;
+ if (!AstNumbering::Renumber(info->function(), info->shared_info(),
+ info->zone())) {
+ return false;
+ }
DCHECK(info->scope() != NULL);
return true;
}
@@ -1303,8 +1307,18 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(
if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) {
Handle<Code> code = isolate->builtins()->CompileLazy();
info.SetCode(code);
+ // There's no need in theory for a lazy-compiled function to have a type
+ // feedback vector, but some parts of the system expect all
+ // SharedFunctionInfo instances to have one. The size of the vector depends
+ // on how many feedback-needing nodes are in the tree, and when lazily
+ // parsing we might not know that, if this function was never parsed before.
+ // In that case the vector will be replaced the next time MakeCode is
+ // called.
+ info.EnsureFeedbackVector();
scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate));
} else if (FullCodeGenerator::MakeCode(&info)) {
+ // MakeCode will ensure that the feedback vector is present and
+ // appropriately sized.
DCHECK(!info.code().is_null());
scope_info = ScopeInfo::Create(info.scope(), info.zone());
} else {
« src/ast-numbering.cc ('K') | « src/compiler.h ('k') | src/compiler/js-inlining.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698