| 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 ClassStats; |
| 15 class JSONArray; | 15 class JSONArray; |
| 16 class JSONObject; | 16 class JSONObject; |
| 17 class JSONStream; | 17 class JSONStream; |
| 18 template<typename T> class MallocGrowableArray; |
| 18 class ObjectPointerVisitor; | 19 class ObjectPointerVisitor; |
| 19 class RawClass; | 20 class RawClass; |
| 20 | 21 |
| 21 template<typename T> | 22 template<typename T> |
| 22 class AllocStats { | 23 class AllocStats { |
| 23 public: | 24 public: |
| 24 T new_count; | 25 T new_count; |
| 25 T new_size; | 26 T new_size; |
| 26 T old_count; | 27 T old_count; |
| 27 T old_size; | 28 T old_size; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 private: | 115 private: |
| 115 // Recent old at start of last new GC (used to compute promoted_*). | 116 // Recent old at start of last new GC (used to compute promoted_*). |
| 116 intptr_t old_pre_new_gc_count_; | 117 intptr_t old_pre_new_gc_count_; |
| 117 intptr_t old_pre_new_gc_size_; | 118 intptr_t old_pre_new_gc_size_; |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 | 121 |
| 121 class ClassTable { | 122 class ClassTable { |
| 122 public: | 123 public: |
| 123 ClassTable(); | 124 ClassTable(); |
| 124 // Create a copy of the original class table only, without copying any of the | 125 // Creates a shallow copy of the original class table for some read-only |
| 125 // stats data. | 126 // access, without support for stats data. |
| 126 explicit ClassTable(ClassTable* original); | 127 explicit ClassTable(ClassTable* original); |
| 127 ~ClassTable(); | 128 ~ClassTable(); |
| 128 | 129 |
| 130 // Thread-safe. |
| 129 RawClass* At(intptr_t index) const { | 131 RawClass* At(intptr_t index) const { |
| 130 ASSERT(IsValidIndex(index)); | 132 ASSERT(IsValidIndex(index)); |
| 131 return table_[index]; | 133 return table_[index]; |
| 132 } | 134 } |
| 133 | 135 |
| 134 intptr_t IsValidIndex(intptr_t index) const { | 136 intptr_t IsValidIndex(intptr_t index) const { |
| 135 return (index > 0) && (index < top_); | 137 return (index > 0) && (index < top_); |
| 136 } | 138 } |
| 137 | 139 |
| 138 bool HasValidClassAt(intptr_t index) const { | 140 bool HasValidClassAt(intptr_t index) const { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // Used by generated code. | 184 // Used by generated code. |
| 183 uword ClassStatsTableAddress() { | 185 uword ClassStatsTableAddress() { |
| 184 return reinterpret_cast<uword>(&class_heap_stats_table_); | 186 return reinterpret_cast<uword>(&class_heap_stats_table_); |
| 185 } | 187 } |
| 186 | 188 |
| 187 ClassHeapStats* StatsWithUpdatedSize(intptr_t cid); | 189 ClassHeapStats* StatsWithUpdatedSize(intptr_t cid); |
| 188 | 190 |
| 189 void AllocationProfilePrintJSON(JSONStream* stream); | 191 void AllocationProfilePrintJSON(JSONStream* stream); |
| 190 void ResetAllocationAccumulators(); | 192 void ResetAllocationAccumulators(); |
| 191 | 193 |
| 194 // Deallocates table copies. Do not call during concurrent access to table. |
| 195 void FreeOldTables(); |
| 196 |
| 192 private: | 197 private: |
| 193 friend class MarkingVisitor; | 198 friend class MarkingVisitor; |
| 194 friend class ScavengerVisitor; | 199 friend class ScavengerVisitor; |
| 195 friend class ClassHeapStatsTestHelper; | 200 friend class ClassHeapStatsTestHelper; |
| 196 static const int initial_capacity_ = 512; | 201 static const int initial_capacity_ = 512; |
| 197 static const int capacity_increment_ = 256; | 202 static const int capacity_increment_ = 256; |
| 198 | 203 |
| 199 static bool ShouldUpdateSizeForClassId(intptr_t cid); | 204 static bool ShouldUpdateSizeForClassId(intptr_t cid); |
| 200 | 205 |
| 201 intptr_t top_; | 206 intptr_t top_; |
| 202 intptr_t capacity_; | 207 intptr_t capacity_; |
| 203 | 208 |
| 209 // Copy-on-write is used for table_, with old copies stored in old_tables_. |
| 204 RawClass** table_; | 210 RawClass** table_; |
| 211 MallocGrowableArray<RawClass**>* old_tables_; |
| 212 |
| 205 ClassHeapStats* class_heap_stats_table_; | 213 ClassHeapStats* class_heap_stats_table_; |
| 206 | 214 |
| 207 ClassHeapStats* predefined_class_heap_stats_table_; | 215 ClassHeapStats* predefined_class_heap_stats_table_; |
| 208 | 216 |
| 209 // May not have updated size for variable size classes. | 217 // May not have updated size for variable size classes. |
| 210 ClassHeapStats* PreliminaryStatsAt(intptr_t cid); | 218 ClassHeapStats* PreliminaryStatsAt(intptr_t cid); |
| 211 void UpdateLiveOld(intptr_t cid, intptr_t size); | 219 void UpdateLiveOld(intptr_t cid, intptr_t size); |
| 212 void UpdateLiveNew(intptr_t cid, intptr_t size); | 220 void UpdateLiveNew(intptr_t cid, intptr_t size); |
| 213 | 221 |
| 214 DISALLOW_COPY_AND_ASSIGN(ClassTable); | 222 DISALLOW_COPY_AND_ASSIGN(ClassTable); |
| 215 }; | 223 }; |
| 216 | 224 |
| 217 } // namespace dart | 225 } // namespace dart |
| 218 | 226 |
| 219 #endif // VM_CLASS_TABLE_H_ | 227 #endif // VM_CLASS_TABLE_H_ |
| OLD | NEW |