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

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

Issue 1943423002: Updates incremental marking pass to collect object statistics. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed an unnecessary class declaration. Created 4 years, 7 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/mark-compact.cc ('K') | « src/heap/object-stats.h ('k') | 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 0198c6bacf8075dc1721282781eba6e1dae61077..0da1e57438eee7d1cb777dfe125873d0bfa8f7fd 100644
--- a/src/heap/object-stats.cc
+++ b/src/heap/object-stats.cc
@@ -134,8 +134,7 @@ void ObjectStats::CheckpointObjectStats() {
Isolate* ObjectStats::isolate() { return heap()->isolate(); }
-
-void ObjectStatsVisitor::CountFixedArray(
+void ObjectStatsCollector::CountFixedArray(
FixedArrayBase* fixed_array, FixedArraySubInstanceType fast_type,
FixedArraySubInstanceType dictionary_type) {
Heap* heap = fixed_array->map()->GetHeap();
@@ -152,12 +151,32 @@ void ObjectStatsVisitor::CountFixedArray(
}
}
+void ObjectStatsCollector::CollectStatistics(StaticVisitorBase::VisitorId id,
+ Map* map, HeapObject* obj) {
+ // Record any type specific statistics here.
+ switch (id) {
+ case StaticVisitorBase::kVisitMap:
+ RecordMapStats(map, obj);
+ break;
+ case StaticVisitorBase::kVisitCode:
+ RecordCodeStats(map, obj);
+ break;
+ case StaticVisitorBase::kVisitSharedFunctionInfo:
+ RecordSharedFunctionInfoStats(map, obj);
+ break;
+ case StaticVisitorBase::kVisitFixedArray:
+ RecordFixedArrayStats(map, obj);
+ break;
+ default:
+ break;
+ }
-void ObjectStatsVisitor::VisitBase(VisitorId id, Map* map, HeapObject* obj) {
Heap* heap = map->GetHeap();
int object_size = obj->Size();
heap->object_stats_->RecordObjectStats(map->instance_type(), object_size);
- table_.GetVisitorById(id)(map, obj);
+}
+
+void ObjectStatsCollector::CollectFixedArrayStatistics(HeapObject* obj) {
if (obj->IsJSObject()) {
JSObject* object = JSObject::cast(obj);
CountFixedArray(object->elements(), DICTIONARY_ELEMENTS_SUB_TYPE,
@@ -167,16 +186,7 @@ void ObjectStatsVisitor::VisitBase(VisitorId id, Map* map, HeapObject* obj) {
}
}
-
-template <ObjectStatsVisitor::VisitorId id>
-void ObjectStatsVisitor::Visit(Map* map, HeapObject* obj) {
- VisitBase(id, map, obj);
-}
-
-
-template <>
-void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitMap>(Map* map,
- HeapObject* obj) {
+void ObjectStatsCollector::RecordMapStats(Map* map, HeapObject* obj) {
Heap* heap = map->GetHeap();
Map* map_obj = Map::cast(obj);
DCHECK(map->instance_type() == MAP_TYPE);
@@ -191,50 +201,55 @@ void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitMap>(Map* map,
heap->object_stats_->RecordFixedArraySubTypeStats(MAP_CODE_CACHE_SUB_TYPE,
cache->Size());
}
- VisitBase(kVisitMap, map, obj);
}
-
-template <>
-void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitCode>(
- Map* map, HeapObject* obj) {
+void ObjectStatsCollector::RecordCodeStats(Map* map, HeapObject* obj) {
Heap* heap = map->GetHeap();
int object_size = obj->Size();
DCHECK(map->instance_type() == CODE_TYPE);
Code* code_obj = Code::cast(obj);
heap->object_stats_->RecordCodeSubTypeStats(code_obj->kind(),
code_obj->GetAge(), object_size);
- VisitBase(kVisitCode, map, obj);
}
-
-template <>
-void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitSharedFunctionInfo>(
- Map* map, HeapObject* obj) {
+void ObjectStatsCollector::RecordSharedFunctionInfoStats(Map* map,
+ HeapObject* obj) {
Heap* heap = map->GetHeap();
SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj);
if (sfi->scope_info() != heap->empty_fixed_array()) {
heap->object_stats_->RecordFixedArraySubTypeStats(
SCOPE_INFO_SUB_TYPE, FixedArray::cast(sfi->scope_info())->Size());
}
- VisitBase(kVisitSharedFunctionInfo, map, obj);
}
-
-template <>
-void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitFixedArray>(
- Map* map, HeapObject* obj) {
+void ObjectStatsCollector::RecordFixedArrayStats(Map* map, HeapObject* obj) {
Heap* heap = map->GetHeap();
FixedArray* fixed_array = FixedArray::cast(obj);
if (fixed_array == heap->string_table()) {
heap->object_stats_->RecordFixedArraySubTypeStats(STRING_TABLE_SUB_TYPE,
fixed_array->Size());
}
- VisitBase(kVisitFixedArray, map, obj);
}
+void MarkCompactObjectStatsVisitor::Initialize(
+ VisitorDispatchTable<Callback>* original) {
+ // Copy the original visitor table to make call-through possible. After we
+ // preserved a copy locally, we patch the original table to call us.
+ table_.CopyFrom(original);
+#define COUNT_FUNCTION(id) original->Register(kVisit##id, Visit<kVisit##id>);
+ VISITOR_ID_LIST(COUNT_FUNCTION)
+#undef COUNT_FUNCTION
+}
-void ObjectStatsVisitor::Initialize(VisitorDispatchTable<Callback>* original) {
+template <MarkCompactObjectStatsVisitor::VisitorId id>
+void MarkCompactObjectStatsVisitor::Visit(Map* map, HeapObject* obj) {
+ ObjectStatsCollector::CollectStatistics(id, map, obj);
+ table_.GetVisitorById(id)(map, obj);
+ ObjectStatsCollector::CollectFixedArrayStatistics(obj);
+}
+
+void IncrementalMarkingObjectStatsVisitor::Initialize(
+ VisitorDispatchTable<Callback>* original) {
// Copy the original visitor table to make call-through possible. After we
// preserved a copy locally, we patch the original table to call us.
table_.CopyFrom(original);
@@ -243,5 +258,12 @@ void ObjectStatsVisitor::Initialize(VisitorDispatchTable<Callback>* original) {
#undef COUNT_FUNCTION
}
+template <IncrementalMarkingObjectStatsVisitor::VisitorId id>
+void IncrementalMarkingObjectStatsVisitor::Visit(Map* map, HeapObject* obj) {
+ ObjectStatsCollector::CollectStatistics(id, map, obj);
+ table_.GetVisitorById(id)(map, obj);
+ ObjectStatsCollector::CollectFixedArrayStatistics(obj);
+}
+
} // namespace internal
} // namespace v8
« src/heap/mark-compact.cc ('K') | « src/heap/object-stats.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698