Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: runtime/vm/profiler_macos.cc

Issue 92123002: Fix race discovered by Valgrind (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/profiler_linux.cc ('k') | runtime/vm/profiler_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)
OLDNEW
« no previous file with comments | « runtime/vm/profiler_linux.cc ('k') | runtime/vm/profiler_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698