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 intptr_t live_count_old_space; | |
23 intptr_t live_count_new_space; | |
24 intptr_t live_size_old_space; | |
25 intptr_t live_size_new_space; | |
26 | |
27 // These fields are updated by generated code: | |
28 intptr_t new_count_since_gc_new_space; | |
Ivan Posva
2013/12/13 23:13:18
new_count_since_gc -> allocated
| |
29 intptr_t new_count_since_gc_old_space; | |
30 intptr_t new_size_since_gc_new_space; | |
31 intptr_t new_size_since_gc_old_space; | |
32 | |
33 static intptr_t new_count_since_gc_new_space_offset() { | |
34 return OFFSET_OF(ClassHeapStats, new_count_since_gc_new_space); | |
35 } | |
36 static intptr_t new_count_since_gc_old_space_offset() { | |
37 return OFFSET_OF(ClassHeapStats, new_count_since_gc_old_space); | |
38 } | |
39 static intptr_t new_size_since_gc_new_space_offset() { | |
40 return OFFSET_OF(ClassHeapStats, new_size_since_gc_new_space); | |
41 } | |
42 static intptr_t new_size_since_gc_old_space_offset() { | |
43 return OFFSET_OF(ClassHeapStats, new_size_since_gc_old_space); | |
44 } | |
45 | |
46 void Initialize(); | |
47 void ResetAtGC(); | |
48 }; | |
49 | |
17 | 50 |
18 class ClassTable { | 51 class ClassTable { |
19 public: | 52 public: |
20 ClassTable(); | 53 ClassTable(); |
21 ~ClassTable(); | 54 ~ClassTable(); |
22 | 55 |
23 RawClass* At(intptr_t index) const { | 56 RawClass* At(intptr_t index) const { |
24 ASSERT(IsValidIndex(index)); | 57 ASSERT(IsValidIndex(index)); |
25 return table_[index]; | 58 return table_[index]; |
26 } | 59 } |
(...skipping 14 matching lines...) Expand all Loading... | |
41 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 74 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
42 | 75 |
43 void Print(); | 76 void Print(); |
44 | 77 |
45 void PrintToJSONStream(JSONStream* stream); | 78 void PrintToJSONStream(JSONStream* stream); |
46 | 79 |
47 static intptr_t table_offset() { | 80 static intptr_t table_offset() { |
48 return OFFSET_OF(ClassTable, table_); | 81 return OFFSET_OF(ClassTable, table_); |
49 } | 82 } |
50 | 83 |
84 // Called whenever a class is allocated in the runtime. | |
85 void ReportAllocationNew(intptr_t cid, intptr_t size); | |
Ivan Posva
2013/12/13 23:13:18
UpdateAllocatedNew which would be in sync with Upd
| |
86 void ReportAllocationOld(intptr_t cid, intptr_t size); | |
87 | |
88 // Called whenever a major GC occurs. | |
89 void ResetCounters(); | |
90 | |
91 // Used by the generated code. | |
92 uword PredefinedClassHeapStatsTableAddress() { | |
93 return reinterpret_cast<uword>(predefined_class_heap_stats_table_); | |
94 } | |
95 | |
96 // Used by generated code. | |
97 uword ClassStatsTableAddress() { | |
98 return reinterpret_cast<uword>(&class_heap_stats_table_); | |
99 } | |
100 | |
51 private: | 101 private: |
102 friend class MarkingVisitor; | |
52 static const int initial_capacity_ = 512; | 103 static const int initial_capacity_ = 512; |
53 static const int capacity_increment_ = 256; | 104 static const int capacity_increment_ = 256; |
54 | 105 |
106 static bool CollectInstanceSizesForClass(intptr_t cid); | |
107 | |
55 intptr_t top_; | 108 intptr_t top_; |
56 intptr_t capacity_; | 109 intptr_t capacity_; |
57 | 110 |
58 RawClass** table_; | 111 RawClass** table_; |
112 ClassHeapStats* class_heap_stats_table_; | |
113 | |
114 ClassHeapStats* predefined_class_heap_stats_table_; | |
115 | |
116 ClassHeapStats* StatsAt(intptr_t cid); | |
117 void UpdateLiveOld(intptr_t cid, intptr_t size); | |
118 void UpdateLiveNew(intptr_t cid, intptr_t size); | |
59 | 119 |
60 DISALLOW_COPY_AND_ASSIGN(ClassTable); | 120 DISALLOW_COPY_AND_ASSIGN(ClassTable); |
61 }; | 121 }; |
62 | 122 |
63 } // namespace dart | 123 } // namespace dart |
64 | 124 |
65 #endif // VM_CLASS_TABLE_H_ | 125 #endif // VM_CLASS_TABLE_H_ |
OLD | NEW |