| OLD | NEW |
| 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/bitfield.h" | 9 #include "vm/bitfield.h" |
| 10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 Isolate* isolate_; | 84 Isolate* isolate_; |
| 85 intptr_t visited_; | 85 intptr_t visited_; |
| 86 | 86 |
| 87 DISALLOW_IMPLICIT_CONSTRUCTORS(SampleVisitor); | 87 DISALLOW_IMPLICIT_CONSTRUCTORS(SampleVisitor); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 | 90 |
| 91 class SampleFilter : public ValueObject { | 91 class SampleFilter : public ValueObject { |
| 92 public: | 92 public: |
| 93 SampleFilter(Isolate* isolate, | 93 SampleFilter(Isolate* isolate, |
| 94 intptr_t thread_task_mask, |
| 94 int64_t time_origin_micros, | 95 int64_t time_origin_micros, |
| 95 int64_t time_extent_micros) | 96 int64_t time_extent_micros) |
| 96 : isolate_(isolate), | 97 : isolate_(isolate), |
| 98 thread_task_mask_(thread_task_mask), |
| 97 time_origin_micros_(time_origin_micros), | 99 time_origin_micros_(time_origin_micros), |
| 98 time_extent_micros_(time_extent_micros) { | 100 time_extent_micros_(time_extent_micros) { |
| 101 ASSERT(thread_task_mask != 0); |
| 99 ASSERT(time_origin_micros_ >= -1); | 102 ASSERT(time_origin_micros_ >= -1); |
| 100 ASSERT(time_extent_micros_ >= -1); | 103 ASSERT(time_extent_micros_ >= -1); |
| 101 } | 104 } |
| 102 virtual ~SampleFilter() { } | 105 virtual ~SampleFilter() { } |
| 103 | 106 |
| 104 // Override this function. | 107 // Override this function. |
| 105 // Return |true| if |sample| passes the filter. | 108 // Return |true| if |sample| passes the filter. |
| 106 virtual bool FilterSample(Sample* sample) { | 109 virtual bool FilterSample(Sample* sample) { |
| 107 return true; | 110 return true; |
| 108 } | 111 } |
| 109 | 112 |
| 110 Isolate* isolate() const { | 113 Isolate* isolate() const { |
| 111 return isolate_; | 114 return isolate_; |
| 112 } | 115 } |
| 113 | 116 |
| 114 // Returns |true| if |sample| passes the time filter. | 117 // Returns |true| if |sample| passes the time filter. |
| 115 bool TimeFilterSample(Sample* sample); | 118 bool TimeFilterSample(Sample* sample); |
| 116 | 119 |
| 120 // Returns |true| if |sample| passes the thread task filter. |
| 121 bool TaskFilterSample(Sample* sample); |
| 122 |
| 117 private: | 123 private: |
| 118 Isolate* isolate_; | 124 Isolate* isolate_; |
| 119 | 125 intptr_t thread_task_mask_; |
| 120 int64_t time_origin_micros_; | 126 int64_t time_origin_micros_; |
| 121 int64_t time_extent_micros_; | 127 int64_t time_extent_micros_; |
| 122 }; | 128 }; |
| 123 | 129 |
| 124 | 130 |
| 125 class ClearProfileVisitor : public SampleVisitor { | 131 class ClearProfileVisitor : public SampleVisitor { |
| 126 public: | 132 public: |
| 127 explicit ClearProfileVisitor(Isolate* isolate); | 133 explicit ClearProfileVisitor(Isolate* isolate); |
| 128 | 134 |
| 129 virtual void VisitSample(Sample* sample); | 135 virtual void VisitSample(Sample* sample); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 273 } |
| 268 | 274 |
| 269 bool is_allocation_sample() const { | 275 bool is_allocation_sample() const { |
| 270 return ClassAllocationSampleBit::decode(state_); | 276 return ClassAllocationSampleBit::decode(state_); |
| 271 } | 277 } |
| 272 | 278 |
| 273 void set_is_allocation_sample(bool allocation_sample) { | 279 void set_is_allocation_sample(bool allocation_sample) { |
| 274 state_ = ClassAllocationSampleBit::update(allocation_sample, state_); | 280 state_ = ClassAllocationSampleBit::update(allocation_sample, state_); |
| 275 } | 281 } |
| 276 | 282 |
| 277 bool is_mutator_thread() const { | 283 Thread::TaskKind thread_task() const { |
| 278 return MutatorThreadBit::decode(state_); | 284 return ThreadTaskBit::decode(state_); |
| 279 } | 285 } |
| 280 | 286 |
| 281 void set_is_mutator_thread(bool mutator_thread) { | 287 void set_thread_task(Thread::TaskKind task) { |
| 282 state_ = MutatorThreadBit::update(mutator_thread, state_); | 288 state_ = ThreadTaskBit::update(task, state_); |
| 283 } | 289 } |
| 284 | 290 |
| 285 bool is_continuation_sample() const { | 291 bool is_continuation_sample() const { |
| 286 return ContinuationSampleBit::decode(state_); | 292 return ContinuationSampleBit::decode(state_); |
| 287 } | 293 } |
| 288 | 294 |
| 289 void SetContinuationIndex(intptr_t index) { | 295 void SetContinuationIndex(intptr_t index) { |
| 290 ASSERT(!is_continuation_sample()); | 296 ASSERT(!is_continuation_sample()); |
| 291 ASSERT(continuation_index_ == -1); | 297 ASSERT(continuation_index_ == -1); |
| 292 state_ = ContinuationSampleBit::update(true, state_); | 298 state_ = ContinuationSampleBit::update(true, state_); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 static intptr_t pcs_length_; | 345 static intptr_t pcs_length_; |
| 340 enum StateBits { | 346 enum StateBits { |
| 341 kHeadSampleBit = 0, | 347 kHeadSampleBit = 0, |
| 342 kLeafFrameIsDartBit = 1, | 348 kLeafFrameIsDartBit = 1, |
| 343 kIgnoreBit = 2, | 349 kIgnoreBit = 2, |
| 344 kExitFrameBit = 3, | 350 kExitFrameBit = 3, |
| 345 kMissingFrameInsertedBit = 4, | 351 kMissingFrameInsertedBit = 4, |
| 346 kTruncatedTraceBit = 5, | 352 kTruncatedTraceBit = 5, |
| 347 kClassAllocationSampleBit = 6, | 353 kClassAllocationSampleBit = 6, |
| 348 kContinuationSampleBit = 7, | 354 kContinuationSampleBit = 7, |
| 349 kMutatorThreadBit = 8, | 355 kThreadTaskBit = 8, // 4 bits. |
| 356 kNextFreeBit = 12, |
| 350 }; | 357 }; |
| 351 class HeadSampleBit : public BitField<uword, bool, kHeadSampleBit, 1> {}; | 358 class HeadSampleBit : public BitField<uword, bool, kHeadSampleBit, 1> {}; |
| 352 class LeafFrameIsDart : | 359 class LeafFrameIsDart : |
| 353 public BitField<uword, bool, kLeafFrameIsDartBit, 1> {}; | 360 public BitField<uword, bool, kLeafFrameIsDartBit, 1> {}; |
| 354 class IgnoreBit : public BitField<uword, bool, kIgnoreBit, 1> {}; | 361 class IgnoreBit : public BitField<uword, bool, kIgnoreBit, 1> {}; |
| 355 class ExitFrameBit : public BitField<uword, bool, kExitFrameBit, 1> {}; | 362 class ExitFrameBit : public BitField<uword, bool, kExitFrameBit, 1> {}; |
| 356 class MissingFrameInsertedBit | 363 class MissingFrameInsertedBit |
| 357 : public BitField<uword, bool, kMissingFrameInsertedBit, 1> {}; | 364 : public BitField<uword, bool, kMissingFrameInsertedBit, 1> {}; |
| 358 class TruncatedTraceBit : | 365 class TruncatedTraceBit : |
| 359 public BitField<uword, bool, kTruncatedTraceBit, 1> {}; | 366 public BitField<uword, bool, kTruncatedTraceBit, 1> {}; |
| 360 class ClassAllocationSampleBit | 367 class ClassAllocationSampleBit |
| 361 : public BitField<uword, bool, kClassAllocationSampleBit, 1> {}; | 368 : public BitField<uword, bool, kClassAllocationSampleBit, 1> {}; |
| 362 class ContinuationSampleBit | 369 class ContinuationSampleBit |
| 363 : public BitField<uword, bool, kContinuationSampleBit, 1> {}; | 370 : public BitField<uword, bool, kContinuationSampleBit, 1> {}; |
| 364 class MutatorThreadBit | 371 class ThreadTaskBit |
| 365 : public BitField<uword, bool, kMutatorThreadBit, 1> {}; | 372 : public BitField<uword, Thread::TaskKind, kThreadTaskBit, 4> {}; |
| 366 | 373 |
| 367 int64_t timestamp_; | 374 int64_t timestamp_; |
| 368 ThreadId tid_; | 375 ThreadId tid_; |
| 369 Isolate* isolate_; | 376 Isolate* isolate_; |
| 370 uword pc_marker_; | 377 uword pc_marker_; |
| 371 uword stack_buffer_[kStackBufferSizeInWords]; | 378 uword stack_buffer_[kStackBufferSizeInWords]; |
| 372 uword vm_tag_; | 379 uword vm_tag_; |
| 373 uword user_tag_; | 380 uword user_tag_; |
| 374 uword metadata_; | 381 uword metadata_; |
| 375 uword lr_; | 382 uword lr_; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 private: | 651 private: |
| 645 ZoneGrowableArray<ProcessedSample*> samples_; | 652 ZoneGrowableArray<ProcessedSample*> samples_; |
| 646 CodeLookupTable* code_lookup_table_; | 653 CodeLookupTable* code_lookup_table_; |
| 647 | 654 |
| 648 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); | 655 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); |
| 649 }; | 656 }; |
| 650 | 657 |
| 651 } // namespace dart | 658 } // namespace dart |
| 652 | 659 |
| 653 #endif // VM_PROFILER_H_ | 660 #endif // VM_PROFILER_H_ |
| OLD | NEW |