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