OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 #include "vm/profiler_service.h" | 5 #include "vm/profiler_service.h" |
6 | 6 |
7 #include "vm/growable_array.h" | 7 #include "vm/growable_array.h" |
8 #include "vm/hash_map.h" | 8 #include "vm/hash_map.h" |
9 #include "vm/log.h" | 9 #include "vm/log.h" |
10 #include "vm/native_symbol.h" | 10 #include "vm/native_symbol.h" |
(...skipping 2652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2663 profile.PrintTimelineJSON(stream); | 2663 profile.PrintTimelineJSON(stream); |
2664 } else { | 2664 } else { |
2665 profile.PrintProfileJSON(stream); | 2665 profile.PrintProfileJSON(stream); |
2666 } | 2666 } |
2667 } | 2667 } |
2668 } | 2668 } |
2669 | 2669 |
2670 | 2670 |
2671 class NoAllocationSampleFilter : public SampleFilter { | 2671 class NoAllocationSampleFilter : public SampleFilter { |
2672 public: | 2672 public: |
2673 NoAllocationSampleFilter(Isolate* isolate, | 2673 NoAllocationSampleFilter(Dart_Port port, |
2674 intptr_t thread_task_mask, | 2674 intptr_t thread_task_mask, |
2675 int64_t time_origin_micros, | 2675 int64_t time_origin_micros, |
2676 int64_t time_extent_micros) | 2676 int64_t time_extent_micros) |
2677 : SampleFilter(isolate, | 2677 : SampleFilter(port, |
2678 thread_task_mask, | 2678 thread_task_mask, |
2679 time_origin_micros, | 2679 time_origin_micros, |
2680 time_extent_micros) {} | 2680 time_extent_micros) {} |
2681 | 2681 |
2682 bool FilterSample(Sample* sample) { return !sample->is_allocation_sample(); } | 2682 bool FilterSample(Sample* sample) { |
2683 return !sample->is_allocation_sample() && | |
2684 !sample->is_native_allocation_sample(); | |
2685 } | |
2683 }; | 2686 }; |
2684 | 2687 |
2685 | 2688 |
2686 void ProfilerService::PrintJSON(JSONStream* stream, | 2689 void ProfilerService::PrintJSON(JSONStream* stream, |
2687 Profile::TagOrder tag_order, | 2690 Profile::TagOrder tag_order, |
2688 intptr_t extra_tags, | 2691 intptr_t extra_tags, |
2689 int64_t time_origin_micros, | 2692 int64_t time_origin_micros, |
2690 int64_t time_extent_micros) { | 2693 int64_t time_extent_micros) { |
2691 Thread* thread = Thread::Current(); | 2694 Thread* thread = Thread::Current(); |
2692 Isolate* isolate = thread->isolate(); | 2695 Isolate* isolate = thread->isolate(); |
2693 NoAllocationSampleFilter filter(isolate, Thread::kMutatorTask, | 2696 NoAllocationSampleFilter filter(isolate->main_port(), Thread::kMutatorTask, |
2694 time_origin_micros, time_extent_micros); | 2697 time_origin_micros, time_extent_micros); |
2695 const bool as_timeline = false; | 2698 const bool as_timeline = false; |
2696 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline); | 2699 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline); |
2697 } | 2700 } |
2698 | 2701 |
2699 | 2702 |
2700 class ClassAllocationSampleFilter : public SampleFilter { | 2703 class ClassAllocationSampleFilter : public SampleFilter { |
2701 public: | 2704 public: |
2702 ClassAllocationSampleFilter(Isolate* isolate, | 2705 ClassAllocationSampleFilter(Dart_Port port, |
2703 const Class& cls, | 2706 const Class& cls, |
2704 intptr_t thread_task_mask, | 2707 intptr_t thread_task_mask, |
2705 int64_t time_origin_micros, | 2708 int64_t time_origin_micros, |
2706 int64_t time_extent_micros) | 2709 int64_t time_extent_micros) |
2707 : SampleFilter(isolate, | 2710 : SampleFilter(port, |
2708 thread_task_mask, | 2711 thread_task_mask, |
2709 time_origin_micros, | 2712 time_origin_micros, |
2710 time_extent_micros), | 2713 time_extent_micros), |
2711 cls_(Class::Handle(cls.raw())) { | 2714 cls_(Class::Handle(cls.raw())) { |
2712 ASSERT(!cls_.IsNull()); | 2715 ASSERT(!cls_.IsNull()); |
2713 } | 2716 } |
2714 | 2717 |
2715 bool FilterSample(Sample* sample) { | 2718 bool FilterSample(Sample* sample) { |
2716 return sample->is_allocation_sample() && | 2719 return sample->is_allocation_sample() && |
2717 (sample->allocation_cid() == cls_.id()); | 2720 (sample->allocation_cid() == cls_.id()) && |
2721 !sample->is_native_allocation_sample(); | |
Cutch
2017/02/23 18:10:25
A sample should never be tagged as both an 'alloca
bkonyi
2017/02/23 19:34:17
Makes sense. Removed.
| |
2718 } | 2722 } |
2719 | 2723 |
2720 private: | 2724 private: |
2721 const Class& cls_; | 2725 const Class& cls_; |
2722 }; | 2726 }; |
2723 | 2727 |
2724 | 2728 |
2729 class NativeAllocationSampleFilter : public SampleFilter { | |
2730 public: | |
2731 NativeAllocationSampleFilter(intptr_t thread_task_mask, | |
2732 int64_t time_origin_micros, | |
2733 int64_t time_extent_micros) | |
2734 : SampleFilter(ILLEGAL_PORT, | |
2735 thread_task_mask, | |
2736 time_origin_micros, | |
2737 time_extent_micros) {} | |
2738 bool FilterSample(Sample* sample) { | |
2739 return sample->is_native_allocation_sample(); | |
2740 } | |
2741 }; | |
2742 | |
2743 | |
2725 void ProfilerService::PrintAllocationJSON(JSONStream* stream, | 2744 void ProfilerService::PrintAllocationJSON(JSONStream* stream, |
2726 Profile::TagOrder tag_order, | 2745 Profile::TagOrder tag_order, |
2727 const Class& cls, | 2746 const Class& cls, |
2728 int64_t time_origin_micros, | 2747 int64_t time_origin_micros, |
2729 int64_t time_extent_micros) { | 2748 int64_t time_extent_micros) { |
2730 Thread* thread = Thread::Current(); | 2749 Thread* thread = Thread::Current(); |
2731 Isolate* isolate = thread->isolate(); | 2750 Isolate* isolate = thread->isolate(); |
2732 ClassAllocationSampleFilter filter(isolate, cls, Thread::kMutatorTask, | 2751 ClassAllocationSampleFilter filter(isolate->main_port(), cls, |
2733 time_origin_micros, time_extent_micros); | 2752 Thread::kMutatorTask, time_origin_micros, |
2753 time_extent_micros); | |
2734 const bool as_timeline = false; | 2754 const bool as_timeline = false; |
2735 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); | 2755 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); |
2736 } | 2756 } |
2757 | |
2758 | |
2759 void ProfilerService::PrintNativeAllocationJSON(JSONStream* stream, | |
2760 Profile::TagOrder tag_order, | |
2761 int64_t time_origin_micros, | |
2762 int64_t time_extent_micros) { | |
2763 Thread* thread = Thread::Current(); | |
2764 const intptr_t thread_task_mask = Thread::kMutatorTask | | |
2765 Thread::kCompilerTask | | |
2766 Thread::kSweeperTask | Thread::kMarkerTask; | |
2767 NativeAllocationSampleFilter filter(thread_task_mask, time_origin_micros, | |
2768 time_extent_micros); | |
2769 const bool as_timeline = false; | |
2770 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); | |
2771 } | |
2737 | 2772 |
2738 | 2773 |
2739 void ProfilerService::PrintTimelineJSON(JSONStream* stream, | 2774 void ProfilerService::PrintTimelineJSON(JSONStream* stream, |
2740 Profile::TagOrder tag_order, | 2775 Profile::TagOrder tag_order, |
2741 int64_t time_origin_micros, | 2776 int64_t time_origin_micros, |
2742 int64_t time_extent_micros) { | 2777 int64_t time_extent_micros) { |
2743 Thread* thread = Thread::Current(); | 2778 Thread* thread = Thread::Current(); |
2744 Isolate* isolate = thread->isolate(); | 2779 Isolate* isolate = thread->isolate(); |
2745 const intptr_t thread_task_mask = Thread::kMutatorTask | | 2780 const intptr_t thread_task_mask = Thread::kMutatorTask | |
2746 Thread::kCompilerTask | | 2781 Thread::kCompilerTask | |
2747 Thread::kSweeperTask | Thread::kMarkerTask; | 2782 Thread::kSweeperTask | Thread::kMarkerTask; |
2748 NoAllocationSampleFilter filter(isolate, thread_task_mask, time_origin_micros, | 2783 NoAllocationSampleFilter filter(isolate->main_port(), thread_task_mask, |
2749 time_extent_micros); | 2784 time_origin_micros, time_extent_micros); |
2750 const bool as_timeline = true; | 2785 const bool as_timeline = true; |
2751 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); | 2786 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); |
2752 } | 2787 } |
2753 | 2788 |
2754 | 2789 |
2755 void ProfilerService::ClearSamples() { | 2790 void ProfilerService::ClearSamples() { |
2756 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 2791 SampleBuffer* sample_buffer = Profiler::sample_buffer(); |
2757 if (sample_buffer == NULL) { | 2792 if (sample_buffer == NULL) { |
2758 return; | 2793 return; |
2759 } | 2794 } |
2760 | 2795 |
2761 Thread* thread = Thread::Current(); | 2796 Thread* thread = Thread::Current(); |
2762 Isolate* isolate = thread->isolate(); | 2797 Isolate* isolate = thread->isolate(); |
2763 | 2798 |
2764 // Disable thread interrupts while processing the buffer. | 2799 // Disable thread interrupts while processing the buffer. |
2765 DisableThreadInterruptsScope dtis(thread); | 2800 DisableThreadInterruptsScope dtis(thread); |
2766 | 2801 |
2767 ClearProfileVisitor clear_profile(isolate); | 2802 ClearProfileVisitor clear_profile(isolate); |
2768 sample_buffer->VisitSamples(&clear_profile); | 2803 sample_buffer->VisitSamples(&clear_profile); |
2769 } | 2804 } |
2770 | 2805 |
2771 #endif // !PRODUCT | 2806 #endif // !PRODUCT |
2772 | 2807 |
2773 } // namespace dart | 2808 } // namespace dart |
OLD | NEW |