Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index f52d6fc5b1cc18146a88633e0aef01566ebade36..1eeb8dc5faba2f7056ffabadb6b75f63d485b9bf 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()); |
} |
@@ -1325,8 +1327,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 (Renumber(&info) && 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 { |