| 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/utils.h" | 5 #include "platform/utils.h" |
| 6 | 6 |
| 7 #include "vm/allocation.h" | 7 #include "vm/allocation.h" |
| 8 #include "vm/atomic.h" | 8 #include "vm/atomic.h" |
| 9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 DEFINE_FLAG(int, profile_depth, 8, | 33 DEFINE_FLAG(int, profile_depth, 8, |
| 34 "Maximum number stack frames walked. Minimum 1. Maximum 128."); | 34 "Maximum number stack frames walked. Minimum 1. Maximum 128."); |
| 35 | 35 |
| 36 bool Profiler::initialized_ = false; | 36 bool Profiler::initialized_ = false; |
| 37 SampleBuffer* Profiler::sample_buffer_ = NULL; | 37 SampleBuffer* Profiler::sample_buffer_ = NULL; |
| 38 | 38 |
| 39 void Profiler::InitOnce() { | 39 void Profiler::InitOnce() { |
| 40 const int kMinimumProfilePeriod = 250; | 40 const int kMinimumProfilePeriod = 250; |
| 41 const int kMinimumDepth = 1; | 41 const int kMinimumDepth = 1; |
| 42 const int kMaximumDepth = 128; | 42 const int kMaximumDepth = 128; |
| 43 if (!FLAG_profile) { | |
| 44 return; | |
| 45 } | |
| 46 ASSERT(!initialized_); | |
| 47 // Place some sane restrictions on user controlled flags. | 43 // Place some sane restrictions on user controlled flags. |
| 48 if (FLAG_profile_period < kMinimumProfilePeriod) { | 44 if (FLAG_profile_period < kMinimumProfilePeriod) { |
| 49 FLAG_profile_period = kMinimumProfilePeriod; | 45 FLAG_profile_period = kMinimumProfilePeriod; |
| 50 } | 46 } |
| 51 if (FLAG_profile_depth < kMinimumDepth) { | 47 if (FLAG_profile_depth < kMinimumDepth) { |
| 52 FLAG_profile_depth = kMinimumDepth; | 48 FLAG_profile_depth = kMinimumDepth; |
| 53 } else if (FLAG_profile_depth > kMaximumDepth) { | 49 } else if (FLAG_profile_depth > kMaximumDepth) { |
| 54 FLAG_profile_depth = kMaximumDepth; | 50 FLAG_profile_depth = kMaximumDepth; |
| 55 } | 51 } |
| 56 Sample::InitOnce(); | 52 Sample::InitOnce(); |
| 53 if (!FLAG_profile) { |
| 54 return; |
| 55 } |
| 56 ASSERT(!initialized_); |
| 57 sample_buffer_ = new SampleBuffer(); | 57 sample_buffer_ = new SampleBuffer(); |
| 58 NativeSymbolResolver::InitOnce(); | 58 NativeSymbolResolver::InitOnce(); |
| 59 ThreadInterrupter::InitOnce(); | 59 ThreadInterrupter::InitOnce(); |
| 60 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); | 60 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); |
| 61 initialized_ = true; | 61 initialized_ = true; |
| 62 } | 62 } |
| 63 | 63 |
| 64 | 64 |
| 65 void Profiler::Shutdown() { | 65 void Profiler::Shutdown() { |
| 66 if (!FLAG_profile) { | 66 if (!FLAG_profile) { |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 return false; | 829 return false; |
| 830 } | 830 } |
| 831 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); | 831 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); |
| 832 cursor += sizeof(fp); | 832 cursor += sizeof(fp); |
| 833 bool r = cursor >= lower_bound_ && cursor < stack_upper_; | 833 bool r = cursor >= lower_bound_ && cursor < stack_upper_; |
| 834 return r; | 834 return r; |
| 835 } | 835 } |
| 836 | 836 |
| 837 | 837 |
| 838 } // namespace dart | 838 } // namespace dart |
| OLD | NEW |