| 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 14 matching lines...) Expand all Loading... |
| 25 // The stack frame walking code uses the frame pointer to traverse the stack. | 25 // The stack frame walking code uses the frame pointer to traverse the stack. |
| 26 // If the VM is compiled without frame pointers (which is the default on | 26 // If the VM is compiled without frame pointers (which is the default on |
| 27 // recent GCC versions with optimizing enabled) the stack walking code may | 27 // recent GCC versions with optimizing enabled) the stack walking code may |
| 28 // fail (sometimes leading to a crash). | 28 // fail (sometimes leading to a crash). |
| 29 // | 29 // |
| 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, false, "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, | 40 DEFINE_FLAG(int, profile_period, 1000, |
| 41 "Time between profiler samples in microseconds. Minimum 250."); | 41 "Time between profiler samples in microseconds. Minimum 250."); |
| 42 | 42 |
| 43 bool Profiler::initialized_ = false; | 43 bool Profiler::initialized_ = false; |
| 44 Monitor* Profiler::monitor_ = NULL; | 44 Monitor* Profiler::monitor_ = NULL; |
| 45 SampleBuffer* Profiler::sample_buffer_ = NULL; | 45 SampleBuffer* Profiler::sample_buffer_ = NULL; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 ASSERT(Isolate::Current() == NULL); | 105 ASSERT(Isolate::Current() == NULL); |
| 106 MonitorLocker ml(monitor_); | 106 MonitorLocker ml(monitor_); |
| 107 { | 107 { |
| 108 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); | 108 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); |
| 109 IsolateProfilerData* profiler_data = isolate->profiler_data(); | 109 IsolateProfilerData* profiler_data = isolate->profiler_data(); |
| 110 if (profiler_data == NULL) { | 110 if (profiler_data == NULL) { |
| 111 // Already freed. | 111 // Already freed. |
| 112 return; | 112 return; |
| 113 } | 113 } |
| 114 isolate->set_profiler_data(NULL); | 114 isolate->set_profiler_data(NULL); |
| 115 profiler_data->set_sample_buffer(NULL); | |
| 116 delete profiler_data; | 115 delete profiler_data; |
| 117 if (FLAG_trace_profiled_isolates) { | 116 if (FLAG_trace_profiled_isolates) { |
| 118 OS::Print("Profiler Shutdown %p %s\n", isolate, isolate->name()); | 117 OS::Print("Profiler Shutdown %p %s\n", isolate, isolate->name()); |
| 119 } | 118 } |
| 120 } | 119 } |
| 121 } | 120 } |
| 122 | 121 |
| 123 | 122 |
| 124 void Profiler::BeginExecution(Isolate* isolate) { | 123 void Profiler::BeginExecution(Isolate* isolate) { |
| 125 if (isolate == NULL) { | 124 if (isolate == NULL) { |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 return false; | 773 return false; |
| 775 } | 774 } |
| 776 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); | 775 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); |
| 777 cursor += sizeof(fp); | 776 cursor += sizeof(fp); |
| 778 bool r = cursor >= lower_bound_ && cursor < stack_upper_; | 777 bool r = cursor >= lower_bound_ && cursor < stack_upper_; |
| 779 return r; | 778 return r; |
| 780 } | 779 } |
| 781 | 780 |
| 782 | 781 |
| 783 } // namespace dart | 782 } // namespace dart |
| OLD | NEW |