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 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 | 53 |
54 static void SetSampleDepth(intptr_t depth); | 54 static void SetSampleDepth(intptr_t depth); |
55 static void SetSamplePeriod(intptr_t period); | 55 static void SetSamplePeriod(intptr_t period); |
56 | 56 |
57 static SampleBuffer* sample_buffer() { return sample_buffer_; } | 57 static SampleBuffer* sample_buffer() { return sample_buffer_; } |
58 | 58 |
59 static void DumpStackTrace(void* context); | 59 static void DumpStackTrace(void* context); |
60 static void DumpStackTrace(); | 60 static void DumpStackTrace(); |
61 | 61 |
62 static void SampleAllocation(Thread* thread, intptr_t cid); | 62 static void SampleAllocation(Thread* thread, intptr_t cid); |
63 static Sample* SampleNativeAllocation(intptr_t skip_count); | 63 static Sample* SampleNativeAllocation(intptr_t skip_count, |
64 uword address, | |
65 uintptr_t allocation_size); | |
64 | 66 |
65 // SampleThread is called from inside the signal handler and hence it is very | 67 // SampleThread is called from inside the signal handler and hence it is very |
66 // critical that the implementation of SampleThread does not do any of the | 68 // critical that the implementation of SampleThread does not do any of the |
67 // following: | 69 // following: |
68 // * Accessing TLS -- Because on Windows the callback will be running in a | 70 // * Accessing TLS -- Because on Windows the callback will be running in a |
69 // different thread. | 71 // different thread. |
70 // * Allocating memory -- Because this takes locks which may already be | 72 // * Allocating memory -- Because this takes locks which may already be |
71 // held, resulting in a dead lock. | 73 // held, resulting in a dead lock. |
72 // * Taking a lock -- See above. | 74 // * Taking a lock -- See above. |
73 static void SampleThread(Thread* thread, const InterruptedThreadState& state); | 75 static void SampleThread(Thread* thread, const InterruptedThreadState& state); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 virtual bool FilterSample(Sample* sample) { return true; } | 136 virtual bool FilterSample(Sample* sample) { return true; } |
135 | 137 |
136 Dart_Port port() const { return port_; } | 138 Dart_Port port() const { return port_; } |
137 | 139 |
138 // Returns |true| if |sample| passes the time filter. | 140 // Returns |true| if |sample| passes the time filter. |
139 bool TimeFilterSample(Sample* sample); | 141 bool TimeFilterSample(Sample* sample); |
140 | 142 |
141 // Returns |true| if |sample| passes the thread task filter. | 143 // Returns |true| if |sample| passes the thread task filter. |
142 bool TaskFilterSample(Sample* sample); | 144 bool TaskFilterSample(Sample* sample); |
143 | 145 |
146 static const intptr_t kNoTaskFilter = -1; | |
147 | |
144 private: | 148 private: |
145 Dart_Port port_; | 149 Dart_Port port_; |
146 intptr_t thread_task_mask_; | 150 intptr_t thread_task_mask_; |
147 int64_t time_origin_micros_; | 151 int64_t time_origin_micros_; |
148 int64_t time_extent_micros_; | 152 int64_t time_extent_micros_; |
149 }; | 153 }; |
150 | 154 |
151 | 155 |
152 class ClearProfileVisitor : public SampleVisitor { | 156 class ClearProfileVisitor : public SampleVisitor { |
153 public: | 157 public: |
(...skipping 22 matching lines...) Expand all Loading... | |
176 port_ = ILLEGAL_PORT; | 180 port_ = ILLEGAL_PORT; |
177 pc_marker_ = 0; | 181 pc_marker_ = 0; |
178 for (intptr_t i = 0; i < kStackBufferSizeInWords; i++) { | 182 for (intptr_t i = 0; i < kStackBufferSizeInWords; i++) { |
179 stack_buffer_[i] = 0; | 183 stack_buffer_[i] = 0; |
180 } | 184 } |
181 vm_tag_ = VMTag::kInvalidTagId; | 185 vm_tag_ = VMTag::kInvalidTagId; |
182 user_tag_ = UserTags::kDefaultUserTag; | 186 user_tag_ = UserTags::kDefaultUserTag; |
183 lr_ = 0; | 187 lr_ = 0; |
184 metadata_ = 0; | 188 metadata_ = 0; |
185 state_ = 0; | 189 state_ = 0; |
190 native_allocation_address_ = 0; | |
191 native_allocation_size_bytes_ = 0; | |
186 continuation_index_ = -1; | 192 continuation_index_ = -1; |
187 uword* pcs = GetPCArray(); | 193 uword* pcs = GetPCArray(); |
188 for (intptr_t i = 0; i < pcs_length_; i++) { | 194 for (intptr_t i = 0; i < pcs_length_; i++) { |
189 pcs[i] = 0; | 195 pcs[i] = 0; |
190 } | 196 } |
191 set_head_sample(true); | 197 set_head_sample(true); |
192 } | 198 } |
193 | 199 |
194 // Timestamp sample was taken at. | 200 // Timestamp sample was taken at. |
195 int64_t timestamp() const { return timestamp_; } | 201 int64_t timestamp() const { return timestamp_; } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 | 278 |
273 bool is_native_allocation_sample() const { | 279 bool is_native_allocation_sample() const { |
274 return NativeAllocationSampleBit::decode(state_); | 280 return NativeAllocationSampleBit::decode(state_); |
275 } | 281 } |
276 | 282 |
277 void set_is_native_allocation_sample(bool native_allocation_sample) { | 283 void set_is_native_allocation_sample(bool native_allocation_sample) { |
278 state_ = | 284 state_ = |
279 NativeAllocationSampleBit::update(native_allocation_sample, state_); | 285 NativeAllocationSampleBit::update(native_allocation_sample, state_); |
280 } | 286 } |
281 | 287 |
288 void set_native_allocation_address(uword address) { | |
289 native_allocation_address_ = address; | |
290 } | |
291 | |
292 uword native_allocation_address() const { return native_allocation_address_; } | |
293 | |
294 uintptr_t native_allocation_size_bytes() const { | |
295 return native_allocation_size_bytes_; | |
296 } | |
297 | |
298 void set_native_allocation_size_bytes(uintptr_t size) { | |
299 native_allocation_size_bytes_ = size; | |
300 } | |
301 | |
282 Thread::TaskKind thread_task() const { return ThreadTaskBit::decode(state_); } | 302 Thread::TaskKind thread_task() const { return ThreadTaskBit::decode(state_); } |
283 | 303 |
284 void set_thread_task(Thread::TaskKind task) { | 304 void set_thread_task(Thread::TaskKind task) { |
285 state_ = ThreadTaskBit::update(task, state_); | 305 state_ = ThreadTaskBit::update(task, state_); |
286 } | 306 } |
287 | 307 |
288 bool is_continuation_sample() const { | 308 bool is_continuation_sample() const { |
289 return ContinuationSampleBit::decode(state_); | 309 return ContinuationSampleBit::decode(state_); |
290 } | 310 } |
291 | 311 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 int64_t timestamp_; | 386 int64_t timestamp_; |
367 ThreadId tid_; | 387 ThreadId tid_; |
368 Dart_Port port_; | 388 Dart_Port port_; |
369 uword pc_marker_; | 389 uword pc_marker_; |
370 uword stack_buffer_[kStackBufferSizeInWords]; | 390 uword stack_buffer_[kStackBufferSizeInWords]; |
371 uword vm_tag_; | 391 uword vm_tag_; |
372 uword user_tag_; | 392 uword user_tag_; |
373 uword metadata_; | 393 uword metadata_; |
374 uword lr_; | 394 uword lr_; |
375 uword state_; | 395 uword state_; |
396 uword native_allocation_address_; | |
397 uintptr_t native_allocation_size_bytes_; | |
376 intptr_t continuation_index_; | 398 intptr_t continuation_index_; |
377 | 399 |
378 /* There are a variable number of words that follow, the words hold the | 400 /* There are a variable number of words that follow, the words hold the |
379 * sampled pc values. Access via GetPCArray() */ | 401 * sampled pc values. Access via GetPCArray() */ |
380 | 402 |
381 DISALLOW_COPY_AND_ASSIGN(Sample); | 403 DISALLOW_COPY_AND_ASSIGN(Sample); |
382 }; | 404 }; |
383 | 405 |
384 | 406 |
385 // A Code object descriptor. | 407 // A Code object descriptor. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 // The user tag. | 579 // The user tag. |
558 uword user_tag() const { return user_tag_; } | 580 uword user_tag() const { return user_tag_; } |
559 void set_user_tag(uword tag) { user_tag_ = tag; } | 581 void set_user_tag(uword tag) { user_tag_ = tag; } |
560 | 582 |
561 // The class id if this is an allocation profile sample. -1 otherwise. | 583 // The class id if this is an allocation profile sample. -1 otherwise. |
562 intptr_t allocation_cid() const { return allocation_cid_; } | 584 intptr_t allocation_cid() const { return allocation_cid_; } |
563 void set_allocation_cid(intptr_t cid) { allocation_cid_ = cid; } | 585 void set_allocation_cid(intptr_t cid) { allocation_cid_ = cid; } |
564 | 586 |
565 bool IsAllocationSample() const { return allocation_cid_ > 0; } | 587 bool IsAllocationSample() const { return allocation_cid_ > 0; } |
566 | 588 |
589 bool is_native_allocation_sample() const { return native_allocation_sample_; } | |
590 void set_is_native_allocation_sample(bool native_allocation_sample) { | |
591 native_allocation_sample_ = native_allocation_sample; | |
Cutch
2017/03/21 20:27:11
do you need this as a separate bool? Couldn't this
bkonyi
2017/03/22 21:25:21
Done.
| |
592 } | |
593 | |
594 uintptr_t native_allocation_size_bytes() const { | |
595 return native_allocation_size_bytes_; | |
596 } | |
597 void set_native_allocation_size_bytes(uintptr_t allocation_size) { | |
598 native_allocation_size_bytes_ = allocation_size; | |
599 } | |
600 | |
567 // Was the stack trace truncated? | 601 // Was the stack trace truncated? |
568 bool truncated() const { return truncated_; } | 602 bool truncated() const { return truncated_; } |
569 void set_truncated(bool truncated) { truncated_ = truncated; } | 603 void set_truncated(bool truncated) { truncated_ = truncated; } |
570 | 604 |
571 // Was the first frame in the stack trace executing? | 605 // Was the first frame in the stack trace executing? |
572 bool first_frame_executing() const { return first_frame_executing_; } | 606 bool first_frame_executing() const { return first_frame_executing_; } |
573 void set_first_frame_executing(bool first_frame_executing) { | 607 void set_first_frame_executing(bool first_frame_executing) { |
574 first_frame_executing_ = first_frame_executing; | 608 first_frame_executing_ = first_frame_executing; |
575 } | 609 } |
576 | 610 |
(...skipping 14 matching lines...) Expand all Loading... | |
591 uword* stack_buffer); | 625 uword* stack_buffer); |
592 | 626 |
593 ZoneGrowableArray<uword> pcs_; | 627 ZoneGrowableArray<uword> pcs_; |
594 int64_t timestamp_; | 628 int64_t timestamp_; |
595 ThreadId tid_; | 629 ThreadId tid_; |
596 uword vm_tag_; | 630 uword vm_tag_; |
597 uword user_tag_; | 631 uword user_tag_; |
598 intptr_t allocation_cid_; | 632 intptr_t allocation_cid_; |
599 bool truncated_; | 633 bool truncated_; |
600 bool first_frame_executing_; | 634 bool first_frame_executing_; |
635 bool native_allocation_sample_; | |
636 uword native_allocation_address_; | |
637 uintptr_t native_allocation_size_bytes_; | |
601 ProfileTrieNode* timeline_trie_; | 638 ProfileTrieNode* timeline_trie_; |
602 | 639 |
603 friend class SampleBuffer; | 640 friend class SampleBuffer; |
604 DISALLOW_COPY_AND_ASSIGN(ProcessedSample); | 641 DISALLOW_COPY_AND_ASSIGN(ProcessedSample); |
605 }; | 642 }; |
606 | 643 |
607 | 644 |
608 // A collection of |ProcessedSample|s. | 645 // A collection of |ProcessedSample|s. |
609 class ProcessedSampleBuffer : public ZoneAllocated { | 646 class ProcessedSampleBuffer : public ZoneAllocated { |
610 public: | 647 public: |
(...skipping 12 matching lines...) Expand all Loading... | |
623 private: | 660 private: |
624 ZoneGrowableArray<ProcessedSample*> samples_; | 661 ZoneGrowableArray<ProcessedSample*> samples_; |
625 CodeLookupTable* code_lookup_table_; | 662 CodeLookupTable* code_lookup_table_; |
626 | 663 |
627 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); | 664 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); |
628 }; | 665 }; |
629 | 666 |
630 } // namespace dart | 667 } // namespace dart |
631 | 668 |
632 #endif // RUNTIME_VM_PROFILER_H_ | 669 #endif // RUNTIME_VM_PROFILER_H_ |
OLD | NEW |