summaryrefslogtreecommitdiff
path: root/runtime/class_table-inl.h
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2016-04-05 14:36:57 -0700
committer Mathieu Chartier <mathieuc@google.com> 2016-04-06 12:22:42 -0700
commitb8aa1e4c10dcdc7fef96634f87e259dfee83a1cf (patch)
tree807e112893a06d0742f5d595493ec5efa5c72a4e /runtime/class_table-inl.h
parent163388162bde0012dc13a59fb8974723af881e58 (diff)
Shard classloader classes lock
Used to guard adding and removing classes. Previously we used the class linker classes lock, but this had a deadlock issue since the reference processor may need to acquire the lock to mark the classes of a class loader. Another thread could be blocked trying to access weak globals while also holding the class linker classes lock. Bug: 27946564 (cherry picked from commit 1609e3a42051769f4a8be3b6731e7bb2f828b3bb) Change-Id: Ic5cfe573c4e6822d49ad0862ffdd9d036e439a96
Diffstat (limited to 'runtime/class_table-inl.h')
-rw-r--r--runtime/class_table-inl.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/runtime/class_table-inl.h b/runtime/class_table-inl.h
index e512906507..42e320ae71 100644
--- a/runtime/class_table-inl.h
+++ b/runtime/class_table-inl.h
@@ -23,6 +23,7 @@ namespace art {
template<class Visitor>
void ClassTable::VisitRoots(Visitor& visitor) {
+ ReaderMutexLock mu(Thread::Current(), lock_);
for (ClassSet& class_set : classes_) {
for (GcRoot<mirror::Class>& root : class_set) {
visitor.VisitRoot(root.AddressWithoutBarrier());
@@ -35,6 +36,7 @@ void ClassTable::VisitRoots(Visitor& visitor) {
template<class Visitor>
void ClassTable::VisitRoots(const Visitor& visitor) {
+ ReaderMutexLock mu(Thread::Current(), lock_);
for (ClassSet& class_set : classes_) {
for (GcRoot<mirror::Class>& root : class_set) {
visitor.VisitRoot(root.AddressWithoutBarrier());
@@ -47,6 +49,7 @@ void ClassTable::VisitRoots(const Visitor& visitor) {
template <typename Visitor>
bool ClassTable::Visit(Visitor& visitor) {
+ ReaderMutexLock mu(Thread::Current(), lock_);
for (ClassSet& class_set : classes_) {
for (GcRoot<mirror::Class>& root : class_set) {
if (!visitor(root.Read())) {