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

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

Issue 201213004: Use VM tag in profile and add stack trace trie (Closed) Base URL: https://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
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_PROFILER_H_ 5 #ifndef VM_PROFILER_H_
6 #define VM_PROFILER_H_ 6 #define VM_PROFILER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/code_observers.h" 9 #include "vm/code_observers.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
11 #include "vm/tags.h"
11 #include "vm/thread.h" 12 #include "vm/thread.h"
12 #include "vm/thread_interrupter.h" 13 #include "vm/thread_interrupter.h"
13 14
14 namespace dart { 15 namespace dart {
15 16
16 // Forward declarations. 17 // Forward declarations.
17 class JSONArray; 18 class JSONArray;
18 class JSONStream; 19 class JSONStream;
19 class ProfilerCodeRegionTable; 20 class ProfilerCodeRegionTable;
20 class Sample; 21 class Sample;
21 class SampleBuffer; 22 class SampleBuffer;
22 23
23 // Profiler 24 // Profiler
24 class Profiler : public AllStatic { 25 class Profiler : public AllStatic {
25 public: 26 public:
26 static void InitOnce(); 27 static void InitOnce();
27 static void Shutdown(); 28 static void Shutdown();
28 29
29 static void SetSampleDepth(intptr_t depth); 30 static void SetSampleDepth(intptr_t depth);
30 static void SetSamplePeriod(intptr_t period); 31 static void SetSamplePeriod(intptr_t period);
31 32
32 static void InitProfilingForIsolate(Isolate* isolate, 33 static void InitProfilingForIsolate(Isolate* isolate,
33 bool shared_buffer = true); 34 bool shared_buffer = true);
34 static void ShutdownProfilingForIsolate(Isolate* isolate); 35 static void ShutdownProfilingForIsolate(Isolate* isolate);
35 36
36 static void BeginExecution(Isolate* isolate); 37 static void BeginExecution(Isolate* isolate);
37 static void EndExecution(Isolate* isolate); 38 static void EndExecution(Isolate* isolate);
38 39
39 static void PrintToJSONStream(Isolate* isolate, JSONStream* stream, 40 static void PrintToJSONStream(Isolate* isolate, JSONStream* stream,
40 bool full); 41 bool full, bool use_tags);
41 static void WriteProfile(Isolate* isolate); 42 static void WriteProfile(Isolate* isolate);
42 43
43 static SampleBuffer* sample_buffer() { 44 static SampleBuffer* sample_buffer() {
44 return sample_buffer_; 45 return sample_buffer_;
45 } 46 }
46 47
47 private: 48 private:
48 static bool initialized_; 49 static bool initialized_;
49 static Monitor* monitor_; 50 static Monitor* monitor_;
50 51
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // The maximum number of stack frames a sample can hold. 103 // The maximum number of stack frames a sample can hold.
103 #define kSampleFramesSize 256 104 #define kSampleFramesSize 256
104 105
105 // Each Sample holds a stack trace from an isolate. 106 // Each Sample holds a stack trace from an isolate.
106 class Sample { 107 class Sample {
107 public: 108 public:
108 void Init(Isolate* isolate, int64_t timestamp, ThreadId tid) { 109 void Init(Isolate* isolate, int64_t timestamp, ThreadId tid) {
109 timestamp_ = timestamp; 110 timestamp_ = timestamp;
110 tid_ = tid; 111 tid_ = tid;
111 isolate_ = isolate; 112 isolate_ = isolate;
113 vm_tag_ = VMTag::kInvalidTagId;
112 for (intptr_t i = 0; i < kSampleFramesSize; i++) { 114 for (intptr_t i = 0; i < kSampleFramesSize; i++) {
113 pcs_[i] = 0; 115 pcs_[i] = 0;
114 } 116 }
115 } 117 }
116 118
117 // Isolate sample was taken from. 119 // Isolate sample was taken from.
118 Isolate* isolate() const { 120 Isolate* isolate() const {
119 return isolate_; 121 return isolate_;
120 } 122 }
121 123
122 // Timestamp sample was taken at. 124 // Timestamp sample was taken at.
123 int64_t timestamp() const { 125 int64_t timestamp() const {
124 return timestamp_; 126 return timestamp_;
125 } 127 }
126 128
127 // Get stack trace entry. 129 // Get stack trace entry.
128 uword At(intptr_t i) const { 130 uword At(intptr_t i) const {
129 ASSERT(i >= 0); 131 ASSERT(i >= 0);
130 ASSERT(i < kSampleFramesSize); 132 ASSERT(i < kSampleFramesSize);
131 return pcs_[i]; 133 return pcs_[i];
132 } 134 }
133 135
134 // Set stack trace entry. 136 // Set stack trace entry.
135 void SetAt(intptr_t i, uword pc) { 137 void SetAt(intptr_t i, uword pc) {
136 ASSERT(i >= 0); 138 ASSERT(i >= 0);
137 ASSERT(i < kSampleFramesSize); 139 ASSERT(i < kSampleFramesSize);
138 pcs_[i] = pc; 140 pcs_[i] = pc;
139 } 141 }
140 142
143 uword vm_tag() const {
144 return vm_tag_;
145 }
146 void set_vm_tag(uword tag) {
147 ASSERT(tag != VMTag::kInvalidTagId);
148 vm_tag_ = tag;
149 }
150
141 private: 151 private:
142 int64_t timestamp_; 152 int64_t timestamp_;
143 ThreadId tid_; 153 ThreadId tid_;
144 Isolate* isolate_; 154 Isolate* isolate_;
155 uword vm_tag_;
145 uword pcs_[kSampleFramesSize]; 156 uword pcs_[kSampleFramesSize];
146 }; 157 };
147 158
148 159
149 // Ring buffer of Samples that is (usually) shared by many isolates. 160 // Ring buffer of Samples that is (usually) shared by many isolates.
150 class SampleBuffer { 161 class SampleBuffer {
151 public: 162 public:
152 static const intptr_t kDefaultBufferCapacity = 120000; // 2 minutes @ 1000hz. 163 static const intptr_t kDefaultBufferCapacity = 120000; // 2 minutes @ 1000hz.
153 164
154 explicit SampleBuffer(intptr_t capacity = kDefaultBufferCapacity) { 165 explicit SampleBuffer(intptr_t capacity = kDefaultBufferCapacity) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 intptr_t capacity_; 216 intptr_t capacity_;
206 uintptr_t cursor_; 217 uintptr_t cursor_;
207 218
208 DISALLOW_COPY_AND_ASSIGN(SampleBuffer); 219 DISALLOW_COPY_AND_ASSIGN(SampleBuffer);
209 }; 220 };
210 221
211 222
212 } // namespace dart 223 } // namespace dart
213 224
214 #endif // VM_PROFILER_H_ 225 #endif // VM_PROFILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698