Fix deadlock with the JIT code cache.
Also remove hack done for ThreadStress.
Change-Id: Ie25c3bca08d9f2b8919706fa3fc26c5ab213f4a3
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index cfccec8..ce972ef 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 @@
// 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);
}
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index dcf9601..b09b87f 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -275,9 +275,6 @@
Locks::mutator_lock_->AssertNotExclusiveHeld(self);
Locks::thread_list_lock_->AssertNotHeld(self);
Locks::thread_suspend_count_lock_->AssertNotHeld(self);
- if (kDebugLocking && gAborting == 0) {
- CHECK_NE(self->GetState(), kRunnable);
- }
std::vector<Thread*> suspended_count_modified_threads;
size_t count = 0;
diff --git a/test/004-ThreadStress/run b/test/004-ThreadStress/run
deleted file mode 100755
index 27c501d..0000000
--- a/test/004-ThreadStress/run
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Be less agressive than the default debug option for the jit code cache
-# to avoid timeouts.
-exec ${RUN} "$@" --runtime-option -Xjitcodecachesize:1M