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

Unified Diff: src/objects.cc

Issue 2681773004: [FeedbackVector] Clarify the way the feedback vector is installed. (Closed)
Patch Set: Code comments+REBASE. Created 3 years, 10 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/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698