Index: runtime/vm/class_table.h |
diff --git a/runtime/vm/class_table.h b/runtime/vm/class_table.h |
index 6ea4dfa7034b94199d53dd94381ad803e3af19c8..c20e1b70665b6ca71fe444fb99bfffcdacecbddc 100644 |
--- a/runtime/vm/class_table.h |
+++ b/runtime/vm/class_table.h |
@@ -11,9 +11,53 @@ |
namespace dart { |
class Class; |
+class ClassStats; |
+class JSONArray; |
+class JSONStream; |
class ObjectPointerVisitor; |
class RawClass; |
-class JSONStream; |
+ |
+ |
+class ClassHeapStats { |
+ public: |
+ // Total allocated before GC. |
+ intptr_t allocated_before_gc_old_space; |
+ intptr_t allocated_before_gc_new_space; |
+ intptr_t allocated_size_before_gc_old_space; |
+ intptr_t allocated_size_before_gc_new_space; |
+ |
+ // Live after GC. |
+ intptr_t live_after_gc_old_space; |
+ intptr_t live_after_gc_new_space; |
+ intptr_t live_size_after_gc_old_space; |
+ intptr_t live_size_after_gc_new_space; |
+ |
+ // Allocated since GC. |
+ intptr_t allocated_since_gc_new_space; |
+ intptr_t allocated_since_gc_old_space; |
+ intptr_t allocated_size_since_gc_new_space; |
+ intptr_t allocated_size_since_gc_old_space; |
+ |
+ static intptr_t allocated_since_gc_new_space_offset() { |
+ return OFFSET_OF(ClassHeapStats, allocated_since_gc_new_space); |
+ } |
+ static intptr_t allocated_since_gc_old_space_offset() { |
+ return OFFSET_OF(ClassHeapStats, allocated_since_gc_old_space); |
+ } |
+ static intptr_t allocated_size_since_gc_new_space_offset() { |
+ return OFFSET_OF(ClassHeapStats, allocated_size_since_gc_new_space); |
+ } |
+ static intptr_t allocated_size_since_gc_old_space_offset() { |
+ return OFFSET_OF(ClassHeapStats, allocated_size_since_gc_old_space); |
+ } |
+ |
+ void Initialize(); |
+ void ResetAtNewGC(); |
+ void ResetAtOldGC(); |
+ void UpdateSize(intptr_t instance_size); |
+ void PrintTOJSONArray(const Class& cls, JSONArray* array); |
+}; |
+ |
class ClassTable { |
public: |
@@ -48,14 +92,48 @@ class ClassTable { |
return OFFSET_OF(ClassTable, table_); |
} |
+ // Called whenever a class is allocated in the runtime. |
+ void UpdateAllocatedNew(intptr_t cid, intptr_t size); |
+ void UpdateAllocatedOld(intptr_t cid, intptr_t size); |
+ |
+ // Called whenever a old GC occurs. |
+ void ResetCountersOld(); |
+ // Called whenever a new GC occurs. |
+ void ResetCountersNew(); |
+ |
+ // Used by the generated code. |
+ uword PredefinedClassHeapStatsTableAddress() { |
+ return reinterpret_cast<uword>(predefined_class_heap_stats_table_); |
+ } |
+ |
+ // Used by generated code. |
+ uword ClassStatsTableAddress() { |
+ return reinterpret_cast<uword>(&class_heap_stats_table_); |
+ } |
+ |
+ |
+ void AllocationProfilePrintToJSONStream(JSONStream* stream); |
+ |
private: |
+ friend class MarkingVisitor; |
+ friend class ScavengerVisitor; |
+ friend class ClassHeapStatsTestHelper; |
static const int initial_capacity_ = 512; |
static const int capacity_increment_ = 256; |
+ static bool ShouldUpdateSizeForClassId(intptr_t cid); |
+ |
intptr_t top_; |
intptr_t capacity_; |
RawClass** table_; |
+ ClassHeapStats* class_heap_stats_table_; |
+ |
+ ClassHeapStats* predefined_class_heap_stats_table_; |
+ |
+ ClassHeapStats* StatsAt(intptr_t cid); |
+ void UpdateLiveOld(intptr_t cid, intptr_t size); |
+ void UpdateLiveNew(intptr_t cid, intptr_t size); |
DISALLOW_COPY_AND_ASSIGN(ClassTable); |
}; |