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

Unified Diff: runtime/vm/profiler.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, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/profiler.h ('k') | runtime/vm/profiler_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/profiler.cc
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index 7945c1489e3f68f70b397d218829ff27a927dd9d..f79d49d32aa36fc0e692b00f663ac7a8fd5446f4 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -73,7 +73,9 @@ DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates.");
bool ProfilerManager::initialized_ = false;
bool ProfilerManager::shutdown_ = false;
+bool ProfilerManager::thread_running_ = false;
Monitor* ProfilerManager::monitor_ = NULL;
+Monitor* ProfilerManager::start_stop_monitor_ = NULL;
Isolate** ProfilerManager::isolates_ = NULL;
intptr_t ProfilerManager::isolates_capacity_ = 0;
intptr_t ProfilerManager::isolates_size_ = 0;
@@ -90,9 +92,23 @@ void ProfilerManager::InitOnce() {
NativeSymbolResolver::InitOnce();
ASSERT(!initialized_);
monitor_ = new Monitor();
+ start_stop_monitor_ = new Monitor();
initialized_ = true;
ResizeIsolates(16);
- Thread::Start(ThreadMain, 0);
+ if (FLAG_trace_profiled_isolates) {
+ OS::Print("ProfilerManager starting up.\n");
+ }
+ {
+ ScopedMonitor startup_lock(start_stop_monitor_);
+ Thread::Start(ThreadMain, 0);
+ while (!thread_running_) {
+ // Wait until profiler thread has started up.
+ startup_lock.Wait();
+ }
+ }
+ if (FLAG_trace_profiled_isolates) {
+ OS::Print("ProfilerManager running.\n");
+ }
}
@@ -101,11 +117,16 @@ void ProfilerManager::Shutdown() {
return;
}
ASSERT(initialized_);
+ if (FLAG_trace_profiled_isolates) {
+ OS::Print("ProfilerManager shutting down.\n");
+ }
+ intptr_t size_at_shutdown = 0;
{
ScopedSignalBlocker ssb;
{
ScopedMonitor lock(monitor_);
shutdown_ = true;
+ size_at_shutdown = isolates_size_;
isolates_size_ = 0;
free(isolates_);
isolates_ = NULL;
@@ -113,6 +134,17 @@ void ProfilerManager::Shutdown() {
}
}
NativeSymbolResolver::ShutdownOnce();
+ {
+ ScopedMonitor shutdown_lock(start_stop_monitor_);
+ while (thread_running_) {
+ // Wait until profiler thread has exited.
+ shutdown_lock.Wait();
+ }
+ }
+ initialized_ = false;
+ if (FLAG_trace_profiled_isolates) {
+ OS::Print("ProfilerManager shut down (%" Pd ").\n", size_at_shutdown);
+ }
}
@@ -133,7 +165,7 @@ void ProfilerManager::SetupIsolateForProfiling(Isolate* isolate) {
profiler_data->set_sample_interval_micros(1000);
isolate->set_profiler_data(profiler_data);
if (FLAG_trace_profiled_isolates) {
- OS::Print("PROF SETUP %p %s %p\n",
+ OS::Print("ProfilerManager Setup Isolate %p %s %p\n",
isolate,
isolate->name(),
reinterpret_cast<void*>(Thread::GetCurrentThreadId()));
@@ -157,8 +189,10 @@ void ProfilerManager::FreeIsolateProfilingData(Isolate* isolate) {
delete sample_buffer;
delete profiler_data;
if (FLAG_trace_profiled_isolates) {
- OS::Print("PROF SHUTDOWN %p %s %p\n", isolate,
- isolate->name(), reinterpret_cast<void*>(Thread::GetCurrentThreadId()));
+ OS::Print("ProfilerManager Shutdown Isolate %p %s %p\n",
+ isolate,
+ isolate->name(),
+ reinterpret_cast<void*>(Thread::GetCurrentThreadId()));
}
}
« no previous file with comments | « runtime/vm/profiler.h ('k') | runtime/vm/profiler_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698