Index: src/mark-compact.cc |
diff --git a/src/mark-compact.cc b/src/mark-compact.cc |
index e61457991e1769c6a589d1c40c7550de5f9854b2..024b7ef4072ca162ebe9ca8750a1a6d3e885f42d 100644 |
--- a/src/mark-compact.cc |
+++ b/src/mark-compact.cc |
@@ -944,6 +944,17 @@ class StaticMarkingVisitor : public StaticVisitorBase { |
table_.GetVisitor(map)(map, obj); |
} |
+ template<int id> |
+ class ObjectStatsTracker { |
+ public: |
+ static inline void Visit(Map* map, HeapObject* obj) { |
+ Heap* heap = map->GetHeap(); |
+ int object_size = obj->Size(); |
+ heap->RecordObjectStats(map->instance_type(), object_size); |
+ non_count_table_.GetVisitorById(static_cast<VisitorId>(id))(map, obj); |
+ } |
+ }; |
+ |
static void Initialize() { |
table_.Register(kVisitShortcutCandidate, |
&FixedBodyVisitor<StaticMarkingVisitor, |
@@ -1012,6 +1023,15 @@ class StaticMarkingVisitor : public StaticVisitorBase { |
table_.RegisterSpecializations<StructObjectVisitor, |
kVisitStruct, |
kVisitStructGeneric>(); |
+ |
+ if (FLAG_track_gc_object_stats) { |
+ // Copy the visitor table to make call-through possible. |
+ non_count_table_.CopyFrom(&table_); |
+#define VISITOR_ID_COUNT_FUNCTION(id)\ |
+ table_.Register(kVisit##id, ObjectStatsTracker<kVisit##id>::Visit); |
+ VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION) |
+#undef VISITOR_ID_COUNT_FUNCTION |
+ } |
} |
INLINE(static void VisitPointer(Heap* heap, Object** p)) { |
@@ -1557,11 +1577,14 @@ class StaticMarkingVisitor : public StaticVisitorBase { |
typedef void (*Callback)(Map* map, HeapObject* object); |
static VisitorDispatchTable<Callback> table_; |
+ static VisitorDispatchTable<Callback> non_count_table_; |
}; |
VisitorDispatchTable<StaticMarkingVisitor::Callback> |
StaticMarkingVisitor::table_; |
+VisitorDispatchTable<StaticMarkingVisitor::Callback> |
+ StaticMarkingVisitor::non_count_table_; |
class MarkingVisitor : public ObjectVisitor { |
@@ -2437,6 +2460,10 @@ void MarkCompactCollector::AfterMarking() { |
// Clean up dead objects from the runtime profiler. |
heap()->isolate()->runtime_profiler()->RemoveDeadSamples(); |
} |
+ |
+ if (FLAG_track_gc_object_stats) { |
+ heap()->CheckpointObjectStats(); |
+ } |
} |