diff options
| author | 2014-05-27 23:04:08 +0000 | |
|---|---|---|
| committer | 2014-05-27 23:04:08 +0000 | |
| commit | 7f7b77ef175e0f679c3a906a82e9a328cd08d524 (patch) | |
| tree | b7dae57111c7ec9e278c01f1539d0de49cd1e354 | |
| parent | c569fe80cd3b5bde781597767ba977c7d0e777ce (diff) | |
| parent | 9bec54430e8609765740fdc51d24ed3f3c907919 (diff) | |
am 9bec5443: Merge "Fix the problem of not shutting down the profiler in ART properly"
* commit '9bec54430e8609765740fdc51d24ed3f3c907919':
Fix the problem of not shutting down the profiler in ART properly
| -rw-r--r-- | runtime/profiler.cc | 7 | ||||
| -rw-r--r-- | runtime/runtime.cc | 5 |
2 files changed, 8 insertions, 4 deletions
diff --git a/runtime/profiler.cc b/runtime/profiler.cc index 6e33f9d232..5459ce3116 100644 --- a/runtime/profiler.cc +++ b/runtime/profiler.cc @@ -193,7 +193,7 @@ void* BackgroundMethodSamplingProfiler::RunProfilerThread(void* arg) { valid_samples += barrier_count; - ThreadState old_state = self->SetState(kWaitingForCheckPointsToRun); + ScopedThreadStateChange tsc(self, kWaitingForCheckPointsToRun); // Wait for the barrier to be crossed by all runnable threads. This wait // is done with a timeout so that we can detect problems with the checkpoint @@ -211,13 +211,11 @@ void* BackgroundMethodSamplingProfiler::RunProfilerThread(void* arg) { // code. Crash the process in this case. CHECK_LT(waitdiff_us, kWaitTimeoutUs); - self->SetState(old_state); - // Update the current time. now_us = MicroTime(); } - if (valid_samples > 0 && !ShuttingDown(self)) { + if (valid_samples > 0) { // After the profile has been taken, write it out. ScopedObjectAccess soa(self); // Acquire the mutator lock. uint32_t size = profiler->WriteProfile(); @@ -335,6 +333,7 @@ void BackgroundMethodSamplingProfiler::Stop() { pthread_t profiler_pthread = 0U; { MutexLock trace_mu(Thread::Current(), *Locks::profiler_lock_); + CHECK(!shutting_down_); profiler = profiler_; shutting_down_ = true; profiler_pthread = profiler_pthread_; diff --git a/runtime/runtime.cc b/runtime/runtime.cc index dcbf42df9b..f76b580a06 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -164,6 +164,11 @@ Runtime::~Runtime() { } shutting_down_ = true; } + // Shut down background profiler before the runtime exits. + if (profile_) { + BackgroundMethodSamplingProfiler::Shutdown(); + } + Trace::Shutdown(); // Make sure to let the GC complete if it is running. |