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

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

Issue 2989093002: [vm] Don't enable the profiler by default. Enable the profiler at startup with --observe, or later … (Closed)
Patch Set: . Created 3 years, 4 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) 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 #include "platform/address_sanitizer.h" 5 #include "platform/address_sanitizer.h"
6 #include "platform/memory_sanitizer.h" 6 #include "platform/memory_sanitizer.h"
7 #include "platform/utils.h" 7 #include "platform/utils.h"
8 8
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/atomic.h" 10 #include "vm/atomic.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 bool Profiler::initialized_ = false; 62 bool Profiler::initialized_ = false;
63 SampleBuffer* Profiler::sample_buffer_ = NULL; 63 SampleBuffer* Profiler::sample_buffer_ = NULL;
64 AllocationSampleBuffer* Profiler::allocation_sample_buffer_ = NULL; 64 AllocationSampleBuffer* Profiler::allocation_sample_buffer_ = NULL;
65 ProfilerCounters Profiler::counters_; 65 ProfilerCounters Profiler::counters_;
66 66
67 void Profiler::InitOnce() { 67 void Profiler::InitOnce() {
68 // Place some sane restrictions on user controlled flags. 68 // Place some sane restrictions on user controlled flags.
69 SetSamplePeriod(FLAG_profile_period); 69 SetSamplePeriod(FLAG_profile_period);
70 SetSampleDepth(FLAG_max_profile_depth); 70 SetSampleDepth(FLAG_max_profile_depth);
71 Sample::InitOnce(); 71 Sample::InitOnce();
72 #if !defined(TARGET_ARCH_DBC)
zra 2017/07/31 15:03:11 I thought the profiler was kind of working somewha
rmacnak 2017/07/31 21:12:12 Removed; this was a bad merge. I was working from
72 if (!FLAG_profiler) { 73 if (!FLAG_profiler) {
73 return; 74 return;
74 } 75 }
75 ASSERT(!initialized_); 76 ASSERT(!initialized_);
76 sample_buffer_ = new SampleBuffer(); 77 sample_buffer_ = new SampleBuffer();
77 Profiler::InitAllocationSampleBuffer(); 78 Profiler::InitAllocationSampleBuffer();
78 // Zero counters. 79 // Zero counters.
79 memset(&counters_, 0, sizeof(counters_)); 80 memset(&counters_, 0, sizeof(counters_));
80 NativeSymbolResolver::InitOnce(); 81 NativeSymbolResolver::InitOnce();
82 ThreadInterrupter::InitOnce();
81 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); 83 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period);
82 ThreadInterrupter::Startup(); 84 ThreadInterrupter::Startup();
83 initialized_ = true; 85 initialized_ = true;
86 #endif // !DBC
84 } 87 }
85 88
86 void Profiler::InitAllocationSampleBuffer() { 89 void Profiler::InitAllocationSampleBuffer() {
87 if (FLAG_profiler_native_memory && 90 if (FLAG_profiler_native_memory &&
88 (Profiler::allocation_sample_buffer_ == NULL)) { 91 (Profiler::allocation_sample_buffer_ == NULL)) {
89 Profiler::allocation_sample_buffer_ = new AllocationSampleBuffer(); 92 Profiler::allocation_sample_buffer_ = new AllocationSampleBuffer();
90 } 93 }
91 } 94 }
92 95
93 void Profiler::Shutdown() { 96 void Profiler::Shutdown() {
97 #if !defined(TARGET_ARCH_DBC)
94 if (!FLAG_profiler) { 98 if (!FLAG_profiler) {
95 return; 99 return;
96 } 100 }
97 ASSERT(initialized_); 101 ASSERT(initialized_);
98 ThreadInterrupter::Shutdown(); 102 ThreadInterrupter::Shutdown();
99 NativeSymbolResolver::ShutdownOnce(); 103 NativeSymbolResolver::ShutdownOnce();
104 // Note we do not free the sample buffer because there may be SIGPROFs
zra 2017/07/31 15:03:11 Can you set a "shutting down" bit somewhere that t
rmacnak 2017/07/31 21:12:12 The signal handler could be between that check and
zra 2017/07/31 21:59:28 Maybe some thing like: Signal handler: AtomicInc(
rmacnak 2017/08/01 19:58:58 Added TODO(30309)
105 // in flight.
106 #endif // !DBC
100 } 107 }
101 108
102 void Profiler::SetSampleDepth(intptr_t depth) { 109 void Profiler::SetSampleDepth(intptr_t depth) {
103 const int kMinimumDepth = 2; 110 const int kMinimumDepth = 2;
104 const int kMaximumDepth = 255; 111 const int kMaximumDepth = 255;
105 if (depth < kMinimumDepth) { 112 if (depth < kMinimumDepth) {
106 FLAG_max_profile_depth = kMinimumDepth; 113 FLAG_max_profile_depth = kMinimumDepth;
107 } else if (depth > kMaximumDepth) { 114 } else if (depth > kMaximumDepth) {
108 FLAG_max_profile_depth = kMaximumDepth; 115 FLAG_max_profile_depth = kMaximumDepth;
109 } else { 116 } else {
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 } 1688 }
1682 1689
1683 ProcessedSampleBuffer::ProcessedSampleBuffer() 1690 ProcessedSampleBuffer::ProcessedSampleBuffer()
1684 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { 1691 : code_lookup_table_(new CodeLookupTable(Thread::Current())) {
1685 ASSERT(code_lookup_table_ != NULL); 1692 ASSERT(code_lookup_table_ != NULL);
1686 } 1693 }
1687 1694
1688 #endif // !PRODUCT 1695 #endif // !PRODUCT
1689 1696
1690 } // namespace dart 1697 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698