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

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

Issue 86793002: Ensure profiler manager thread has shutdown before main thread (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.cc ('k') | runtime/vm/profiler_linux.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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
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"
11 #include "vm/signal_handler.h" 11 #include "vm/signal_handler.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 DECLARE_FLAG(bool, profile); 15 DECLARE_FLAG(bool, profile);
16 16 DECLARE_FLAG(bool, trace_profiled_isolates);
17 17
18 static void ProfileSignalAction(int signal, siginfo_t* info, void* context_) { 18 static void ProfileSignalAction(int signal, siginfo_t* info, void* context_) {
19 if (signal != SIGPROF) { 19 if (signal != SIGPROF) {
20 return; 20 return;
21 } 21 }
22 Isolate* isolate = Isolate::Current(); 22 Isolate* isolate = Isolate::Current();
23 if (isolate == NULL) { 23 if (isolate == NULL) {
24 return; 24 return;
25 } 25 }
26 // Thread owns no profiler locks at this point. 26 // Thread owns no profiler locks at this point.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 ASSERT(lowest != max_time); 90 ASSERT(lowest != max_time);
91 ASSERT(lowest > 0); 91 ASSERT(lowest > 0);
92 return lowest; 92 return lowest;
93 } 93 }
94 94
95 95
96 void ProfilerManager::ThreadMain(uword parameters) { 96 void ProfilerManager::ThreadMain(uword parameters) {
97 ASSERT(initialized_); 97 ASSERT(initialized_);
98 ASSERT(FLAG_profile); 98 ASSERT(FLAG_profile);
99 SignalHandler::Install(ProfileSignalAction); 99 SignalHandler::Install(ProfileSignalAction);
100 if (FLAG_trace_profiled_isolates) {
101 OS::Print("ProfilerManager Android ready.\n");
102 }
103 thread_running_ = true;
104 {
105 // Signal to main thread we are ready.
106 ScopedMonitor startup_lock(start_stop_monitor_);
107 startup_lock.Notify();
108 }
100 ScopedMonitor lock(monitor_); 109 ScopedMonitor lock(monitor_);
101 while (!shutdown_) { 110 while (!shutdown_) {
102 int64_t current_time = OS::GetCurrentTimeMicros(); 111 int64_t current_time = OS::GetCurrentTimeMicros();
103 int64_t next_sample = SampleAndRescheduleIsolates(current_time); 112 int64_t next_sample = SampleAndRescheduleIsolates(current_time);
104 lock.WaitMicros(next_sample); 113 lock.WaitMicros(next_sample);
105 } 114 }
115 if (FLAG_trace_profiled_isolates) {
116 OS::Print("ProfilerManager Android exiting.\n");
117 }
118 thread_running_ = false;
119 {
120 // Signal to main thread we are exiting.
121 ScopedMonitor shutdown_lock(start_stop_monitor_);
122 shutdown_lock.Notify();
123 }
106 } 124 }
107 125
108 126
109 } // namespace dart 127 } // namespace dart
110 128
111 #endif // defined(TARGET_OS_ANDROID) 129 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/profiler_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698