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

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

Issue 2680213002: Updated MallocHooks to collect stack traces when memory is allocated. (Closed)
Patch Set: Rough patch: addressed initial comments + converted sample filters from using Isolates to Dart_Port… Created 3 years, 10 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
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) { return !sample->is_allocation_sample(); }
2683 }; 2683 };
2684 2684
2685 2685
2686 void ProfilerService::PrintJSON(JSONStream* stream, 2686 void ProfilerService::PrintJSON(JSONStream* stream,
2687 Profile::TagOrder tag_order, 2687 Profile::TagOrder tag_order,
2688 intptr_t extra_tags, 2688 intptr_t extra_tags,
2689 int64_t time_origin_micros, 2689 int64_t time_origin_micros,
2690 int64_t time_extent_micros) { 2690 int64_t time_extent_micros) {
2691 Thread* thread = Thread::Current(); 2691 Thread* thread = Thread::Current();
2692 Isolate* isolate = thread->isolate(); 2692 Isolate* isolate = thread->isolate();
2693 NoAllocationSampleFilter filter(isolate, Thread::kMutatorTask, 2693 NoAllocationSampleFilter filter(isolate->main_port(), Thread::kMutatorTask,
2694 time_origin_micros, time_extent_micros); 2694 time_origin_micros, time_extent_micros);
2695 const bool as_timeline = false; 2695 const bool as_timeline = false;
2696 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline); 2696 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline);
2697 } 2697 }
2698 2698
2699 2699
2700 class ClassAllocationSampleFilter : public SampleFilter { 2700 class ClassAllocationSampleFilter : public SampleFilter {
2701 public: 2701 public:
2702 ClassAllocationSampleFilter(Isolate* isolate, 2702 ClassAllocationSampleFilter(Dart_Port port,
2703 const Class& cls, 2703 const Class& cls,
2704 intptr_t thread_task_mask, 2704 intptr_t thread_task_mask,
2705 int64_t time_origin_micros, 2705 int64_t time_origin_micros,
2706 int64_t time_extent_micros) 2706 int64_t time_extent_micros)
2707 : SampleFilter(isolate, 2707 : SampleFilter(port,
2708 thread_task_mask, 2708 thread_task_mask,
2709 time_origin_micros, 2709 time_origin_micros,
2710 time_extent_micros), 2710 time_extent_micros),
2711 cls_(Class::Handle(cls.raw())) { 2711 cls_(Class::Handle(cls.raw())) {
2712 ASSERT(!cls_.IsNull()); 2712 ASSERT(!cls_.IsNull());
2713 } 2713 }
2714 2714
2715 bool FilterSample(Sample* sample) { 2715 bool FilterSample(Sample* sample) {
2716 return sample->is_allocation_sample() && 2716 return sample->is_allocation_sample() &&
2717 (sample->allocation_cid() == cls_.id()); 2717 (sample->allocation_cid() == cls_.id());
2718 } 2718 }
2719 2719
2720 private: 2720 private:
2721 const Class& cls_; 2721 const Class& cls_;
2722 }; 2722 };
2723 2723
2724 2724
2725 void ProfilerService::PrintAllocationJSON(JSONStream* stream, 2725 void ProfilerService::PrintAllocationJSON(JSONStream* stream,
2726 Profile::TagOrder tag_order, 2726 Profile::TagOrder tag_order,
2727 const Class& cls, 2727 const Class& cls,
2728 int64_t time_origin_micros, 2728 int64_t time_origin_micros,
2729 int64_t time_extent_micros) { 2729 int64_t time_extent_micros) {
2730 Thread* thread = Thread::Current(); 2730 Thread* thread = Thread::Current();
2731 Isolate* isolate = thread->isolate(); 2731 Isolate* isolate = thread->isolate();
2732 ClassAllocationSampleFilter filter(isolate, cls, Thread::kMutatorTask, 2732 ClassAllocationSampleFilter filter(isolate->main_port(), cls,
2733 time_origin_micros, time_extent_micros); 2733 Thread::kMutatorTask, time_origin_micros,
2734 time_extent_micros);
2734 const bool as_timeline = false; 2735 const bool as_timeline = false;
2735 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); 2736 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
2736 } 2737 }
2737 2738
2738 2739
2739 void ProfilerService::PrintTimelineJSON(JSONStream* stream, 2740 void ProfilerService::PrintTimelineJSON(JSONStream* stream,
2740 Profile::TagOrder tag_order, 2741 Profile::TagOrder tag_order,
2741 int64_t time_origin_micros, 2742 int64_t time_origin_micros,
2742 int64_t time_extent_micros) { 2743 int64_t time_extent_micros) {
2743 Thread* thread = Thread::Current(); 2744 Thread* thread = Thread::Current();
2744 Isolate* isolate = thread->isolate(); 2745 Isolate* isolate = thread->isolate();
2745 const intptr_t thread_task_mask = Thread::kMutatorTask | 2746 const intptr_t thread_task_mask = Thread::kMutatorTask |
2746 Thread::kCompilerTask | 2747 Thread::kCompilerTask |
2747 Thread::kSweeperTask | Thread::kMarkerTask; 2748 Thread::kSweeperTask | Thread::kMarkerTask;
2748 NoAllocationSampleFilter filter(isolate, thread_task_mask, time_origin_micros, 2749 NoAllocationSampleFilter filter(isolate->main_port(), thread_task_mask,
2749 time_extent_micros); 2750 time_origin_micros, time_extent_micros);
2750 const bool as_timeline = true; 2751 const bool as_timeline = true;
2751 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); 2752 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
2752 } 2753 }
2753 2754
2754 2755
2755 void ProfilerService::ClearSamples() { 2756 void ProfilerService::ClearSamples() {
2756 SampleBuffer* sample_buffer = Profiler::sample_buffer(); 2757 SampleBuffer* sample_buffer = Profiler::sample_buffer();
2757 if (sample_buffer == NULL) { 2758 if (sample_buffer == NULL) {
2758 return; 2759 return;
2759 } 2760 }
2760 2761
2761 Thread* thread = Thread::Current(); 2762 Thread* thread = Thread::Current();
2762 Isolate* isolate = thread->isolate(); 2763 Isolate* isolate = thread->isolate();
2763 2764
2764 // Disable thread interrupts while processing the buffer. 2765 // Disable thread interrupts while processing the buffer.
2765 DisableThreadInterruptsScope dtis(thread); 2766 DisableThreadInterruptsScope dtis(thread);
2766 2767
2767 ClearProfileVisitor clear_profile(isolate); 2768 ClearProfileVisitor clear_profile(isolate);
2768 sample_buffer->VisitSamples(&clear_profile); 2769 sample_buffer->VisitSamples(&clear_profile);
2769 } 2770 }
2770 2771
2771 #endif // !PRODUCT 2772 #endif // !PRODUCT
2772 2773
2773 } // namespace dart 2774 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698