Move inline caches GC handling in JitCodeCache.
Make the classes they hold weak references and visit
them during SweepJitRoots.
This fixes the newly introduced deadlock:
Thread1:
1) Lock JitCodeCache lock to create Profiling info for
ArtMethod m.
2) m is a copied method, we need to track the actual holder,
needing to decode a weak reference.
3) Weak references are not accessible due to GC.
GC Thread:
- Disallow weak reference access.
- Wait for checkpoint.
Thread2:
- Try to lock JitCodeCache lock
- Deadlock, as Thread1 owns the JitCodeCache lock.
Test: test-art-host
bug: 31289185
bug: 33198826
Change-Id: I7ee17631015450ace8d2a0264415a81c5a902bb8
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index aa5da2e..5def65e 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -65,8 +65,10 @@
OFFSET_OF_OBJECT_MEMBER(Class, super_class_));
}
+template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
inline ClassLoader* Class::GetClassLoader() {
- return GetFieldObject<ClassLoader>(OFFSET_OF_OBJECT_MEMBER(Class, class_loader_));
+ return GetFieldObject<ClassLoader, kVerifyFlags, kReadBarrierOption>(
+ OFFSET_OF_OBJECT_MEMBER(Class, class_loader_));
}
template<VerifyObjectFlags kVerifyFlags>