| 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/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
| 10 #include "vm/profiler.h" | 10 #include "vm/profiler.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 126 } |
| 127 | 127 |
| 128 | 128 |
| 129 void ProfilerManager::ThreadMain(uword parameters) { | 129 void ProfilerManager::ThreadMain(uword parameters) { |
| 130 ASSERT(initialized_); | 130 ASSERT(initialized_); |
| 131 ASSERT(FLAG_profile); | 131 ASSERT(FLAG_profile); |
| 132 SignalHandler::Install(ProfileSignalAction); | 132 SignalHandler::Install(ProfileSignalAction); |
| 133 if (FLAG_trace_profiled_isolates) { | 133 if (FLAG_trace_profiled_isolates) { |
| 134 OS::Print("ProfilerManager MacOS ready.\n"); | 134 OS::Print("ProfilerManager MacOS ready.\n"); |
| 135 } | 135 } |
| 136 thread_running_ = true; | |
| 137 { | 136 { |
| 138 // Signal to main thread we are ready. | 137 // Signal to main thread we are ready. |
| 139 ScopedMonitor startup_lock(start_stop_monitor_); | 138 ScopedMonitor startup_lock(start_stop_monitor_); |
| 139 thread_running_ = true; |
| 140 startup_lock.Notify(); | 140 startup_lock.Notify(); |
| 141 } | 141 } |
| 142 ScopedMonitor lock(monitor_); | 142 ScopedMonitor lock(monitor_); |
| 143 while (!shutdown_) { | 143 while (!shutdown_) { |
| 144 int64_t current_time = OS::GetCurrentTimeMicros(); | 144 int64_t current_time = OS::GetCurrentTimeMicros(); |
| 145 int64_t next_sample = SampleAndRescheduleIsolates(current_time); | 145 int64_t next_sample = SampleAndRescheduleIsolates(current_time); |
| 146 lock.WaitMicros(next_sample); | 146 lock.WaitMicros(next_sample); |
| 147 } | 147 } |
| 148 if (FLAG_trace_profiled_isolates) { | 148 if (FLAG_trace_profiled_isolates) { |
| 149 OS::Print("ProfilerManager MacOS exiting.\n"); | 149 OS::Print("ProfilerManager MacOS exiting.\n"); |
| 150 } | 150 } |
| 151 thread_running_ = false; | |
| 152 { | 151 { |
| 153 // Signal to main thread we are exiting. | 152 // Signal to main thread we are exiting. |
| 154 ScopedMonitor shutdown_lock(start_stop_monitor_); | 153 ScopedMonitor shutdown_lock(start_stop_monitor_); |
| 154 thread_running_ = false; |
| 155 shutdown_lock.Notify(); | 155 shutdown_lock.Notify(); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 | 159 |
| 160 } // namespace dart | 160 } // namespace dart |
| 161 | 161 |
| 162 #endif // defined(TARGET_OS_MACOS) | 162 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |