OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_OBJECT_STATS_H_ | 5 #ifndef V8_HEAP_OBJECT_STATS_H_ |
6 #define V8_HEAP_OBJECT_STATS_H_ | 6 #define V8_HEAP_OBJECT_STATS_H_ |
7 | 7 |
8 #include "src/heap/heap.h" | 8 #include "src/heap/heap.h" |
9 #include "src/heap/objects-visiting.h" | 9 #include "src/heap/objects-visiting.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 private: | 74 private: |
75 Heap* heap_; | 75 Heap* heap_; |
76 | 76 |
77 // Object counts and used memory by InstanceType | 77 // Object counts and used memory by InstanceType |
78 size_t object_counts_[OBJECT_STATS_COUNT]; | 78 size_t object_counts_[OBJECT_STATS_COUNT]; |
79 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; | 79 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; |
80 size_t object_sizes_[OBJECT_STATS_COUNT]; | 80 size_t object_sizes_[OBJECT_STATS_COUNT]; |
81 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; | 81 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; |
82 }; | 82 }; |
83 | 83 |
84 | 84 class ObjectStatsCollector { |
85 class ObjectStatsVisitor : public StaticMarkingVisitor<ObjectStatsVisitor> { | |
86 public: | 85 public: |
87 static void Initialize(VisitorDispatchTable<Callback>* original); | 86 static void CollectStatistics(StaticVisitorBase::VisitorId id, Map* map, |
88 | 87 HeapObject* obj); |
89 static void VisitBase(VisitorId id, Map* map, HeapObject* obj); | 88 static void CollectFixedArrayStatistics(HeapObject* obj); |
90 | 89 |
91 static void CountFixedArray(FixedArrayBase* fixed_array, | 90 static void CountFixedArray(FixedArrayBase* fixed_array, |
92 FixedArraySubInstanceType fast_type, | 91 FixedArraySubInstanceType fast_type, |
93 FixedArraySubInstanceType dictionary_type); | 92 FixedArraySubInstanceType dictionary_type); |
| 93 static void RecordMapStats(Map* map, HeapObject* obj); |
| 94 static void RecordCodeStats(Map* map, HeapObject* obj); |
| 95 static void RecordSharedFunctionInfoStats(Map* map, HeapObject* obj); |
| 96 static void RecordFixedArrayStats(Map* map, HeapObject* obj); |
| 97 }; |
| 98 |
| 99 class MarkCompactObjectStatsVisitor |
| 100 : public StaticMarkingVisitor<MarkCompactObjectStatsVisitor> { |
| 101 public: |
| 102 static void Initialize(VisitorDispatchTable<Callback>* original); |
94 | 103 |
95 template <VisitorId id> | 104 template <VisitorId id> |
96 static inline void Visit(Map* map, HeapObject* obj); | 105 static inline void Visit(Map* map, HeapObject* obj); |
| 106 }; |
| 107 |
| 108 class IncrementalMarkingObjectStatsVisitor |
| 109 : public StaticMarkingVisitor<IncrementalMarkingObjectStatsVisitor> { |
| 110 public: |
| 111 static void Initialize(VisitorDispatchTable<Callback>* original); |
| 112 |
| 113 template <VisitorId id> |
| 114 static inline void Visit(Map* map, HeapObject* obj); |
97 }; | 115 }; |
98 | 116 |
99 } // namespace internal | 117 } // namespace internal |
100 } // namespace v8 | 118 } // namespace v8 |
101 | 119 |
102 #endif // V8_HEAP_OBJECT_STATS_H_ | 120 #endif // V8_HEAP_OBJECT_STATS_H_ |
OLD | NEW |