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" |
11 #include "vm/globals.h" | 11 #include "vm/globals.h" |
12 #include "vm/growable_array.h" | 12 #include "vm/growable_array.h" |
13 #include "vm/object.h" | 13 #include "vm/object.h" |
14 #include "vm/tags.h" | 14 #include "vm/tags.h" |
15 #include "vm/thread_interrupter.h" | 15 #include "vm/thread_interrupter.h" |
16 | 16 |
17 // Profiler sampling and stack walking support. | 17 // Profiler sampling and stack walking support. |
18 // NOTE: For service related code, see profile_service.h. | 18 // NOTE: For service related code, see profile_service.h. |
19 | 19 |
20 namespace dart { | 20 namespace dart { |
21 | 21 |
22 // Forward declarations. | 22 // Forward declarations. |
23 class ProcessedSample; | 23 class ProcessedSample; |
24 class ProcessedSampleBuffer; | 24 class ProcessedSampleBuffer; |
25 | 25 |
26 class Sample; | 26 class Sample; |
27 class SampleBuffer; | 27 class SampleBuffer; |
28 class ProfileTrieNode; | |
28 | 29 |
29 class Profiler : public AllStatic { | 30 class Profiler : public AllStatic { |
30 public: | 31 public: |
31 static void InitOnce(); | 32 static void InitOnce(); |
32 static void Shutdown(); | 33 static void Shutdown(); |
33 | 34 |
34 static void SetSampleDepth(intptr_t depth); | 35 static void SetSampleDepth(intptr_t depth); |
35 static void SetSamplePeriod(intptr_t period); | 36 static void SetSamplePeriod(intptr_t period); |
36 | 37 |
37 static SampleBuffer* sample_buffer() { | 38 static SampleBuffer* sample_buffer() { |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 uword At(intptr_t index) const { | 527 uword At(intptr_t index) const { |
527 ASSERT(index >= 0); | 528 ASSERT(index >= 0); |
528 ASSERT(index < length()); | 529 ASSERT(index < length()); |
529 return pcs_[index]; | 530 return pcs_[index]; |
530 } | 531 } |
531 | 532 |
532 // Timestamp sample was taken at. | 533 // Timestamp sample was taken at. |
533 int64_t timestamp() const { return timestamp_; } | 534 int64_t timestamp() const { return timestamp_; } |
534 void set_timestamp(int64_t timestamp) { timestamp_ = timestamp; } | 535 void set_timestamp(int64_t timestamp) { timestamp_ = timestamp; } |
535 | 536 |
537 ThreadId tid() const { return tid_; } | |
538 void set_tid(ThreadId tid) { tid_ = tid; } | |
539 | |
536 // The VM tag. | 540 // The VM tag. |
537 uword vm_tag() const { return vm_tag_; } | 541 uword vm_tag() const { return vm_tag_; } |
538 void set_vm_tag(uword tag) { vm_tag_ = tag; } | 542 void set_vm_tag(uword tag) { vm_tag_ = tag; } |
539 | 543 |
540 // The user tag. | 544 // The user tag. |
541 uword user_tag() const { return user_tag_; } | 545 uword user_tag() const { return user_tag_; } |
542 void set_user_tag(uword tag) { user_tag_ = tag; } | 546 void set_user_tag(uword tag) { user_tag_ = tag; } |
543 | 547 |
544 // The class id if this is an allocation profile sample. -1 otherwise. | 548 // The class id if this is an allocation profile sample. -1 otherwise. |
545 intptr_t allocation_cid() const { return allocation_cid_; } | 549 intptr_t allocation_cid() const { return allocation_cid_; } |
546 void set_allocation_cid(intptr_t cid) { allocation_cid_ = cid; } | 550 void set_allocation_cid(intptr_t cid) { allocation_cid_ = cid; } |
547 | 551 |
548 bool IsAllocationSample() const { | 552 bool IsAllocationSample() const { |
549 return allocation_cid_ > 0; | 553 return allocation_cid_ > 0; |
550 } | 554 } |
551 | 555 |
552 // Was the stack trace truncated? | 556 // Was the stack trace truncated? |
553 bool truncated() const { return truncated_; } | 557 bool truncated() const { return truncated_; } |
554 void set_truncated(bool truncated) { truncated_ = truncated; } | 558 void set_truncated(bool truncated) { truncated_ = truncated; } |
555 | 559 |
556 // Was the first frame in the stack trace executing? | 560 // Was the first frame in the stack trace executing? |
557 bool first_frame_executing() const { return first_frame_executing_; } | 561 bool first_frame_executing() const { return first_frame_executing_; } |
558 void set_first_frame_executing(bool first_frame_executing) { | 562 void set_first_frame_executing(bool first_frame_executing) { |
559 first_frame_executing_ = first_frame_executing; | 563 first_frame_executing_ = first_frame_executing; |
560 } | 564 } |
561 | 565 |
566 ProfileTrieNode* timeline_trie() const { return timeline_trie_; } | |
567 void set_timeline_trie(ProfileTrieNode* trie) { timeline_trie_ = trie; } | |
Cutch
2015/12/15 21:54:58
rewrite to:
ASSERT(timeline_trie_ == NULL);
timel
rmacnak
2015/12/16 00:14:20
Done.
| |
568 | |
562 private: | 569 private: |
563 void FixupCaller(const CodeLookupTable& clt, | 570 void FixupCaller(const CodeLookupTable& clt, |
564 uword pc_marker, | 571 uword pc_marker, |
565 uword* stack_buffer); | 572 uword* stack_buffer); |
566 | 573 |
567 void CheckForMissingDartFrame(const CodeLookupTable& clt, | 574 void CheckForMissingDartFrame(const CodeLookupTable& clt, |
568 const CodeDescriptor* code, | 575 const CodeDescriptor* code, |
569 uword pc_marker, | 576 uword pc_marker, |
570 uword* stack_buffer); | 577 uword* stack_buffer); |
571 | 578 |
572 ZoneGrowableArray<uword> pcs_; | 579 ZoneGrowableArray<uword> pcs_; |
573 int64_t timestamp_; | 580 int64_t timestamp_; |
581 ThreadId tid_; | |
574 uword vm_tag_; | 582 uword vm_tag_; |
575 uword user_tag_; | 583 uword user_tag_; |
576 intptr_t allocation_cid_; | 584 intptr_t allocation_cid_; |
577 bool truncated_; | 585 bool truncated_; |
578 bool first_frame_executing_; | 586 bool first_frame_executing_; |
587 ProfileTrieNode* timeline_trie_; | |
579 | 588 |
580 friend class SampleBuffer; | 589 friend class SampleBuffer; |
581 DISALLOW_COPY_AND_ASSIGN(ProcessedSample); | 590 DISALLOW_COPY_AND_ASSIGN(ProcessedSample); |
582 }; | 591 }; |
583 | 592 |
584 | 593 |
585 // A collection of |ProcessedSample|s. | 594 // A collection of |ProcessedSample|s. |
586 class ProcessedSampleBuffer : public ZoneAllocated { | 595 class ProcessedSampleBuffer : public ZoneAllocated { |
587 public: | 596 public: |
588 ProcessedSampleBuffer(); | 597 ProcessedSampleBuffer(); |
(...skipping 17 matching lines...) Expand all Loading... | |
606 private: | 615 private: |
607 ZoneGrowableArray<ProcessedSample*> samples_; | 616 ZoneGrowableArray<ProcessedSample*> samples_; |
608 CodeLookupTable* code_lookup_table_; | 617 CodeLookupTable* code_lookup_table_; |
609 | 618 |
610 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); | 619 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); |
611 }; | 620 }; |
612 | 621 |
613 } // namespace dart | 622 } // namespace dart |
614 | 623 |
615 #endif // VM_PROFILER_H_ | 624 #endif // VM_PROFILER_H_ |
OLD | NEW |