Fix 616-cha-unloading.
Consider cases of implicit arena reuse to prevent false positives.
Test: 616-cha-unloading
Change-Id: Ia1755fb66167279c08dd9ba59813402e798c0b79
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 2f6b754..fa70f65 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -97,6 +97,14 @@
REQUIRES_SHARED(Locks::classlinker_classes_lock_, Locks::mutator_lock_) = 0;
};
+class AllocatorVisitor {
+ public:
+ virtual ~AllocatorVisitor() {}
+ // Return true to continue visiting.
+ virtual bool Visit(LinearAlloc* alloc)
+ REQUIRES_SHARED(Locks::classlinker_classes_lock_, Locks::mutator_lock_) = 0;
+};
+
class ClassLinker {
public:
// Well known mirror::Class roots accessed via GetClassRoot.
@@ -664,6 +672,11 @@
REQUIRES(!Locks::classlinker_classes_lock_)
REQUIRES_SHARED(Locks::mutator_lock_);
+ // Visit all of the allocators that belong to classloaders except boot classloader.
+ // This is used by 616-cha-unloading test to confirm memory reuse.
+ void VisitAllocators(AllocatorVisitor* visitor) const
+ REQUIRES_SHARED(Locks::classlinker_classes_lock_, Locks::mutator_lock_);
+
// Throw the class initialization failure recorded when first trying to initialize the given
// class.
void ThrowEarlierClassFailure(ObjPtr<mirror::Class> c, bool wrap_in_no_class_def = false)