| Index: runtime/vm/heap_class_stats.h
|
| diff --git a/runtime/vm/heap_class_stats.h b/runtime/vm/heap_class_stats.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a752d142e72abd185c7dcb82dd8495331723592f
|
| --- /dev/null
|
| +++ b/runtime/vm/heap_class_stats.h
|
| @@ -0,0 +1,65 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +#ifndef VM_HEAP_CLASS_STATS_H_
|
| +#define VM_HEAP_CLASS_STATS_H_
|
| +
|
| +#include "platform/assert.h"
|
| +#include "vm/globals.h"
|
| +#include "vm/object.h"
|
| +
|
| +namespace dart {
|
| +
|
| +class JSONStream;
|
| +
|
| +// For each register class in an isolate we track the following:
|
| +// 1) Number of live instances in old space.
|
| +// 2) Number of live instances in new space.
|
| +// 3) Number of instances allocated since last full GC.
|
| +// Generated code will update (3) directly. See BumpAllocationCount.
|
| +struct HeapClassData {
|
| + intptr_t live_old_space;
|
| + intptr_t live_new_space;
|
| + // This field is updated by generated code.
|
| + intptr_t allocated_since_gc;
|
| + static intptr_t allocated_since_gc_offset() {
|
| + return OFFSET_OF(HeapClassData, allocated_since_gc);
|
| + }
|
| +};
|
| +
|
| +
|
| +class HeapClassStatistics {
|
| + public:
|
| + explicit HeapClassStatistics(Isolate* isolate);
|
| + ~HeapClassStatistics();
|
| +
|
| + // Called when a new class is registered in the isolate.
|
| + void RegisterClass(const Class& cls);
|
| +
|
| + // Called whenever a class is allocated in the runtime.
|
| + void AllocateClass(intptr_t cid);
|
| +
|
| + // Called whenever a major GC occurs.
|
| + void Collect();
|
| +
|
| + // Used by generated code for class allocations.
|
| + uword ClassStatsTableAddress();
|
| +
|
| + private:
|
| + friend class HeapClassStatsVisitor;
|
| + Isolate* isolate_;
|
| + HeapClassData* class_table_;
|
| + intptr_t class_table_size_;
|
| +
|
| + void ResetCounters();
|
| + void ReportLiveOldSpace(intptr_t cid);
|
| + void ReportLiveNewSpace(intptr_t cid);
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(HeapClassStatistics);
|
| +};
|
| +
|
| +
|
| +} // namespace dart
|
| +
|
| +#endif // VM_HEAP_CLASS_STATS_H_
|
|
|