diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-01-09 11:23:53 -0800 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-03-05 12:44:22 -0800 |
commit | 661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8 (patch) | |
tree | 02e428694277d85a98505f8e814aba378fc7651c /runtime/instrumentation.cc | |
parent | 3cd52df3d740f8a656233b199dfcaab165f415ff (diff) | |
download | art-661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8.tar.gz art-661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8.tar.bz2 art-661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8.zip |
Fix valgrind gtests and memory leaks.
All tests pass other than image_test which passes if some bad reads
are disabled (buzbee working on this).
Change-Id: Ifd6b6e3aed0bc867703b6e818353a9f296609422
Diffstat (limited to 'runtime/instrumentation.cc')
-rw-r--r-- | runtime/instrumentation.cc | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index e10d881a09..89a63ac2d9 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -457,6 +457,22 @@ static void ResetQuickAllocEntryPointsForThread(Thread* thread, void* arg) { thread->ResetQuickAllocEntryPointsForThread(); } +void Instrumentation::SetEntrypointsInstrumented(bool instrumented) { + Runtime* runtime = Runtime::Current(); + ThreadList* tl = runtime->GetThreadList(); + if (runtime->IsStarted()) { + tl->SuspendAll(); + } + { + MutexLock mu(Thread::Current(), *Locks::runtime_shutdown_lock_); + SetQuickAllocEntryPointsInstrumented(instrumented); + ResetQuickAllocEntryPoints(); + } + if (runtime->IsStarted()) { + tl->ResumeAll(); + } +} + void Instrumentation::InstrumentQuickAllocEntryPoints() { // TODO: the read of quick_alloc_entry_points_instrumentation_counter_ is racey and this code // should be guarded by a lock. @@ -464,15 +480,7 @@ void Instrumentation::InstrumentQuickAllocEntryPoints() { const bool enable_instrumentation = quick_alloc_entry_points_instrumentation_counter_.FetchAndAdd(1) == 0; if (enable_instrumentation) { - // Instrumentation wasn't enabled so enable it. - ThreadList* tl = Runtime::Current()->GetThreadList(); - tl->SuspendAll(); - { - MutexLock mu(Thread::Current(), *Locks::runtime_shutdown_lock_); - SetQuickAllocEntryPointsInstrumented(true); - ResetQuickAllocEntryPoints(); - } - tl->ResumeAll(); + SetEntrypointsInstrumented(true); } } @@ -483,14 +491,7 @@ void Instrumentation::UninstrumentQuickAllocEntryPoints() { const bool disable_instrumentation = quick_alloc_entry_points_instrumentation_counter_.FetchAndSub(1) == 1; if (disable_instrumentation) { - ThreadList* tl = Runtime::Current()->GetThreadList(); - tl->SuspendAll(); - { - MutexLock mu(Thread::Current(), *Locks::runtime_shutdown_lock_); - SetQuickAllocEntryPointsInstrumented(false); - ResetQuickAllocEntryPoints(); - } - tl->ResumeAll(); + SetEntrypointsInstrumented(false); } } |