OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 #ifndef VM_HEAP_CLASS_STATS_H_ |
| 6 #define VM_HEAP_CLASS_STATS_H_ |
| 7 |
| 8 #include "platform/assert.h" |
| 9 #include "vm/globals.h" |
| 10 #include "vm/object.h" |
| 11 |
| 12 namespace dart { |
| 13 |
| 14 class JSONStream; |
| 15 |
| 16 // For each register class in an isolate we track the following: |
| 17 // 1) Number of live instances in old space. |
| 18 // 2) Number of live instances in new space. |
| 19 // 3) Number of instances allocated since last full GC. |
| 20 // Generated code will update (3) directly. See BumpAllocationCount. |
| 21 struct HeapClassData { |
| 22 intptr_t live_old_space; |
| 23 intptr_t live_new_space; |
| 24 // This field is updated by generated code. |
| 25 intptr_t allocated_since_gc; |
| 26 static intptr_t allocated_since_gc_offset() { |
| 27 return OFFSET_OF(HeapClassData, allocated_since_gc); |
| 28 } |
| 29 }; |
| 30 |
| 31 |
| 32 class HeapClassStatistics { |
| 33 public: |
| 34 explicit HeapClassStatistics(Isolate* isolate); |
| 35 ~HeapClassStatistics(); |
| 36 |
| 37 // Called when a new class is registered in the isolate. |
| 38 void RegisterClass(const Class& cls); |
| 39 |
| 40 // Called whenever a class is allocated in the runtime. |
| 41 void AllocateClass(intptr_t cid); |
| 42 |
| 43 // Called whenever a major GC occurs. |
| 44 void Collect(); |
| 45 |
| 46 // Used by generated code for class allocations. |
| 47 uword ClassStatsTableAddress(); |
| 48 |
| 49 private: |
| 50 friend class HeapClassStatsVisitor; |
| 51 Isolate* isolate_; |
| 52 HeapClassData* class_table_; |
| 53 intptr_t class_table_size_; |
| 54 |
| 55 void ResetCounters(); |
| 56 void ReportLiveOldSpace(intptr_t cid); |
| 57 void ReportLiveNewSpace(intptr_t cid); |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(HeapClassStatistics); |
| 60 }; |
| 61 |
| 62 |
| 63 } // namespace dart |
| 64 |
| 65 #endif // VM_HEAP_CLASS_STATS_H_ |
OLD | NEW |