summaryrefslogtreecommitdiff
path: root/runtime/jit/jit_code_cache.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2015-11-03 10:28:03 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-11-03 10:28:03 +0000
commitdf6dc42ba2ca0fa43ba970ba2e60977422105f7e (patch)
tree351a2190729632df3135538665bd0616c1cf1056 /runtime/jit/jit_code_cache.cc
parent4bbe7807f313bb8e59131812c31bf31513094f8f (diff)
parent62623401fe994ff2f2719faf3cdb3c23b92ccd96 (diff)
Merge "Fix deadlock with the JIT code cache."
Diffstat (limited to 'runtime/jit/jit_code_cache.cc')
-rw-r--r--runtime/jit/jit_code_cache.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index cfccec87cf..ce972ef976 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -25,6 +25,7 @@
#include "linear_alloc.h"
#include "mem_map.h"
#include "oat_file-inl.h"
+#include "scoped_thread_state_change.h"
#include "thread_list.h"
namespace art {
@@ -407,9 +408,17 @@ void JitCodeCache::GarbageCollectCache(Thread* self) {
// Run a checkpoint on all threads to mark the JIT compiled code they are running.
{
Barrier barrier(0);
- MarkCodeClosure closure(this, &barrier);
- size_t threads_running_checkpoint =
- Runtime::Current()->GetThreadList()->RunCheckpoint(&closure);
+ size_t threads_running_checkpoint = 0;
+ {
+ // Walking the stack requires the mutator lock.
+ // We only take the lock when running the checkpoint and not waiting so that
+ // when we go back to suspended, we can execute checkpoints that were requested
+ // concurrently, and then move to waiting for our own checkpoint to finish.
+ ScopedObjectAccess soa(self);
+ MarkCodeClosure closure(this, &barrier);
+ threads_running_checkpoint =
+ Runtime::Current()->GetThreadList()->RunCheckpoint(&closure);
+ }
if (threads_running_checkpoint != 0) {
barrier.Increment(self, threads_running_checkpoint);
}