| 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" |
| 11 #include "vm/code_patcher.h" | 11 #include "vm/code_patcher.h" |
| 12 #include "vm/debugger.h" | 12 #include "vm/debugger.h" |
| 13 #include "vm/instructions.h" | 13 #include "vm/instructions.h" |
| 14 #include "vm/isolate.h" | 14 #include "vm/isolate.h" |
| 15 #include "vm/json_stream.h" | 15 #include "vm/json_stream.h" |
| 16 #include "vm/lockers.h" | 16 #include "vm/lockers.h" |
| 17 #include "vm/message_handler.h" | 17 #include "vm/message_handler.h" |
| 18 #include "vm/native_symbol.h" | 18 #include "vm/native_symbol.h" |
| 19 #include "vm/object.h" | 19 #include "vm/object.h" |
| 20 #include "vm/os.h" | 20 #include "vm/os.h" |
| 21 #include "vm/profiler.h" | 21 #include "vm/profiler.h" |
| 22 #include "vm/reusable_handles.h" | 22 #include "vm/reusable_handles.h" |
| 23 #include "vm/signal_handler.h" | 23 #include "vm/signal_handler.h" |
| 24 #include "vm/simulator.h" | 24 #include "vm/simulator.h" |
| 25 #include "vm/stack_frame.h" | 25 #include "vm/stack_frame.h" |
| 26 | 26 |
| 27 namespace dart { | 27 namespace dart { |
| 28 | 28 |
| 29 | |
| 30 static const intptr_t kSampleSize = 8; | 29 static const intptr_t kSampleSize = 8; |
| 31 | 30 |
| 32 DECLARE_FLAG(bool, trace_profiler); | 31 DECLARE_FLAG(bool, trace_profiler); |
| 33 | |
| 34 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler"); | |
| 35 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); | 32 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); |
| 36 | 33 |
| 37 #if defined(TARGET_OS_ANDROID) || defined(TARGET_ARCH_ARM64) || \ | 34 #if defined(TARGET_OS_ANDROID) || defined(TARGET_ARCH_ARM64) || \ |
| 38 defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) | 35 defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) |
| 39 DEFINE_FLAG(int, profile_period, 10000, | 36 DEFINE_FLAG(int, profile_period, 10000, |
| 40 "Time between profiler samples in microseconds. Minimum 50."); | 37 "Time between profiler samples in microseconds. Minimum 50."); |
| 41 #else | 38 #else |
| 42 DEFINE_FLAG(int, profile_period, 1000, | 39 DEFINE_FLAG(int, profile_period, 1000, |
| 43 "Time between profiler samples in microseconds. Minimum 50."); | 40 "Time between profiler samples in microseconds. Minimum 50."); |
| 44 #endif | 41 #endif |
| 45 DEFINE_FLAG(int, max_profile_depth, kSampleSize, | 42 DEFINE_FLAG(int, max_profile_depth, kSampleSize, |
| 46 "Maximum number stack frames walked. Minimum 1. Maximum 255."); | 43 "Maximum number stack frames walked. Minimum 1. Maximum 255."); |
| 47 #if defined(USING_SIMULATOR) | 44 #if defined(USING_SIMULATOR) |
| 48 DEFINE_FLAG(bool, profile_vm, true, | 45 DEFINE_FLAG(bool, profile_vm, true, |
| 49 "Always collect native stack traces."); | 46 "Always collect native stack traces."); |
| 50 #else | 47 #else |
| 51 DEFINE_FLAG(bool, profile_vm, false, | 48 DEFINE_FLAG(bool, profile_vm, false, |
| 52 "Always collect native stack traces."); | 49 "Always collect native stack traces."); |
| 53 #endif | 50 #endif |
| 54 | 51 |
| 52 #ifndef PRODUCT |
| 53 |
| 55 bool Profiler::initialized_ = false; | 54 bool Profiler::initialized_ = false; |
| 56 SampleBuffer* Profiler::sample_buffer_ = NULL; | 55 SampleBuffer* Profiler::sample_buffer_ = NULL; |
| 57 | 56 |
| 58 | 57 |
| 59 void Profiler::InitOnce() { | 58 void Profiler::InitOnce() { |
| 60 // Place some sane restrictions on user controlled flags. | 59 // Place some sane restrictions on user controlled flags. |
| 61 SetSamplePeriod(FLAG_profile_period); | 60 SetSamplePeriod(FLAG_profile_period); |
| 62 SetSampleDepth(FLAG_max_profile_depth); | 61 SetSampleDepth(FLAG_max_profile_depth); |
| 63 Sample::InitOnce(); | 62 Sample::InitOnce(); |
| 64 if (!FLAG_profile) { | 63 if (!FLAG_profiler) { |
| 65 return; | 64 return; |
| 66 } | 65 } |
| 67 ASSERT(!initialized_); | 66 ASSERT(!initialized_); |
| 68 sample_buffer_ = new SampleBuffer(); | 67 sample_buffer_ = new SampleBuffer(); |
| 69 NativeSymbolResolver::InitOnce(); | 68 NativeSymbolResolver::InitOnce(); |
| 70 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); | 69 ThreadInterrupter::SetInterruptPeriod(FLAG_profile_period); |
| 71 ThreadInterrupter::Startup(); | 70 ThreadInterrupter::Startup(); |
| 72 initialized_ = true; | 71 initialized_ = true; |
| 73 } | 72 } |
| 74 | 73 |
| 75 | 74 |
| 76 void Profiler::Shutdown() { | 75 void Profiler::Shutdown() { |
| 77 if (!FLAG_profile) { | 76 if (!FLAG_profiler) { |
| 78 return; | 77 return; |
| 79 } | 78 } |
| 80 ASSERT(initialized_); | 79 ASSERT(initialized_); |
| 81 ThreadInterrupter::Shutdown(); | 80 ThreadInterrupter::Shutdown(); |
| 82 NativeSymbolResolver::ShutdownOnce(); | 81 NativeSymbolResolver::ShutdownOnce(); |
| 83 } | 82 } |
| 84 | 83 |
| 85 | 84 |
| 86 void Profiler::SetSampleDepth(intptr_t depth) { | 85 void Profiler::SetSampleDepth(intptr_t depth) { |
| 87 const int kMinimumDepth = 2; | 86 const int kMinimumDepth = 2; |
| (...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 InsertAt(1, return_address); | 1377 InsertAt(1, return_address); |
| 1379 } | 1378 } |
| 1380 } | 1379 } |
| 1381 | 1380 |
| 1382 | 1381 |
| 1383 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1382 ProcessedSampleBuffer::ProcessedSampleBuffer() |
| 1384 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1383 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
| 1385 ASSERT(code_lookup_table_ != NULL); | 1384 ASSERT(code_lookup_table_ != NULL); |
| 1386 } | 1385 } |
| 1387 | 1386 |
| 1387 #endif // !PRODUCT |
| 1388 |
| 1388 } // namespace dart | 1389 } // namespace dart |
| OLD | NEW |