Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: runtime/vm/heap_histogram.h

Issue 187133004: When reading a full snapshot use the class id from the snapshot instead of generating a new one. Th… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_HISTOGRAM_H_
6 #define VM_HEAP_HISTOGRAM_H_
7
8 #include "platform/assert.h"
9 #include "vm/flags.h"
10 #include "vm/globals.h"
11 #include "vm/raw_object.h"
12
13 namespace dart {
14
15 class JSONStream;
16
17 DECLARE_FLAG(bool, print_object_histogram);
18
19 // ObjectHistogram is used to compute an average object histogram over
20 // the lifetime of an isolate and then print the histogram when the isolate
21 // is shut down. Information is gathered at the back-edge of each major GC
22 // event. When an object histogram is collected for an isolate, an extra major
23 // GC is performed just prior to shutdown.
24 class ObjectHistogram {
25 public:
26 explicit ObjectHistogram(Isolate* isolate);
27 ~ObjectHistogram();
28
29 // Called when a new class is registered in the isolate.
30 void RegisterClass(const Class& cls);
31
32 // Collect sample for the histogram. Called at back-edge of major GC.
33 void Collect();
34
35 // Print the histogram on stdout.
36 void Print();
37
38 void PrintToJSONStream(JSONStream* stream);
39
40 private:
41 // Add obj to histogram
42 void Add(RawObject* obj);
43
44 // For each class an Element keeps track of the accounting.
45 class Element : public ValueObject {
46 public:
47 void Add(int size) {
48 count_++;
49 size_ += size;
50 }
51 intptr_t class_id_;
52 intptr_t count_;
53 intptr_t size_;
54 };
55
56 // Compare function for sorting result.
57 static int compare(const Element** a, const Element** b);
58
59 // This function returns a malloced array. Caller is responsible for calling
60 // free().
61 Element** GetSortedArray(intptr_t* array_length);
62
63 intptr_t major_gc_count_;
64 intptr_t table_length_;
65 Element* table_;
66 Isolate* isolate_;
67
68 friend class ObjectHistogramVisitor;
69
70 DISALLOW_COPY_AND_ASSIGN(ObjectHistogram);
71 };
72
73 } // namespace dart
74
75 #endif // VM_HEAP_HISTOGRAM_H_
76
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698