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

Unified Diff: src/heap/object-stats.cc

Issue 2176393003: [heap] ObjectStats: Account for headers when computing HashTable overhead (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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/object-stats.cc
diff --git a/src/heap/object-stats.cc b/src/heap/object-stats.cc
index 1f2eef0c339f5cad848529133999c8a2af74920f..a9ef8686b82575b30b976a754065a88973d41c83 100644
--- a/src/heap/object-stats.cc
+++ b/src/heap/object-stats.cc
@@ -274,7 +274,9 @@ void ObjectStatsCollector::RecordHashTableHelper(HeapObject* parent,
int subtype) {
int used = array->NumberOfElements() * HashTable::kEntrySize;
CHECK_GE(array->Size(), used);
- size_t overhead = array->Size() - used;
+ size_t overhead = array->Size() - used -
+ HashTable::kElementsStartIndex * kPointerSize -
+ FixedArray::kHeaderSize;
RecordFixedArrayHelper(parent, array, subtype, overhead);
}
@@ -290,7 +292,7 @@ void ObjectStatsCollector::RecordJSObjectDetails(JSObject* object) {
int used = object->GetFastElementsUsage() * kPointerSize;
if (object->GetElementsKind() == FAST_HOLEY_DOUBLE_ELEMENTS) used *= 2;
CHECK_GE(elements->Size(), used);
- overhead = elements->Size() - used;
+ overhead = elements->Size() - used - FixedArray::kHeaderSize;
}
stats_->RecordFixedArraySubTypeStats(elements, FAST_ELEMENTS_SUB_TYPE,
elements->Size(), overhead);
@@ -322,15 +324,16 @@ void ObjectStatsCollector::RecordJSWeakCollectionDetails(
}
void ObjectStatsCollector::RecordJSCollectionDetails(JSObject* obj) {
+ // The JS versions use a different HashTable implementation that cannot use
+ // the regular helper. Since overall impact is usually small just record
+ // without overhead.
if (obj->IsJSMap()) {
- RecordHashTableHelper(nullptr,
- OrderedHashMap::cast(JSMap::cast(obj)->table()),
- JS_COLLECTION_SUB_TYPE);
+ RecordFixedArrayHelper(nullptr, FixedArray::cast(JSMap::cast(obj)->table()),
+ JS_COLLECTION_SUB_TYPE, 0);
}
if (obj->IsJSSet()) {
- RecordHashTableHelper(nullptr,
- OrderedHashSet::cast(JSSet::cast(obj)->table()),
- JS_COLLECTION_SUB_TYPE);
+ RecordFixedArrayHelper(nullptr, FixedArray::cast(JSSet::cast(obj)->table()),
+ JS_COLLECTION_SUB_TYPE, 0);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698