Chromium Code Reviews

Unified Diff: src/type-feedback-vector.cc

Issue 1563213002: Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ports. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: src/type-feedback-vector.cc
diff --git a/src/type-feedback-vector.cc b/src/type-feedback-vector.cc
index 698f2a6d17380d6e0771c5194e2259819b864542..0a1bcd47656453155241d3e1647b5c88d26d21d8 100644
--- a/src/type-feedback-vector.cc
+++ b/src/type-feedback-vector.cc
@@ -83,6 +83,14 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
for (int i = 0; i < slot_count; i++) {
metadata->SetKind(FeedbackVectorSlot(i), spec->GetKind(i));
}
+
+ // It's important that the TypeFeedbackMetadata have a COW map, since it's
+ // pointed to by both a SharedFunctionInfo and indirectly by closures through
+ // the TypeFeedbackVector. The serializer uses the COW map type to decide
+ // this object belongs in the startup snapshot and not the partial
+ // snapshot(s).
+ metadata->set_map(isolate->heap()->fixed_cow_array_map());
+
return metadata;
}
@@ -103,6 +111,23 @@ bool TypeFeedbackMetadata::SpecDiffersFrom(
}
+bool TypeFeedbackMetadata::DiffersFrom(
+ const TypeFeedbackMetadata* other_metadata) const {
+ if (other_metadata->slot_count() != slot_count()) {
+ return true;
+ }
+
+ int slots = slot_count();
+ for (int i = 0; i < slots; i++) {
+ FeedbackVectorSlot slot(i);
+ if (GetKind(slot) != other_metadata->GetKind(slot)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
const char* TypeFeedbackMetadata::Kind2String(FeedbackVectorSlotKind kind) {
switch (kind) {
case FeedbackVectorSlotKind::INVALID:
@@ -246,15 +271,26 @@ void TypeFeedbackVector::ClearAllKeyedStoreICs(Isolate* isolate) {
SharedFunctionInfo::Iterator iterator(isolate);
SharedFunctionInfo* shared;
while ((shared = iterator.Next())) {
- TypeFeedbackVector* vector = shared->feedback_vector();
- vector->ClearKeyedStoreICs(shared);
+ if (!shared->OptimizedCodeMapIsCleared()) {
+ FixedArray* optimized_code_map = shared->optimized_code_map();
+ int length = optimized_code_map->length();
+ for (int i = SharedFunctionInfo::kEntriesStart; i < length;
+ i += SharedFunctionInfo::kEntryLength) {
+ WeakCell* cell = WeakCell::cast(
+ optimized_code_map->get(i + SharedFunctionInfo::kLiteralsOffset));
+ if (cell->value()->IsLiteralsArray()) {
+ TypeFeedbackVector* vector =
+ LiteralsArray::cast(cell->value())->feedback_vector();
+ vector->ClearKeyedStoreICs(shared);
+ }
+ }
+ }
}
}
void TypeFeedbackVector::ClearKeyedStoreICs(SharedFunctionInfo* shared) {
Isolate* isolate = GetIsolate();
-
Code* host = shared->code();
Object* uninitialized_sentinel =
TypeFeedbackVector::RawUninitializedSentinel(isolate);

Powered by Google App Engine