| 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 #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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 Sample::InitOnce(); | 71 Sample::InitOnce(); |
| 72 if (!FLAG_profiler) { | 72 if (!FLAG_profiler) { |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 ASSERT(!initialized_); | 75 ASSERT(!initialized_); |
| 76 sample_buffer_ = new SampleBuffer(); | 76 sample_buffer_ = new SampleBuffer(); |
| 77 Profiler::InitAllocationSampleBuffer(); | 77 Profiler::InitAllocationSampleBuffer(); |
| 78 // Zero counters. | 78 // Zero counters. |
| 79 memset(&counters_, 0, sizeof(counters_)); | 79 memset(&counters_, 0, sizeof(counters_)); |
| 80 NativeSymbolResolver::InitOnce(); | 80 NativeSymbolResolver::InitOnce(); |
| 81 ThreadInterrupter::InitOnce(); | |
| 82 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); | 81 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); |
| 83 ThreadInterrupter::Startup(); | 82 ThreadInterrupter::Startup(); |
| 84 initialized_ = true; | 83 initialized_ = true; |
| 85 } | 84 } |
| 86 | 85 |
| 87 void Profiler::InitAllocationSampleBuffer() { | 86 void Profiler::InitAllocationSampleBuffer() { |
| 88 if (FLAG_profiler_native_memory && | 87 if (FLAG_profiler_native_memory && |
| 89 (Profiler::allocation_sample_buffer_ == NULL)) { | 88 (Profiler::allocation_sample_buffer_ == NULL)) { |
| 90 Profiler::allocation_sample_buffer_ = new AllocationSampleBuffer(); | 89 Profiler::allocation_sample_buffer_ = new AllocationSampleBuffer(); |
| 91 } | 90 } |
| 92 } | 91 } |
| 93 | 92 |
| 94 void Profiler::Shutdown() { | 93 void Profiler::Shutdown() { |
| 95 if (!FLAG_profiler) { | 94 if (!FLAG_profiler) { |
| 96 return; | 95 return; |
| 97 } | 96 } |
| 98 ASSERT(initialized_); | 97 ASSERT(initialized_); |
| 99 ThreadInterrupter::Shutdown(); | 98 ThreadInterrupter::Shutdown(); |
| 100 NativeSymbolResolver::ShutdownOnce(); | 99 NativeSymbolResolver::ShutdownOnce(); |
| 101 #if defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS) || defined(HOST_OS_ANDROID) | |
| 102 // TODO(30309): Free the sample buffer on platforms that use a signal-based | |
| 103 // thread interrupter. | |
| 104 #else | |
| 105 delete sample_buffer_; | |
| 106 sample_buffer_ = NULL; | |
| 107 #endif | |
| 108 } | 100 } |
| 109 | 101 |
| 110 void Profiler::SetSampleDepth(intptr_t depth) { | 102 void Profiler::SetSampleDepth(intptr_t depth) { |
| 111 const int kMinimumDepth = 2; | 103 const int kMinimumDepth = 2; |
| 112 const int kMaximumDepth = 255; | 104 const int kMaximumDepth = 255; |
| 113 if (depth < kMinimumDepth) { | 105 if (depth < kMinimumDepth) { |
| 114 FLAG_max_profile_depth = kMinimumDepth; | 106 FLAG_max_profile_depth = kMinimumDepth; |
| 115 } else if (depth > kMaximumDepth) { | 107 } else if (depth > kMaximumDepth) { |
| 116 FLAG_max_profile_depth = kMaximumDepth; | 108 FLAG_max_profile_depth = kMaximumDepth; |
| 117 } else { | 109 } else { |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 } | 1681 } |
| 1690 | 1682 |
| 1691 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1683 ProcessedSampleBuffer::ProcessedSampleBuffer() |
| 1692 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1684 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
| 1693 ASSERT(code_lookup_table_ != NULL); | 1685 ASSERT(code_lookup_table_ != NULL); |
| 1694 } | 1686 } |
| 1695 | 1687 |
| 1696 #endif // !PRODUCT | 1688 #endif // !PRODUCT |
| 1697 | 1689 |
| 1698 } // namespace dart | 1690 } // namespace dart |
| OLD | NEW |