Index: runtime/vm/class_table.h |
diff --git a/runtime/vm/class_table.h b/runtime/vm/class_table.h |
index 6ea4dfa7034b94199d53dd94381ad803e3af19c8..41092387ce9c8258cb20c614560aae47f774636e 100644 |
--- a/runtime/vm/class_table.h |
+++ b/runtime/vm/class_table.h |
@@ -11,10 +11,42 @@ |
namespace dart { |
class Class; |
+class ClassStats; |
class ObjectPointerVisitor; |
class RawClass; |
class JSONStream; |
+class ClassHeapStats { |
+ public: |
+ intptr_t live_count_old_space; |
+ intptr_t live_count_new_space; |
+ intptr_t live_size_old_space; |
+ intptr_t live_size_new_space; |
+ |
+ // These fields are updated by generated code: |
+ intptr_t new_count_since_gc_new_space; |
+ intptr_t new_count_since_gc_old_space; |
+ intptr_t new_size_since_gc_new_space; |
+ intptr_t new_size_since_gc_old_space; |
+ |
+ static intptr_t new_count_since_gc_new_space_offset() { |
+ return OFFSET_OF(ClassHeapStats, new_count_since_gc_new_space); |
+ } |
+ static intptr_t new_count_since_gc_old_space_offset() { |
+ return OFFSET_OF(ClassHeapStats, new_count_since_gc_old_space); |
+ } |
+ static intptr_t new_size_since_gc_new_space_offset() { |
+ return OFFSET_OF(ClassHeapStats, new_size_since_gc_new_space); |
+ } |
+ static intptr_t new_size_since_gc_old_space_offset() { |
+ return OFFSET_OF(ClassHeapStats, new_size_since_gc_old_space); |
+ } |
+ |
+ void Initialize(); |
+ void ResetAtGC(); |
+}; |
+ |
+ |
class ClassTable { |
public: |
ClassTable(); |
@@ -48,14 +80,42 @@ class ClassTable { |
return OFFSET_OF(ClassTable, table_); |
} |
+ // Called whenever a class is allocated in the runtime. |
+ void ReportAllocationNewSpace(intptr_t cid, intptr_t size); |
+ void ReportAllocationOldSpace(intptr_t cid, intptr_t size); |
+ |
+ // Called whenever a major GC occurs. |
+ void Collect(); |
+ |
+ // 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_); |
+ } |
+ |
private: |
+ friend class MarkingVisitor; |
static const int initial_capacity_ = 512; |
static const int capacity_increment_ = 256; |
+ static bool CollectInstanceSizesForClass(intptr_t cid); |
+ |
intptr_t top_; |
intptr_t capacity_; |
RawClass** table_; |
+ ClassHeapStats* class_heap_stats_table_; |
+ |
+ ClassHeapStats* predefined_class_heap_stats_table_; |
+ |
+ ClassHeapStats* FindClassHeapStats(intptr_t cid); |
+ void ResetCounters(); |
+ void ReportLiveOldSpace(intptr_t cid, intptr_t size); |
+ void ReportLiveNewSpace(intptr_t cid, intptr_t size); |
DISALLOW_COPY_AND_ASSIGN(ClassTable); |
}; |