OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_CLASS_TABLE_H_ | 5 #ifndef VM_CLASS_TABLE_H_ |
6 #define VM_CLASS_TABLE_H_ | 6 #define VM_CLASS_TABLE_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 class Class; | 13 class Class; |
| 14 class ClassStats; |
| 15 class JSONStream; |
14 class ObjectPointerVisitor; | 16 class ObjectPointerVisitor; |
15 class RawClass; | 17 class RawClass; |
16 class JSONStream; | 18 |
| 19 |
| 20 class ClassHeapStats { |
| 21 public: |
| 22 // Total allocated before GC. |
| 23 intptr_t allocated_before_gc_old_space; |
| 24 intptr_t allocated_before_gc_new_space; |
| 25 intptr_t allocated_size_before_gc_old_space; |
| 26 intptr_t allocated_size_before_gc_new_space; |
| 27 |
| 28 // Live after GC. |
| 29 intptr_t live_after_gc_old_space; |
| 30 intptr_t live_after_gc_new_space; |
| 31 intptr_t live_size_after_gc_old_space; |
| 32 intptr_t live_size_after_gc_new_space; |
| 33 |
| 34 // Allocated since GC. |
| 35 intptr_t allocated_since_gc_new_space; |
| 36 intptr_t allocated_since_gc_old_space; |
| 37 intptr_t allocated_size_since_gc_new_space; |
| 38 intptr_t allocated_size_since_gc_old_space; |
| 39 |
| 40 static intptr_t allocated_since_gc_new_space_offset() { |
| 41 return OFFSET_OF(ClassHeapStats, allocated_since_gc_new_space); |
| 42 } |
| 43 static intptr_t allocated_since_gc_old_space_offset() { |
| 44 return OFFSET_OF(ClassHeapStats, allocated_since_gc_old_space); |
| 45 } |
| 46 static intptr_t allocated_size_since_gc_new_space_offset() { |
| 47 return OFFSET_OF(ClassHeapStats, allocated_size_since_gc_new_space); |
| 48 } |
| 49 static intptr_t allocated_size_since_gc_old_space_offset() { |
| 50 return OFFSET_OF(ClassHeapStats, allocated_size_since_gc_old_space); |
| 51 } |
| 52 |
| 53 void Initialize(); |
| 54 void ResetAtNewGC(); |
| 55 void ResetAtOldGC(); |
| 56 }; |
| 57 |
17 | 58 |
18 class ClassTable { | 59 class ClassTable { |
19 public: | 60 public: |
20 ClassTable(); | 61 ClassTable(); |
21 ~ClassTable(); | 62 ~ClassTable(); |
22 | 63 |
23 RawClass* At(intptr_t index) const { | 64 RawClass* At(intptr_t index) const { |
24 ASSERT(IsValidIndex(index)); | 65 ASSERT(IsValidIndex(index)); |
25 return table_[index]; | 66 return table_[index]; |
26 } | 67 } |
(...skipping 14 matching lines...) Expand all Loading... |
41 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 82 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
42 | 83 |
43 void Print(); | 84 void Print(); |
44 | 85 |
45 void PrintToJSONStream(JSONStream* stream); | 86 void PrintToJSONStream(JSONStream* stream); |
46 | 87 |
47 static intptr_t table_offset() { | 88 static intptr_t table_offset() { |
48 return OFFSET_OF(ClassTable, table_); | 89 return OFFSET_OF(ClassTable, table_); |
49 } | 90 } |
50 | 91 |
| 92 // Called whenever a class is allocated in the runtime. |
| 93 void UpdateAllocatedNew(intptr_t cid, intptr_t size); |
| 94 void UpdateAllocatedOld(intptr_t cid, intptr_t size); |
| 95 |
| 96 // Called whenever a old GC occurs. |
| 97 void ResetCountersOld(); |
| 98 // Called whenever a new GC occurs. |
| 99 void ResetCountersNew(); |
| 100 |
| 101 // Used by the generated code. |
| 102 uword PredefinedClassHeapStatsTableAddress() { |
| 103 return reinterpret_cast<uword>(predefined_class_heap_stats_table_); |
| 104 } |
| 105 |
| 106 // Used by generated code. |
| 107 uword ClassStatsTableAddress() { |
| 108 return reinterpret_cast<uword>(&class_heap_stats_table_); |
| 109 } |
| 110 |
51 private: | 111 private: |
| 112 friend class MarkingVisitor; |
| 113 friend class ScavengerVisitor; |
| 114 friend class ClassHeapStatsTestHelper; |
52 static const int initial_capacity_ = 512; | 115 static const int initial_capacity_ = 512; |
53 static const int capacity_increment_ = 256; | 116 static const int capacity_increment_ = 256; |
54 | 117 |
| 118 static bool CollectInstanceSizesForClass(intptr_t cid); |
| 119 |
55 intptr_t top_; | 120 intptr_t top_; |
56 intptr_t capacity_; | 121 intptr_t capacity_; |
57 | 122 |
58 RawClass** table_; | 123 RawClass** table_; |
| 124 ClassHeapStats* class_heap_stats_table_; |
| 125 |
| 126 ClassHeapStats* predefined_class_heap_stats_table_; |
| 127 |
| 128 ClassHeapStats* StatsAt(intptr_t cid); |
| 129 void UpdateLiveOld(intptr_t cid, intptr_t size); |
| 130 void UpdateLiveNew(intptr_t cid, intptr_t size); |
59 | 131 |
60 DISALLOW_COPY_AND_ASSIGN(ClassTable); | 132 DISALLOW_COPY_AND_ASSIGN(ClassTable); |
61 }; | 133 }; |
62 | 134 |
63 } // namespace dart | 135 } // namespace dart |
64 | 136 |
65 #endif // VM_CLASS_TABLE_H_ | 137 #endif // VM_CLASS_TABLE_H_ |
OLD | NEW |