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

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

Issue 19870006: Support stacktrace and objecthistogram service commands (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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_HEAP_HISTOGRAM_H_ 5 #ifndef VM_HEAP_HISTOGRAM_H_
6 #define VM_HEAP_HISTOGRAM_H_ 6 #define VM_HEAP_HISTOGRAM_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
11 #include "vm/raw_object.h" 11 #include "vm/raw_object.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 class JSONStream;
16
15 DECLARE_FLAG(bool, print_object_histogram); 17 DECLARE_FLAG(bool, print_object_histogram);
16 18
17 // ObjectHistogram is used to compute an average object histogram over 19 // ObjectHistogram is used to compute an average object histogram over
18 // the lifetime of an isolate and then print the histogram when the isolate 20 // the lifetime of an isolate and then print the histogram when the isolate
19 // is shut down. Information is gathered at the back-edge of each major GC 21 // is shut down. Information is gathered at the back-edge of each major GC
20 // event. When an object histogram is collected for an isolate, an extra major 22 // event. When an object histogram is collected for an isolate, an extra major
21 // GC is performed just prior to shutdown. 23 // GC is performed just prior to shutdown.
22 class ObjectHistogram { 24 class ObjectHistogram {
23 public: 25 public:
24 explicit ObjectHistogram(Isolate* isolate); 26 explicit ObjectHistogram(Isolate* isolate);
25 ~ObjectHistogram(); 27 ~ObjectHistogram();
26 28
27 // Called when a new class is registered in the isolate. 29 // Called when a new class is registered in the isolate.
28 void RegisterClass(const Class& cls); 30 void RegisterClass(const Class& cls);
29 31
30 // Collect sample for the histogram. Called at back-edge of major GC. 32 // Collect sample for the histogram. Called at back-edge of major GC.
31 void Collect(); 33 void Collect();
32 34
33 // Print the histogram on stdout. 35 // Print the histogram on stdout.
34 void Print(); 36 void Print();
35 37
38 void PrintToJSONStream(JSONStream* stream);
39
36 private: 40 private:
37 // Add obj to histogram 41 // Add obj to histogram
38 void Add(RawObject* obj); 42 void Add(RawObject* obj);
39 43
40 // For each class an Element keeps track of the accounting. 44 // For each class an Element keeps track of the accounting.
41 class Element : public ValueObject { 45 class Element : public ValueObject {
42 public: 46 public:
43 void Add(int size) { 47 void Add(int size) {
44 count_++; 48 count_++;
45 size_ += size; 49 size_ += size;
46 } 50 }
47 intptr_t class_id_; 51 intptr_t class_id_;
48 intptr_t count_; 52 intptr_t count_;
49 intptr_t size_; 53 intptr_t size_;
50 }; 54 };
51 55
52 // Compare function for sorting result. 56 // Compare function for sorting result.
53 static int compare(const Element** a, const Element** b); 57 static int compare(const Element** a, const Element** b);
54 58
59 Element** GetSortedArray(int* array_length);
siva 2013/08/01 18:16:18 why 'int' and not 'intptr_t'? We should also docu
Cutch 2013/08/01 22:22:04 Done.
60
55 intptr_t major_gc_count_; 61 intptr_t major_gc_count_;
56 intptr_t table_length_; 62 intptr_t table_length_;
57 Element* table_; 63 Element* table_;
58 Isolate* isolate_; 64 Isolate* isolate_;
59 65
60 friend class ObjectHistogramVisitor; 66 friend class ObjectHistogramVisitor;
61 67
62 DISALLOW_COPY_AND_ASSIGN(ObjectHistogram); 68 DISALLOW_COPY_AND_ASSIGN(ObjectHistogram);
63 }; 69 };
64 70
65 } // namespace dart 71 } // namespace dart
66 72
67 #endif // VM_HEAP_HISTOGRAM_H_ 73 #endif // VM_HEAP_HISTOGRAM_H_
68 74
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698