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

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

Issue 2181303002: [ic] Avoid memory wasting when allocating names table of type feedback metadata. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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.cc ('k') | no next file » | 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 e413d7d9de8a13bcd835aaebcae3caf8efb368e8..9ffc22e6a8a1bc09a86112595b7d3665526fdf26 100644
--- a/src/type-feedback-vector.cc
+++ b/src/type-feedback-vector.cc
@@ -100,8 +100,12 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
// Add names to NamesTable.
const int name_count = spec->name_count();
- Handle<UnseededNumberDictionary> names =
- UnseededNumberDictionary::New(isolate, name_count);
+ Handle<UnseededNumberDictionary> names;
+ if (name_count) {
+ names = UnseededNumberDictionary::New(
+ isolate, base::bits::RoundUpToPowerOfTwo32(name_count), TENURED,
+ USE_CUSTOM_MINIMUM_CAPACITY);
+ }
int name_index = 0;
for (int i = 0; i < slot_count; i++) {
@@ -115,7 +119,8 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
}
}
DCHECK_EQ(name_count, name_index);
- metadata->set(kNamesTableIndex, *names);
+ metadata->set(kNamesTableIndex,
+ name_count ? static_cast<Object*>(*names) : Smi::FromInt(0));
// It's important that the TypeFeedbackMetadata have a COW map, since it's
// pointed to by both a SharedFunctionInfo and indirectly by closures through
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698