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

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

Issue 2102073002: [ic] Use UnseededNumberDictionary as a storage for names in TypeFeedbackMetadata. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« src/heap/heap.h ('K') | « src/objects-inl.h ('k') | src/type-info.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/type-feedback-vector.cc
diff --git a/src/type-feedback-vector.cc b/src/type-feedback-vector.cc
index bc2f1c288bce149d7c9bb705fe74a714d5a07671..661aa2feac43c129745b8544930cc7b8e1ec9267 100644
--- a/src/type-feedback-vector.cc
+++ b/src/type-feedback-vector.cc
@@ -39,20 +39,13 @@ FeedbackVectorSlotKind TypeFeedbackMetadata::GetKind(
String* TypeFeedbackMetadata::GetName(FeedbackVectorSlot slot) const {
DCHECK(SlotRequiresName(GetKind(slot)));
- FixedArray* names = FixedArray::cast(get(kNamesTableIndex));
- // TODO(ishell): consider using binary search here or even Dictionary when we
- // have more ICs with names.
- Smi* key = Smi::FromInt(slot.ToInt());
- for (int entry = 0; entry < names->length(); entry += kNameTableEntrySize) {
- Object* current_key = names->get(entry + kNameTableSlotIndex);
- if (current_key == key) {
- Object* name = names->get(entry + kNameTableNameIndex);
- DCHECK(name->IsString());
- return String::cast(name);
- }
- }
- UNREACHABLE();
- return nullptr;
+ UnseededNumberDictionary* names =
+ UnseededNumberDictionary::cast(get(kNamesTableIndex));
+ int entry = names->FindEntry(GetIsolate(), slot.ToInt());
+ CHECK_NE(UnseededNumberDictionary::kNotFound, entry);
+ Object* name = names->ValueAt(entry);
+ DCHECK(name->IsString());
+ return String::cast(name);
}
void TypeFeedbackMetadata::SetKind(FeedbackVectorSlot slot,
@@ -107,10 +100,9 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
// Add names to NamesTable.
const int name_count = spec->name_count();
- Handle<FixedArray> names =
- name_count == 0
- ? factory->empty_fixed_array()
- : factory->NewFixedArray(name_count * kNameTableEntrySize);
+ Handle<UnseededNumberDictionary> names =
+ UnseededNumberDictionary::New(isolate, name_count);
+
int name_index = 0;
for (int i = 0; i < slot_count; i++) {
FeedbackVectorSlotKind kind = spec->GetKind(i);
@@ -118,9 +110,7 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
if (SlotRequiresName(kind)) {
Handle<String> name = spec->GetName(name_index);
DCHECK(!name.is_null());
- int entry = name_index * kNameTableEntrySize;
- names->set(entry + kNameTableSlotIndex, Smi::FromInt(i));
- names->set(entry + kNameTableNameIndex, *name);
+ names = UnseededNumberDictionary::AtNumberPut(names, i, name);
name_index++;
}
}
« src/heap/heap.h ('K') | « src/objects-inl.h ('k') | src/type-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698