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

Side by Side Diff: runtime/vm/profiler_service.cc

Issue 2680213002: Updated MallocHooks to collect stack traces when memory is allocated. (Closed)
Patch Set: Updated MallocHooks to collect stack traces when memory is allocated. Created 3 years, 9 months 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/profiler_service.h ('k') | runtime/vm/profiler_test.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) 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
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());
2718 } 2721 }
2719 2722
2720 private: 2723 private:
2721 const Class& cls_; 2724 const Class& cls_;
2722 }; 2725 };
2723 2726
2724 2727
2728 class NativeAllocationSampleFilter : public SampleFilter {
2729 public:
2730 NativeAllocationSampleFilter(intptr_t thread_task_mask,
2731 int64_t time_origin_micros,
2732 int64_t time_extent_micros)
2733 : SampleFilter(ILLEGAL_PORT,
2734 thread_task_mask,
2735 time_origin_micros,
2736 time_extent_micros) {}
2737 bool FilterSample(Sample* sample) {
2738 return sample->is_native_allocation_sample();
2739 }
2740 };
2741
2742
2725 void ProfilerService::PrintAllocationJSON(JSONStream* stream, 2743 void ProfilerService::PrintAllocationJSON(JSONStream* stream,
2726 Profile::TagOrder tag_order, 2744 Profile::TagOrder tag_order,
2727 const Class& cls, 2745 const Class& cls,
2728 int64_t time_origin_micros, 2746 int64_t time_origin_micros,
2729 int64_t time_extent_micros) { 2747 int64_t time_extent_micros) {
2730 Thread* thread = Thread::Current(); 2748 Thread* thread = Thread::Current();
2731 Isolate* isolate = thread->isolate(); 2749 Isolate* isolate = thread->isolate();
2732 ClassAllocationSampleFilter filter(isolate, cls, Thread::kMutatorTask, 2750 ClassAllocationSampleFilter filter(isolate->main_port(), cls,
2733 time_origin_micros, time_extent_micros); 2751 Thread::kMutatorTask, time_origin_micros,
2752 time_extent_micros);
2734 const bool as_timeline = false; 2753 const bool as_timeline = false;
2735 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); 2754 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
2736 } 2755 }
2756
2757
2758 void ProfilerService::PrintNativeAllocationJSON(JSONStream* stream,
2759 Profile::TagOrder tag_order,
2760 int64_t time_origin_micros,
2761 int64_t time_extent_micros) {
2762 Thread* thread = Thread::Current();
2763 const intptr_t thread_task_mask = Thread::kMutatorTask |
2764 Thread::kCompilerTask |
2765 Thread::kSweeperTask | Thread::kMarkerTask;
2766 NativeAllocationSampleFilter filter(thread_task_mask, time_origin_micros,
2767 time_extent_micros);
2768 const bool as_timeline = false;
2769 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
2770 }
2737 2771
2738 2772
2739 void ProfilerService::PrintTimelineJSON(JSONStream* stream, 2773 void ProfilerService::PrintTimelineJSON(JSONStream* stream,
2740 Profile::TagOrder tag_order, 2774 Profile::TagOrder tag_order,
2741 int64_t time_origin_micros, 2775 int64_t time_origin_micros,
2742 int64_t time_extent_micros) { 2776 int64_t time_extent_micros) {
2743 Thread* thread = Thread::Current(); 2777 Thread* thread = Thread::Current();
2744 Isolate* isolate = thread->isolate(); 2778 Isolate* isolate = thread->isolate();
2745 const intptr_t thread_task_mask = Thread::kMutatorTask | 2779 const intptr_t thread_task_mask = Thread::kMutatorTask |
2746 Thread::kCompilerTask | 2780 Thread::kCompilerTask |
2747 Thread::kSweeperTask | Thread::kMarkerTask; 2781 Thread::kSweeperTask | Thread::kMarkerTask;
2748 NoAllocationSampleFilter filter(isolate, thread_task_mask, time_origin_micros, 2782 NoAllocationSampleFilter filter(isolate->main_port(), thread_task_mask,
2749 time_extent_micros); 2783 time_origin_micros, time_extent_micros);
2750 const bool as_timeline = true; 2784 const bool as_timeline = true;
2751 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); 2785 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
2752 } 2786 }
2753 2787
2754 2788
2755 void ProfilerService::ClearSamples() { 2789 void ProfilerService::ClearSamples() {
2756 SampleBuffer* sample_buffer = Profiler::sample_buffer(); 2790 SampleBuffer* sample_buffer = Profiler::sample_buffer();
2757 if (sample_buffer == NULL) { 2791 if (sample_buffer == NULL) {
2758 return; 2792 return;
2759 } 2793 }
2760 2794
2761 Thread* thread = Thread::Current(); 2795 Thread* thread = Thread::Current();
2762 Isolate* isolate = thread->isolate(); 2796 Isolate* isolate = thread->isolate();
2763 2797
2764 // Disable thread interrupts while processing the buffer. 2798 // Disable thread interrupts while processing the buffer.
2765 DisableThreadInterruptsScope dtis(thread); 2799 DisableThreadInterruptsScope dtis(thread);
2766 2800
2767 ClearProfileVisitor clear_profile(isolate); 2801 ClearProfileVisitor clear_profile(isolate);
2768 sample_buffer->VisitSamples(&clear_profile); 2802 sample_buffer->VisitSamples(&clear_profile);
2769 } 2803 }
2770 2804
2771 #endif // !PRODUCT 2805 #endif // !PRODUCT
2772 2806
2773 } // namespace dart 2807 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler_service.h ('k') | runtime/vm/profiler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698