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 <cstdio> | 5 #include <cstdio> |
6 | 6 |
7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
8 | 8 |
9 #include "vm/atomic.h" | 9 #include "vm/atomic.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #if defined(USING_SIMULATOR) || defined(TARGET_OS_WINDOWS) || \ | 31 #if defined(USING_SIMULATOR) || defined(TARGET_OS_WINDOWS) || \ |
32 defined(TARGET_OS_MACOS) || defined(TARGET_OS_ANDROID) | 32 defined(TARGET_OS_MACOS) || defined(TARGET_OS_ANDROID) |
33 DEFINE_FLAG(bool, profile, false, "Enable Sampling Profiler"); | 33 DEFINE_FLAG(bool, profile, false, "Enable Sampling Profiler"); |
34 #else | 34 #else |
35 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler"); | 35 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler"); |
36 #endif | 36 #endif |
37 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); | 37 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); |
38 DEFINE_FLAG(charp, profile_dir, NULL, | 38 DEFINE_FLAG(charp, profile_dir, NULL, |
39 "Enable writing profile data into specified directory."); | 39 "Enable writing profile data into specified directory."); |
| 40 DEFINE_FLAG(int, profile_period, 1000, |
| 41 "Time between profiler samples in microseconds. Minimum 250."); |
40 | 42 |
41 bool Profiler::initialized_ = false; | 43 bool Profiler::initialized_ = false; |
42 Monitor* Profiler::monitor_ = NULL; | 44 Monitor* Profiler::monitor_ = NULL; |
43 SampleBuffer* Profiler::sample_buffer_ = NULL; | 45 SampleBuffer* Profiler::sample_buffer_ = NULL; |
44 | 46 |
45 void Profiler::InitOnce() { | 47 void Profiler::InitOnce() { |
| 48 const int kMinimumProfilePeriod = 250; |
46 if (!FLAG_profile) { | 49 if (!FLAG_profile) { |
47 return; | 50 return; |
48 } | 51 } |
49 ASSERT(!initialized_); | 52 ASSERT(!initialized_); |
50 initialized_ = true; | 53 initialized_ = true; |
51 monitor_ = new Monitor(); | 54 monitor_ = new Monitor(); |
52 sample_buffer_ = new SampleBuffer(); | 55 sample_buffer_ = new SampleBuffer(); |
53 NativeSymbolResolver::InitOnce(); | 56 NativeSymbolResolver::InitOnce(); |
54 ThreadInterrupter::InitOnce(); | 57 ThreadInterrupter::InitOnce(); |
| 58 if (FLAG_profile_period < kMinimumProfilePeriod) { |
| 59 FLAG_profile_period = kMinimumProfilePeriod; |
| 60 } |
| 61 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); |
55 } | 62 } |
56 | 63 |
57 | 64 |
58 void Profiler::Shutdown() { | 65 void Profiler::Shutdown() { |
59 if (!FLAG_profile) { | 66 if (!FLAG_profile) { |
60 return; | 67 return; |
61 } | 68 } |
62 ASSERT(initialized_); | 69 ASSERT(initialized_); |
63 ThreadInterrupter::Shutdown(); | 70 ThreadInterrupter::Shutdown(); |
64 NativeSymbolResolver::ShutdownOnce(); | 71 NativeSymbolResolver::ShutdownOnce(); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 return false; | 534 return false; |
528 } | 535 } |
529 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); | 536 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); |
530 cursor += sizeof(fp); | 537 cursor += sizeof(fp); |
531 bool r = cursor >= lower_bound_ && cursor < stack_upper_; | 538 bool r = cursor >= lower_bound_ && cursor < stack_upper_; |
532 return r; | 539 return r; |
533 } | 540 } |
534 | 541 |
535 | 542 |
536 } // namespace dart | 543 } // namespace dart |
OLD | NEW |