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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/proccpuinfo.cc ('k') | runtime/vm/profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 RUNTIME_VM_PROFILER_H_ 5 #ifndef RUNTIME_VM_PROFILER_H_
6 #define RUNTIME_VM_PROFILER_H_ 6 #define RUNTIME_VM_PROFILER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/bitfield.h" 9 #include "vm/bitfield.h"
10 #include "vm/code_observers.h" 10 #include "vm/code_observers.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 46
47 class Profiler : public AllStatic { 47 class Profiler : public AllStatic {
48 public: 48 public:
49 static void InitOnce(); 49 static void InitOnce();
50 static void Shutdown(); 50 static void Shutdown();
51 51
52 static void SetSampleDepth(intptr_t depth); 52 static void SetSampleDepth(intptr_t depth);
53 static void SetSamplePeriod(intptr_t period); 53 static void SetSamplePeriod(intptr_t period);
54 54
55 static SampleBuffer* sample_buffer() { 55 static SampleBuffer* sample_buffer() { return sample_buffer_; }
56 return sample_buffer_;
57 }
58 56
59 static void DumpStackTrace(bool native_stack_trace = true); 57 static void DumpStackTrace(bool native_stack_trace = true);
60 58
61 static void SampleAllocation(Thread* thread, intptr_t cid); 59 static void SampleAllocation(Thread* thread, intptr_t cid);
62 60
63 // SampleThread is called from inside the signal handler and hence it is very 61 // SampleThread is called from inside the signal handler and hence it is very
64 // critical that the implementation of SampleThread does not do any of the 62 // critical that the implementation of SampleThread does not do any of the
65 // following: 63 // following:
66 // * Accessing TLS -- Because on Windows the callback will be running in a 64 // * Accessing TLS -- Because on Windows the callback will be running in a
67 // different thread. 65 // different thread.
68 // * Allocating memory -- Because this takes locks which may already be 66 // * Allocating memory -- Because this takes locks which may already be
69 // held, resulting in a dead lock. 67 // held, resulting in a dead lock.
70 // * Taking a lock -- See above. 68 // * Taking a lock -- See above.
71 static void SampleThread(Thread* thread, 69 static void SampleThread(Thread* thread, const InterruptedThreadState& state);
72 const InterruptedThreadState& state);
73 70
74 static ProfilerCounters counters() { 71 static ProfilerCounters counters() {
75 // Copies the counter values. 72 // Copies the counter values.
76 return counters_; 73 return counters_;
77 } 74 }
78 75
79 private: 76 private:
80 // Does not walk the thread's stack. 77 // Does not walk the thread's stack.
81 static void SampleThreadSingleFrame(Thread* thread, uintptr_t pc); 78 static void SampleThreadSingleFrame(Thread* thread, uintptr_t pc);
82 static bool initialized_; 79 static bool initialized_;
83 80
84 static SampleBuffer* sample_buffer_; 81 static SampleBuffer* sample_buffer_;
85 82
86 static ProfilerCounters counters_; 83 static ProfilerCounters counters_;
87 84
88 friend class Thread; 85 friend class Thread;
89 }; 86 };
90 87
91 88
92 class SampleVisitor : public ValueObject { 89 class SampleVisitor : public ValueObject {
93 public: 90 public:
94 explicit SampleVisitor(Isolate* isolate) : isolate_(isolate), visited_(0) { } 91 explicit SampleVisitor(Isolate* isolate) : isolate_(isolate), visited_(0) {}
95 virtual ~SampleVisitor() {} 92 virtual ~SampleVisitor() {}
96 93
97 virtual void VisitSample(Sample* sample) = 0; 94 virtual void VisitSample(Sample* sample) = 0;
98 95
99 intptr_t visited() const { 96 intptr_t visited() const { return visited_; }
100 return visited_;
101 }
102 97
103 void IncrementVisited() { 98 void IncrementVisited() { visited_++; }
104 visited_++;
105 }
106 99
107 Isolate* isolate() const { 100 Isolate* isolate() const { return isolate_; }
108 return isolate_;
109 }
110 101
111 private: 102 private:
112 Isolate* isolate_; 103 Isolate* isolate_;
113 intptr_t visited_; 104 intptr_t visited_;
114 105
115 DISALLOW_IMPLICIT_CONSTRUCTORS(SampleVisitor); 106 DISALLOW_IMPLICIT_CONSTRUCTORS(SampleVisitor);
116 }; 107 };
117 108
118 109
119 class SampleFilter : public ValueObject { 110 class SampleFilter : public ValueObject {
120 public: 111 public:
121 SampleFilter(Isolate* isolate, 112 SampleFilter(Isolate* isolate,
122 intptr_t thread_task_mask, 113 intptr_t thread_task_mask,
123 int64_t time_origin_micros, 114 int64_t time_origin_micros,
124 int64_t time_extent_micros) 115 int64_t time_extent_micros)
125 : isolate_(isolate), 116 : isolate_(isolate),
126 thread_task_mask_(thread_task_mask), 117 thread_task_mask_(thread_task_mask),
127 time_origin_micros_(time_origin_micros), 118 time_origin_micros_(time_origin_micros),
128 time_extent_micros_(time_extent_micros) { 119 time_extent_micros_(time_extent_micros) {
129 ASSERT(thread_task_mask != 0); 120 ASSERT(thread_task_mask != 0);
130 ASSERT(time_origin_micros_ >= -1); 121 ASSERT(time_origin_micros_ >= -1);
131 ASSERT(time_extent_micros_ >= -1); 122 ASSERT(time_extent_micros_ >= -1);
132 } 123 }
133 virtual ~SampleFilter() { } 124 virtual ~SampleFilter() {}
134 125
135 // Override this function. 126 // Override this function.
136 // Return |true| if |sample| passes the filter. 127 // Return |true| if |sample| passes the filter.
137 virtual bool FilterSample(Sample* sample) { 128 virtual bool FilterSample(Sample* sample) { return true; }
138 return true;
139 }
140 129
141 Isolate* isolate() const { 130 Isolate* isolate() const { return isolate_; }
142 return isolate_;
143 }
144 131
145 // Returns |true| if |sample| passes the time filter. 132 // Returns |true| if |sample| passes the time filter.
146 bool TimeFilterSample(Sample* sample); 133 bool TimeFilterSample(Sample* sample);
147 134
148 // Returns |true| if |sample| passes the thread task filter. 135 // Returns |true| if |sample| passes the thread task filter.
149 bool TaskFilterSample(Sample* sample); 136 bool TaskFilterSample(Sample* sample);
150 137
151 private: 138 private:
152 Isolate* isolate_; 139 Isolate* isolate_;
153 intptr_t thread_task_mask_; 140 intptr_t thread_task_mask_;
(...skipping 14 matching lines...) Expand all
168 class Sample { 155 class Sample {
169 public: 156 public:
170 void Init(Isolate* isolate, int64_t timestamp, ThreadId tid) { 157 void Init(Isolate* isolate, int64_t timestamp, ThreadId tid) {
171 Clear(); 158 Clear();
172 timestamp_ = timestamp; 159 timestamp_ = timestamp;
173 tid_ = tid; 160 tid_ = tid;
174 isolate_ = isolate; 161 isolate_ = isolate;
175 } 162 }
176 163
177 // Isolate sample was taken from. 164 // Isolate sample was taken from.
178 Isolate* isolate() const { 165 Isolate* isolate() const { return isolate_; }
179 return isolate_;
180 }
181 166
182 // Thread sample was taken on. 167 // Thread sample was taken on.
183 ThreadId tid() const { 168 ThreadId tid() const { return tid_; }
184 return tid_;
185 }
186 169
187 void Clear() { 170 void Clear() {
188 isolate_ = NULL; 171 isolate_ = NULL;
189 pc_marker_ = 0; 172 pc_marker_ = 0;
190 for (intptr_t i = 0; i < kStackBufferSizeInWords; i++) { 173 for (intptr_t i = 0; i < kStackBufferSizeInWords; i++) {
191 stack_buffer_[i] = 0; 174 stack_buffer_[i] = 0;
192 } 175 }
193 vm_tag_ = VMTag::kInvalidTagId; 176 vm_tag_ = VMTag::kInvalidTagId;
194 user_tag_ = UserTags::kDefaultUserTag; 177 user_tag_ = UserTags::kDefaultUserTag;
195 lr_ = 0; 178 lr_ = 0;
196 metadata_ = 0; 179 metadata_ = 0;
197 state_ = 0; 180 state_ = 0;
198 continuation_index_ = -1; 181 continuation_index_ = -1;
199 uword* pcs = GetPCArray(); 182 uword* pcs = GetPCArray();
200 for (intptr_t i = 0; i < pcs_length_; i++) { 183 for (intptr_t i = 0; i < pcs_length_; i++) {
201 pcs[i] = 0; 184 pcs[i] = 0;
202 } 185 }
203 set_head_sample(true); 186 set_head_sample(true);
204 } 187 }
205 188
206 // Timestamp sample was taken at. 189 // Timestamp sample was taken at.
207 int64_t timestamp() const { 190 int64_t timestamp() const { return timestamp_; }
208 return timestamp_;
209 }
210 191
211 // Top most pc. 192 // Top most pc.
212 uword pc() const { 193 uword pc() const { return At(0); }
213 return At(0);
214 }
215 194
216 // Get stack trace entry. 195 // Get stack trace entry.
217 uword At(intptr_t i) const { 196 uword At(intptr_t i) const {
218 ASSERT(i >= 0); 197 ASSERT(i >= 0);
219 ASSERT(i < pcs_length_); 198 ASSERT(i < pcs_length_);
220 uword* pcs = GetPCArray(); 199 uword* pcs = GetPCArray();
221 return pcs[i]; 200 return pcs[i];
222 } 201 }
223 202
224 // Set stack trace entry. 203 // Set stack trace entry.
225 void SetAt(intptr_t i, uword pc) { 204 void SetAt(intptr_t i, uword pc) {
226 ASSERT(i >= 0); 205 ASSERT(i >= 0);
227 ASSERT(i < pcs_length_); 206 ASSERT(i < pcs_length_);
228 uword* pcs = GetPCArray(); 207 uword* pcs = GetPCArray();
229 pcs[i] = pc; 208 pcs[i] = pc;
230 } 209 }
231 210
232 uword vm_tag() const { 211 uword vm_tag() const { return vm_tag_; }
233 return vm_tag_;
234 }
235 void set_vm_tag(uword tag) { 212 void set_vm_tag(uword tag) {
236 ASSERT(tag != VMTag::kInvalidTagId); 213 ASSERT(tag != VMTag::kInvalidTagId);
237 vm_tag_ = tag; 214 vm_tag_ = tag;
238 } 215 }
239 216
240 uword user_tag() const { 217 uword user_tag() const { return user_tag_; }
241 return user_tag_; 218 void set_user_tag(uword tag) { user_tag_ = tag; }
242 }
243 void set_user_tag(uword tag) {
244 user_tag_ = tag;
245 }
246 219
247 uword pc_marker() const { 220 uword pc_marker() const { return pc_marker_; }
248 return pc_marker_;
249 }
250 221
251 void set_pc_marker(uword pc_marker) { 222 void set_pc_marker(uword pc_marker) { pc_marker_ = pc_marker; }
252 pc_marker_ = pc_marker;
253 }
254 223
255 uword lr() const { 224 uword lr() const { return lr_; }
256 return lr_;
257 }
258 225
259 void set_lr(uword link_register) { 226 void set_lr(uword link_register) { lr_ = link_register; }
260 lr_ = link_register;
261 }
262 227
263 bool leaf_frame_is_dart() const { 228 bool leaf_frame_is_dart() const { return LeafFrameIsDart::decode(state_); }
264 return LeafFrameIsDart::decode(state_);
265 }
266 229
267 void set_leaf_frame_is_dart(bool leaf_frame_is_dart) { 230 void set_leaf_frame_is_dart(bool leaf_frame_is_dart) {
268 state_ = LeafFrameIsDart::update(leaf_frame_is_dart, state_); 231 state_ = LeafFrameIsDart::update(leaf_frame_is_dart, state_);
269 } 232 }
270 233
271 bool ignore_sample() const { 234 bool ignore_sample() const { return IgnoreBit::decode(state_); }
272 return IgnoreBit::decode(state_);
273 }
274 235
275 void set_ignore_sample(bool ignore_sample) { 236 void set_ignore_sample(bool ignore_sample) {
276 state_ = IgnoreBit::update(ignore_sample, state_); 237 state_ = IgnoreBit::update(ignore_sample, state_);
277 } 238 }
278 239
279 bool exit_frame_sample() const { 240 bool exit_frame_sample() const { return ExitFrameBit::decode(state_); }
280 return ExitFrameBit::decode(state_);
281 }
282 241
283 void set_exit_frame_sample(bool exit_frame_sample) { 242 void set_exit_frame_sample(bool exit_frame_sample) {
284 state_ = ExitFrameBit::update(exit_frame_sample, state_); 243 state_ = ExitFrameBit::update(exit_frame_sample, state_);
285 } 244 }
286 245
287 bool missing_frame_inserted() const { 246 bool missing_frame_inserted() const {
288 return MissingFrameInsertedBit::decode(state_); 247 return MissingFrameInsertedBit::decode(state_);
289 } 248 }
290 249
291 void set_missing_frame_inserted(bool missing_frame_inserted) { 250 void set_missing_frame_inserted(bool missing_frame_inserted) {
292 state_ = MissingFrameInsertedBit::update(missing_frame_inserted, state_); 251 state_ = MissingFrameInsertedBit::update(missing_frame_inserted, state_);
293 } 252 }
294 253
295 bool truncated_trace() const { 254 bool truncated_trace() const { return TruncatedTraceBit::decode(state_); }
296 return TruncatedTraceBit::decode(state_);
297 }
298 255
299 void set_truncated_trace(bool truncated_trace) { 256 void set_truncated_trace(bool truncated_trace) {
300 state_ = TruncatedTraceBit::update(truncated_trace, state_); 257 state_ = TruncatedTraceBit::update(truncated_trace, state_);
301 } 258 }
302 259
303 bool is_allocation_sample() const { 260 bool is_allocation_sample() const {
304 return ClassAllocationSampleBit::decode(state_); 261 return ClassAllocationSampleBit::decode(state_);
305 } 262 }
306 263
307 void set_is_allocation_sample(bool allocation_sample) { 264 void set_is_allocation_sample(bool allocation_sample) {
308 state_ = ClassAllocationSampleBit::update(allocation_sample, state_); 265 state_ = ClassAllocationSampleBit::update(allocation_sample, state_);
309 } 266 }
310 267
311 Thread::TaskKind thread_task() const { 268 Thread::TaskKind thread_task() const { return ThreadTaskBit::decode(state_); }
312 return ThreadTaskBit::decode(state_);
313 }
314 269
315 void set_thread_task(Thread::TaskKind task) { 270 void set_thread_task(Thread::TaskKind task) {
316 state_ = ThreadTaskBit::update(task, state_); 271 state_ = ThreadTaskBit::update(task, state_);
317 } 272 }
318 273
319 bool is_continuation_sample() const { 274 bool is_continuation_sample() const {
320 return ContinuationSampleBit::decode(state_); 275 return ContinuationSampleBit::decode(state_);
321 } 276 }
322 277
323 void SetContinuationIndex(intptr_t index) { 278 void SetContinuationIndex(intptr_t index) {
(...skipping 11 matching lines...) Expand all
335 290
336 intptr_t allocation_cid() const { 291 intptr_t allocation_cid() const {
337 ASSERT(is_allocation_sample()); 292 ASSERT(is_allocation_sample());
338 return metadata_; 293 return metadata_;
339 } 294 }
340 295
341 void set_head_sample(bool head_sample) { 296 void set_head_sample(bool head_sample) {
342 state_ = HeadSampleBit::update(head_sample, state_); 297 state_ = HeadSampleBit::update(head_sample, state_);
343 } 298 }
344 299
345 bool head_sample() const { 300 bool head_sample() const { return HeadSampleBit::decode(state_); }
346 return HeadSampleBit::decode(state_);
347 }
348 301
349 void set_metadata(intptr_t metadata) { 302 void set_metadata(intptr_t metadata) { metadata_ = metadata; }
350 metadata_ = metadata;
351 }
352 303
353 void SetAllocationCid(intptr_t cid) { 304 void SetAllocationCid(intptr_t cid) {
354 set_is_allocation_sample(true); 305 set_is_allocation_sample(true);
355 set_metadata(cid); 306 set_metadata(cid);
356 } 307 }
357 308
358 static void InitOnce(); 309 static void InitOnce();
359 310
360 static intptr_t instance_size() { 311 static intptr_t instance_size() { return instance_size_; }
361 return instance_size_;
362 }
363 312
364 uword* GetPCArray() const; 313 uword* GetPCArray() const;
365 314
366 static const int kStackBufferSizeInWords = 2; 315 static const int kStackBufferSizeInWords = 2;
367 uword* GetStackBuffer() { 316 uword* GetStackBuffer() { return &stack_buffer_[0]; }
368 return &stack_buffer_[0];
369 }
370 317
371 private: 318 private:
372 static intptr_t instance_size_; 319 static intptr_t instance_size_;
373 static intptr_t pcs_length_; 320 static intptr_t pcs_length_;
374 enum StateBits { 321 enum StateBits {
375 kHeadSampleBit = 0, 322 kHeadSampleBit = 0,
376 kLeafFrameIsDartBit = 1, 323 kLeafFrameIsDartBit = 1,
377 kIgnoreBit = 2, 324 kIgnoreBit = 2,
378 kExitFrameBit = 3, 325 kExitFrameBit = 3,
379 kMissingFrameInsertedBit = 4, 326 kMissingFrameInsertedBit = 4,
380 kTruncatedTraceBit = 5, 327 kTruncatedTraceBit = 5,
381 kClassAllocationSampleBit = 6, 328 kClassAllocationSampleBit = 6,
382 kContinuationSampleBit = 7, 329 kContinuationSampleBit = 7,
383 kThreadTaskBit = 8, // 5 bits. 330 kThreadTaskBit = 8, // 5 bits.
384 kNextFreeBit = 13, 331 kNextFreeBit = 13,
385 }; 332 };
386 class HeadSampleBit : public BitField<uword, bool, kHeadSampleBit, 1> {}; 333 class HeadSampleBit : public BitField<uword, bool, kHeadSampleBit, 1> {};
387 class LeafFrameIsDart : 334 class LeafFrameIsDart : public BitField<uword, bool, kLeafFrameIsDartBit, 1> {
388 public BitField<uword, bool, kLeafFrameIsDartBit, 1> {}; 335 };
389 class IgnoreBit : public BitField<uword, bool, kIgnoreBit, 1> {}; 336 class IgnoreBit : public BitField<uword, bool, kIgnoreBit, 1> {};
390 class ExitFrameBit : public BitField<uword, bool, kExitFrameBit, 1> {}; 337 class ExitFrameBit : public BitField<uword, bool, kExitFrameBit, 1> {};
391 class MissingFrameInsertedBit 338 class MissingFrameInsertedBit
392 : public BitField<uword, bool, kMissingFrameInsertedBit, 1> {}; 339 : public BitField<uword, bool, kMissingFrameInsertedBit, 1> {};
393 class TruncatedTraceBit : 340 class TruncatedTraceBit
394 public BitField<uword, bool, kTruncatedTraceBit, 1> {}; 341 : public BitField<uword, bool, kTruncatedTraceBit, 1> {};
395 class ClassAllocationSampleBit 342 class ClassAllocationSampleBit
396 : public BitField<uword, bool, kClassAllocationSampleBit, 1> {}; 343 : public BitField<uword, bool, kClassAllocationSampleBit, 1> {};
397 class ContinuationSampleBit 344 class ContinuationSampleBit
398 : public BitField<uword, bool, kContinuationSampleBit, 1> {}; 345 : public BitField<uword, bool, kContinuationSampleBit, 1> {};
399 class ThreadTaskBit 346 class ThreadTaskBit
400 : public BitField<uword, Thread::TaskKind, kThreadTaskBit, 5> {}; 347 : public BitField<uword, Thread::TaskKind, kThreadTaskBit, 5> {};
401 348
402 int64_t timestamp_; 349 int64_t timestamp_;
403 ThreadId tid_; 350 ThreadId tid_;
404 Isolate* isolate_; 351 Isolate* isolate_;
(...skipping 17 matching lines...) Expand all
422 class CodeDescriptor : public ZoneAllocated { 369 class CodeDescriptor : public ZoneAllocated {
423 public: 370 public:
424 explicit CodeDescriptor(const Code& code); 371 explicit CodeDescriptor(const Code& code);
425 372
426 uword Start() const; 373 uword Start() const;
427 374
428 uword Size() const; 375 uword Size() const;
429 376
430 int64_t CompileTimestamp() const; 377 int64_t CompileTimestamp() const;
431 378
432 RawCode* code() const { 379 RawCode* code() const { return code_.raw(); }
433 return code_.raw();
434 }
435 380
436 const char* Name() const { 381 const char* Name() const { return code_.Name(); }
437 return code_.Name();
438 }
439 382
440 bool Contains(uword pc) const { 383 bool Contains(uword pc) const {
441 uword end = Start() + Size(); 384 uword end = Start() + Size();
442 return (pc >= Start()) && (pc < end); 385 return (pc >= Start()) && (pc < end);
443 } 386 }
444 387
445 static int Compare(CodeDescriptor* const* a, 388 static int Compare(CodeDescriptor* const* a, CodeDescriptor* const* b) {
446 CodeDescriptor* const* b) {
447 ASSERT(a != NULL); 389 ASSERT(a != NULL);
448 ASSERT(b != NULL); 390 ASSERT(b != NULL);
449 391
450 uword a_start = (*a)->Start(); 392 uword a_start = (*a)->Start();
451 uword b_start = (*b)->Start(); 393 uword b_start = (*b)->Start();
452 394
453 if (a_start < b_start) { 395 if (a_start < b_start) {
454 return -1; 396 return -1;
455 } else if (a_start > b_start) { 397 } else if (a_start > b_start) {
456 return 1; 398 return 1;
457 } else { 399 } else {
458 return 0; 400 return 0;
459 } 401 }
460 } 402 }
461 403
462 private: 404 private:
463 const Code& code_; 405 const Code& code_;
464 406
465 DISALLOW_COPY_AND_ASSIGN(CodeDescriptor); 407 DISALLOW_COPY_AND_ASSIGN(CodeDescriptor);
466 }; 408 };
467 409
468 410
469 // Fast lookup of Dart code objects. 411 // Fast lookup of Dart code objects.
470 class CodeLookupTable : public ZoneAllocated { 412 class CodeLookupTable : public ZoneAllocated {
471 public: 413 public:
472 explicit CodeLookupTable(Thread* thread); 414 explicit CodeLookupTable(Thread* thread);
473 415
474 intptr_t length() const { 416 intptr_t length() const { return code_objects_.length(); }
475 return code_objects_.length();
476 }
477 417
478 const CodeDescriptor* At(intptr_t index) const { 418 const CodeDescriptor* At(intptr_t index) const {
479 return code_objects_.At(index); 419 return code_objects_.At(index);
480 } 420 }
481 421
482 const CodeDescriptor* FindCode(uword pc) const; 422 const CodeDescriptor* FindCode(uword pc) const;
483 423
484 private: 424 private:
485 void Build(Thread* thread); 425 void Build(Thread* thread);
486 426
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 504
565 505
566 // A |ProcessedSample| is a combination of 1 (or more) |Sample|(s) that have 506 // A |ProcessedSample| is a combination of 1 (or more) |Sample|(s) that have
567 // been merged into a logical sample. The raw data may have been processed to 507 // been merged into a logical sample. The raw data may have been processed to
568 // improve the quality of the stack trace. 508 // improve the quality of the stack trace.
569 class ProcessedSample : public ZoneAllocated { 509 class ProcessedSample : public ZoneAllocated {
570 public: 510 public:
571 ProcessedSample(); 511 ProcessedSample();
572 512
573 // Add |pc| to stack trace. 513 // Add |pc| to stack trace.
574 void Add(uword pc) { 514 void Add(uword pc) { pcs_.Add(pc); }
575 pcs_.Add(pc);
576 }
577 515
578 // Insert |pc| at |index|. 516 // Insert |pc| at |index|.
579 void InsertAt(intptr_t index, uword pc) { 517 void InsertAt(intptr_t index, uword pc) { pcs_.InsertAt(index, pc); }
580 pcs_.InsertAt(index, pc);
581 }
582 518
583 // Number of pcs in stack trace. 519 // Number of pcs in stack trace.
584 intptr_t length() const { return pcs_.length(); } 520 intptr_t length() const { return pcs_.length(); }
585 521
586 // Get |pc| at |index|. 522 // Get |pc| at |index|.
587 uword At(intptr_t index) const { 523 uword At(intptr_t index) const {
588 ASSERT(index >= 0); 524 ASSERT(index >= 0);
589 ASSERT(index < length()); 525 ASSERT(index < length());
590 return pcs_[index]; 526 return pcs_[index];
591 } 527 }
(...skipping 10 matching lines...) Expand all
602 void set_vm_tag(uword tag) { vm_tag_ = tag; } 538 void set_vm_tag(uword tag) { vm_tag_ = tag; }
603 539
604 // The user tag. 540 // The user tag.
605 uword user_tag() const { return user_tag_; } 541 uword user_tag() const { return user_tag_; }
606 void set_user_tag(uword tag) { user_tag_ = tag; } 542 void set_user_tag(uword tag) { user_tag_ = tag; }
607 543
608 // The class id if this is an allocation profile sample. -1 otherwise. 544 // The class id if this is an allocation profile sample. -1 otherwise.
609 intptr_t allocation_cid() const { return allocation_cid_; } 545 intptr_t allocation_cid() const { return allocation_cid_; }
610 void set_allocation_cid(intptr_t cid) { allocation_cid_ = cid; } 546 void set_allocation_cid(intptr_t cid) { allocation_cid_ = cid; }
611 547
612 bool IsAllocationSample() const { 548 bool IsAllocationSample() const { return allocation_cid_ > 0; }
613 return allocation_cid_ > 0;
614 }
615 549
616 // Was the stack trace truncated? 550 // Was the stack trace truncated?
617 bool truncated() const { return truncated_; } 551 bool truncated() const { return truncated_; }
618 void set_truncated(bool truncated) { truncated_ = truncated; } 552 void set_truncated(bool truncated) { truncated_ = truncated; }
619 553
620 // Was the first frame in the stack trace executing? 554 // Was the first frame in the stack trace executing?
621 bool first_frame_executing() const { return first_frame_executing_; } 555 bool first_frame_executing() const { return first_frame_executing_; }
622 void set_first_frame_executing(bool first_frame_executing) { 556 void set_first_frame_executing(bool first_frame_executing) {
623 first_frame_executing_ = first_frame_executing; 557 first_frame_executing_ = first_frame_executing;
624 } 558 }
(...skipping 27 matching lines...) Expand all
652 friend class SampleBuffer; 586 friend class SampleBuffer;
653 DISALLOW_COPY_AND_ASSIGN(ProcessedSample); 587 DISALLOW_COPY_AND_ASSIGN(ProcessedSample);
654 }; 588 };
655 589
656 590
657 // A collection of |ProcessedSample|s. 591 // A collection of |ProcessedSample|s.
658 class ProcessedSampleBuffer : public ZoneAllocated { 592 class ProcessedSampleBuffer : public ZoneAllocated {
659 public: 593 public:
660 ProcessedSampleBuffer(); 594 ProcessedSampleBuffer();
661 595
662 void Add(ProcessedSample* sample) { 596 void Add(ProcessedSample* sample) { samples_.Add(sample); }
663 samples_.Add(sample);
664 }
665 597
666 intptr_t length() const { 598 intptr_t length() const { return samples_.length(); }
667 return samples_.length();
668 }
669 599
670 ProcessedSample* At(intptr_t index) { 600 ProcessedSample* At(intptr_t index) { return samples_.At(index); }
671 return samples_.At(index);
672 }
673 601
674 const CodeLookupTable& code_lookup_table() const { 602 const CodeLookupTable& code_lookup_table() const {
675 return *code_lookup_table_; 603 return *code_lookup_table_;
676 } 604 }
677 605
678 private: 606 private:
679 ZoneGrowableArray<ProcessedSample*> samples_; 607 ZoneGrowableArray<ProcessedSample*> samples_;
680 CodeLookupTable* code_lookup_table_; 608 CodeLookupTable* code_lookup_table_;
681 609
682 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); 610 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer);
683 }; 611 };
684 612
685 } // namespace dart 613 } // namespace dart
686 614
687 #endif // RUNTIME_VM_PROFILER_H_ 615 #endif // RUNTIME_VM_PROFILER_H_
OLDNEW
« no previous file with comments | « runtime/vm/proccpuinfo.cc ('k') | runtime/vm/profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698