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 JSONArray; |
| 16 class JSONStream; |
14 class ObjectPointerVisitor; | 17 class ObjectPointerVisitor; |
15 class RawClass; | 18 class RawClass; |
16 class JSONStream; | 19 |
| 20 |
| 21 class ClassHeapStats { |
| 22 public: |
| 23 // Total allocated before GC. |
| 24 intptr_t allocated_before_gc_old_space; |
| 25 intptr_t allocated_before_gc_new_space; |
| 26 intptr_t allocated_size_before_gc_old_space; |
| 27 intptr_t allocated_size_before_gc_new_space; |
| 28 |
| 29 // Live after GC. |
| 30 intptr_t live_after_gc_old_space; |
| 31 intptr_t live_after_gc_new_space; |
| 32 intptr_t live_size_after_gc_old_space; |
| 33 intptr_t live_size_after_gc_new_space; |
| 34 |
| 35 // Allocated since GC. |
| 36 intptr_t allocated_since_gc_new_space; |
| 37 intptr_t allocated_since_gc_old_space; |
| 38 intptr_t allocated_size_since_gc_new_space; |
| 39 intptr_t allocated_size_since_gc_old_space; |
| 40 |
| 41 static intptr_t allocated_since_gc_new_space_offset() { |
| 42 return OFFSET_OF(ClassHeapStats, allocated_since_gc_new_space); |
| 43 } |
| 44 static intptr_t allocated_since_gc_old_space_offset() { |
| 45 return OFFSET_OF(ClassHeapStats, allocated_since_gc_old_space); |
| 46 } |
| 47 static intptr_t allocated_size_since_gc_new_space_offset() { |
| 48 return OFFSET_OF(ClassHeapStats, allocated_size_since_gc_new_space); |
| 49 } |
| 50 static intptr_t allocated_size_since_gc_old_space_offset() { |
| 51 return OFFSET_OF(ClassHeapStats, allocated_size_since_gc_old_space); |
| 52 } |
| 53 |
| 54 void Initialize(); |
| 55 void ResetAtNewGC(); |
| 56 void ResetAtOldGC(); |
| 57 void UpdateSize(intptr_t instance_size); |
| 58 void PrintTOJSONArray(const Class& cls, JSONArray* array); |
| 59 }; |
| 60 |
17 | 61 |
18 class ClassTable { | 62 class ClassTable { |
19 public: | 63 public: |
20 ClassTable(); | 64 ClassTable(); |
21 ~ClassTable(); | 65 ~ClassTable(); |
22 | 66 |
23 RawClass* At(intptr_t index) const { | 67 RawClass* At(intptr_t index) const { |
24 ASSERT(IsValidIndex(index)); | 68 ASSERT(IsValidIndex(index)); |
25 return table_[index]; | 69 return table_[index]; |
26 } | 70 } |
(...skipping 14 matching lines...) Expand all Loading... |
41 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 85 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
42 | 86 |
43 void Print(); | 87 void Print(); |
44 | 88 |
45 void PrintToJSONStream(JSONStream* stream); | 89 void PrintToJSONStream(JSONStream* stream); |
46 | 90 |
47 static intptr_t table_offset() { | 91 static intptr_t table_offset() { |
48 return OFFSET_OF(ClassTable, table_); | 92 return OFFSET_OF(ClassTable, table_); |
49 } | 93 } |
50 | 94 |
| 95 // Called whenever a class is allocated in the runtime. |
| 96 void UpdateAllocatedNew(intptr_t cid, intptr_t size); |
| 97 void UpdateAllocatedOld(intptr_t cid, intptr_t size); |
| 98 |
| 99 // Called whenever a old GC occurs. |
| 100 void ResetCountersOld(); |
| 101 // Called whenever a new GC occurs. |
| 102 void ResetCountersNew(); |
| 103 |
| 104 // Used by the generated code. |
| 105 uword PredefinedClassHeapStatsTableAddress() { |
| 106 return reinterpret_cast<uword>(predefined_class_heap_stats_table_); |
| 107 } |
| 108 |
| 109 // Used by generated code. |
| 110 uword ClassStatsTableAddress() { |
| 111 return reinterpret_cast<uword>(&class_heap_stats_table_); |
| 112 } |
| 113 |
| 114 |
| 115 void AllocationProfilePrintToJSONStream(JSONStream* stream); |
| 116 |
51 private: | 117 private: |
| 118 friend class MarkingVisitor; |
| 119 friend class ScavengerVisitor; |
| 120 friend class ClassHeapStatsTestHelper; |
52 static const int initial_capacity_ = 512; | 121 static const int initial_capacity_ = 512; |
53 static const int capacity_increment_ = 256; | 122 static const int capacity_increment_ = 256; |
54 | 123 |
| 124 static bool ShouldUpdateSizeForClassId(intptr_t cid); |
| 125 |
55 intptr_t top_; | 126 intptr_t top_; |
56 intptr_t capacity_; | 127 intptr_t capacity_; |
57 | 128 |
58 RawClass** table_; | 129 RawClass** table_; |
| 130 ClassHeapStats* class_heap_stats_table_; |
| 131 |
| 132 ClassHeapStats* predefined_class_heap_stats_table_; |
| 133 |
| 134 ClassHeapStats* StatsAt(intptr_t cid); |
| 135 void UpdateLiveOld(intptr_t cid, intptr_t size); |
| 136 void UpdateLiveNew(intptr_t cid, intptr_t size); |
59 | 137 |
60 DISALLOW_COPY_AND_ASSIGN(ClassTable); | 138 DISALLOW_COPY_AND_ASSIGN(ClassTable); |
61 }; | 139 }; |
62 | 140 |
63 } // namespace dart | 141 } // namespace dart |
64 | 142 |
65 #endif // VM_CLASS_TABLE_H_ | 143 #endif // VM_CLASS_TABLE_H_ |
OLD | NEW |