Address comments from aog/1180224.
Move handling of objects in interpreter cache to weak objects.
Bug: 119800099
Test: test.py
Change-Id: Ie7b2b2e285607a7c1460fd4f0b4ea690f9a16594
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 3c6e437..fad0de6 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -702,6 +702,7 @@
// from mutators. See b/32167580.
GetJit()->GetCodeCache()->SweepRootTables(visitor);
}
+ thread_list_->SweepInterpreterCaches(visitor);
// All other generic system-weak holders.
for (gc::AbstractSystemWeakHolder* holder : system_weak_holders_) {
@@ -2978,4 +2979,29 @@
return !IsAotCompiler() && !(IsSystemServer() && jit_options_->GetSaveProfilingInfo());
}
+void Runtime::ProcessWeakClass(GcRoot<mirror::Class>* root_ptr,
+ IsMarkedVisitor* visitor,
+ mirror::Class* update) {
+ // This does not need a read barrier because this is called by GC.
+ mirror::Class* cls = root_ptr->Read<kWithoutReadBarrier>();
+ if (cls != nullptr && cls != GetWeakClassSentinel()) {
+ DCHECK((cls->IsClass<kDefaultVerifyFlags>()));
+ // Look at the classloader of the class to know if it has been unloaded.
+ // This does not need a read barrier because this is called by GC.
+ ObjPtr<mirror::Object> class_loader =
+ cls->GetClassLoader<kDefaultVerifyFlags, kWithoutReadBarrier>();
+ if (class_loader == nullptr || visitor->IsMarked(class_loader.Ptr()) != nullptr) {
+ // The class loader is live, update the entry if the class has moved.
+ mirror::Class* new_cls = down_cast<mirror::Class*>(visitor->IsMarked(cls));
+ // Note that new_object can be null for CMS and newly allocated objects.
+ if (new_cls != nullptr && new_cls != cls) {
+ *root_ptr = GcRoot<mirror::Class>(new_cls);
+ }
+ } else {
+ // The class loader is not live, clear the entry.
+ *root_ptr = GcRoot<mirror::Class>(update);
+ }
+ }
+}
+
} // namespace art