| 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(); |
| 81 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); | 82 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); |
| 82 ThreadInterrupter::Startup(); | 83 ThreadInterrupter::Startup(); |
| 83 initialized_ = true; | 84 initialized_ = true; |
| 84 } | 85 } |
| 85 | 86 |
| 86 void Profiler::InitAllocationSampleBuffer() { | 87 void Profiler::InitAllocationSampleBuffer() { |
| 87 if (FLAG_profiler_native_memory && | 88 if (FLAG_profiler_native_memory && |
| 88 (Profiler::allocation_sample_buffer_ == NULL)) { | 89 (Profiler::allocation_sample_buffer_ == NULL)) { |
| 89 Profiler::allocation_sample_buffer_ = new AllocationSampleBuffer(); | 90 Profiler::allocation_sample_buffer_ = new AllocationSampleBuffer(); |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 | 93 |
| 93 void Profiler::Shutdown() { | 94 void Profiler::Shutdown() { |
| 94 if (!FLAG_profiler) { | 95 if (!FLAG_profiler) { |
| 95 return; | 96 return; |
| 96 } | 97 } |
| 97 ASSERT(initialized_); | 98 ASSERT(initialized_); |
| 98 ThreadInterrupter::Shutdown(); | 99 ThreadInterrupter::Shutdown(); |
| 99 NativeSymbolResolver::ShutdownOnce(); | 100 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 |
| 100 } | 108 } |
| 101 | 109 |
| 102 void Profiler::SetSampleDepth(intptr_t depth) { | 110 void Profiler::SetSampleDepth(intptr_t depth) { |
| 103 const int kMinimumDepth = 2; | 111 const int kMinimumDepth = 2; |
| 104 const int kMaximumDepth = 255; | 112 const int kMaximumDepth = 255; |
| 105 if (depth < kMinimumDepth) { | 113 if (depth < kMinimumDepth) { |
| 106 FLAG_max_profile_depth = kMinimumDepth; | 114 FLAG_max_profile_depth = kMinimumDepth; |
| 107 } else if (depth > kMaximumDepth) { | 115 } else if (depth > kMaximumDepth) { |
| 108 FLAG_max_profile_depth = kMaximumDepth; | 116 FLAG_max_profile_depth = kMaximumDepth; |
| 109 } else { | 117 } else { |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 } | 1689 } |
| 1682 | 1690 |
| 1683 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1691 ProcessedSampleBuffer::ProcessedSampleBuffer() |
| 1684 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1692 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
| 1685 ASSERT(code_lookup_table_ != NULL); | 1693 ASSERT(code_lookup_table_ != NULL); |
| 1686 } | 1694 } |
| 1687 | 1695 |
| 1688 #endif // !PRODUCT | 1696 #endif // !PRODUCT |
| 1689 | 1697 |
| 1690 } // namespace dart | 1698 } // namespace dart |
| OLD | NEW |