Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index f6b82a0b9ed1c515637dec1ff4864164a30b6090..cd3aeee5a626bbbdee0120a37ee50985afff7d24 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -12108,39 +12108,27 @@ void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code, |
// static |
void JSFunction::EnsureLiterals(Handle<JSFunction> function) { |
Handle<SharedFunctionInfo> shared(function->shared()); |
- Handle<Context> native_context(function->context()->native_context()); |
Isolate* isolate = shared->GetIsolate(); |
- Cell* cell = function->feedback_vector_cell(); |
- if (cell == isolate->heap()->undefined_cell()) { |
- if (FLAG_trace_strong_rooted_literals) { |
- PrintF("EnsureLiterals: Installing literals cell in %s %p\n", |
- shared->DebugName()->ToCString().get(), |
- reinterpret_cast<void*>(*function)); |
- } |
- // Top level code didn't get it's literals installed. |
- Handle<FeedbackVector> feedback_vector = |
- FeedbackVector::New(isolate, shared); |
- Handle<Cell> new_cell = isolate->factory()->NewCell(feedback_vector); |
- function->set_feedback_vector_cell(*new_cell); |
- } else if (!cell->value()->IsFeedbackVector() || |
- !function->has_feedback_vector()) { |
- DCHECK(cell != isolate->heap()->undefined_cell()); |
- if (FLAG_trace_strong_rooted_literals) { |
- PrintF("EnsureLiterals: Update literals cell in %s %p\n", |
- shared->DebugName()->ToCString().get(), |
- reinterpret_cast<void*>(*function)); |
- } |
- Handle<FeedbackVector> feedback_vector = |
- FeedbackVector::New(isolate, shared); |
- // Re-get the feedback_vector() value as GC may have occurred. |
- function->feedback_vector_cell()->set_value(*feedback_vector); |
- } else { |
- if (FLAG_trace_strong_rooted_literals) { |
- PrintF("EnsureLiterals: did nothing for %s %p\n", |
- shared->DebugName()->ToCString().get(), |
- reinterpret_cast<void*>(*function)); |
+ FeedbackVectorState state = function->GetFeedbackVectorState(isolate); |
+ switch (state) { |
+ case TOP_LEVEL_SCRIPT_NEEDS_VECTOR: { |
+ // A top level script didn't get it's literals installed. |
+ Handle<FeedbackVector> feedback_vector = |
+ FeedbackVector::New(isolate, shared); |
+ Handle<Cell> new_cell = isolate->factory()->NewCell(feedback_vector); |
+ function->set_feedback_vector_cell(*new_cell); |
+ break; |
} |
+ case NEEDS_VECTOR: { |
+ Handle<FeedbackVector> feedback_vector = |
+ FeedbackVector::New(isolate, shared); |
+ function->feedback_vector_cell()->set_value(*feedback_vector); |
+ break; |
+ } |
+ case HAS_VECTOR: |
+ // Nothing to do. |
+ break; |
} |
} |