| 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/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/json_stream.h" | 10 #include "vm/json_stream.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (!FLAG_profile) { | 162 if (!FLAG_profile) { |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 { | 165 { |
| 166 ScopedSignalBlocker ssb; | 166 ScopedSignalBlocker ssb; |
| 167 FreeIsolateProfilingData(isolate); | 167 FreeIsolateProfilingData(isolate); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 | 171 |
| 172 void ProfilerManager::ScheduleIsolateHelper(Isolate* isolate) { |
| 173 ScopedMonitor lock(monitor_); |
| 174 intptr_t i = FindIsolate(isolate); |
| 175 if (i >= 0) { |
| 176 // Already scheduled. |
| 177 return; |
| 178 } |
| 179 { |
| 180 ScopedMutex profiler_data_lock(isolate->profiler_data_mutex()); |
| 181 IsolateProfilerData* profiler_data = isolate->profiler_data(); |
| 182 if (profiler_data == NULL) { |
| 183 return; |
| 184 } |
| 185 profiler_data->Scheduled(OS::GetCurrentTimeMicros(), |
| 186 Thread::GetCurrentThreadId()); |
| 187 } |
| 188 AddIsolate(isolate); |
| 189 lock.Notify(); |
| 190 } |
| 191 |
| 192 |
| 172 void ProfilerManager::ScheduleIsolate(Isolate* isolate, bool inside_signal) { | 193 void ProfilerManager::ScheduleIsolate(Isolate* isolate, bool inside_signal) { |
| 173 if (!FLAG_profile) { | 194 if (!FLAG_profile) { |
| 174 return; | 195 return; |
| 175 } | 196 } |
| 176 ASSERT(initialized_); | 197 ASSERT(initialized_); |
| 177 ASSERT(isolate != NULL); | 198 ASSERT(isolate != NULL); |
| 178 if (!inside_signal) { | 199 if (!inside_signal) { |
| 179 ScopedSignalBlocker ssb; | 200 ScopedSignalBlocker ssb; |
| 180 { | 201 { |
| 181 ScopedMonitor lock(monitor_); | 202 ScheduleIsolateHelper(isolate); |
| 182 { | |
| 183 ScopedMutex profiler_data_lock(isolate->profiler_data_mutex()); | |
| 184 IsolateProfilerData* profiler_data = isolate->profiler_data(); | |
| 185 if (profiler_data == NULL) { | |
| 186 return; | |
| 187 } | |
| 188 profiler_data->Scheduled(OS::GetCurrentTimeMicros(), | |
| 189 Thread::GetCurrentThreadId()); | |
| 190 } | |
| 191 AddIsolate(isolate); | |
| 192 lock.Notify(); | |
| 193 } | 203 } |
| 194 } else { | 204 } else { |
| 195 // Do not need a signal blocker inside a signal handler. | 205 // Do not need a signal blocker inside a signal handler. |
| 196 { | 206 { |
| 197 ScopedMonitor lock(monitor_); | 207 ScheduleIsolateHelper(isolate); |
| 198 { | |
| 199 ScopedMutex profiler_data_lock(isolate->profiler_data_mutex()); | |
| 200 IsolateProfilerData* profiler_data = isolate->profiler_data(); | |
| 201 if (profiler_data == NULL) { | |
| 202 return; | |
| 203 } | |
| 204 profiler_data->Scheduled(OS::GetCurrentTimeMicros(), | |
| 205 Thread::GetCurrentThreadId()); | |
| 206 } | |
| 207 AddIsolate(isolate); | |
| 208 lock.Notify(); | |
| 209 } | 208 } |
| 210 } | 209 } |
| 211 } | 210 } |
| 212 | 211 |
| 213 | 212 |
| 214 void ProfilerManager::DescheduleIsolate(Isolate* isolate) { | 213 void ProfilerManager::DescheduleIsolate(Isolate* isolate) { |
| 215 if (!FLAG_profile) { | 214 if (!FLAG_profile) { |
| 216 return; | 215 return; |
| 217 } | 216 } |
| 218 ASSERT(initialized_); | 217 ASSERT(initialized_); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 return false; | 644 return false; |
| 646 } | 645 } |
| 647 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); | 646 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); |
| 648 cursor += sizeof(fp); | 647 cursor += sizeof(fp); |
| 649 bool r = cursor >= lower_bound_ && cursor < stack_upper_; | 648 bool r = cursor >= lower_bound_ && cursor < stack_upper_; |
| 650 return r; | 649 return r; |
| 651 } | 650 } |
| 652 | 651 |
| 653 | 652 |
| 654 } // namespace dart | 653 } // namespace dart |
| OLD | NEW |