From 97a6f7cd191cde0abaaf6323ae2f67d8e42a1236 Mon Sep 17 00:00:00 2001 From: Lokesh Gidra Date: Wed, 13 Sep 2023 22:11:52 +0000 Subject: Update class-table and intern-table concurrently with uffd GC Bug: 160737021 Test: art/testrunner/testrunner.py Change-Id: I4413ead05947f3f865116ae8dc7d67d860106b37 --- runtime/class_table-inl.h | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'runtime/class_table-inl.h') diff --git a/runtime/class_table-inl.h b/runtime/class_table-inl.h index ecc8a0a620..4ee59a79f7 100644 --- a/runtime/class_table-inl.h +++ b/runtime/class_table-inl.h @@ -68,12 +68,14 @@ inline bool ClassTable::ClassDescriptorEquals::operator()(const TableSlot& a, return a.Read()->DescriptorEquals(b.first); } -template -void ClassTable::VisitRoots(Visitor& visitor) { +template +void ClassTable::VisitRoots(Visitor& visitor, bool skip_classes) { ReaderMutexLock mu(Thread::Current(), lock_); - for (ClassSet& class_set : classes_) { - for (TableSlot& table_slot : class_set) { - table_slot.VisitRoot(visitor); + if (!skip_classes) { + for (ClassSet& class_set : classes_) { + for (TableSlot& table_slot : class_set) { + table_slot.VisitRoot(visitor); + } } } for (GcRoot& root : strong_roots_) { @@ -86,12 +88,14 @@ void ClassTable::VisitRoots(Visitor& visitor) { } } -template -void ClassTable::VisitRoots(const Visitor& visitor) { +template +void ClassTable::VisitRoots(const Visitor& visitor, bool skip_classes) { ReaderMutexLock mu(Thread::Current(), lock_); - for (ClassSet& class_set : classes_) { - for (TableSlot& table_slot : class_set) { - table_slot.VisitRoot(visitor); + if (!skip_classes) { + for (ClassSet& class_set : classes_) { + for (TableSlot& table_slot : class_set) { + table_slot.VisitRoot(visitor); + } } } for (GcRoot& root : strong_roots_) { @@ -104,6 +108,18 @@ void ClassTable::VisitRoots(const Visitor& visitor) { } } +template +void ClassTable::VisitClassesIfConditionMet(Condition& cond, Visitor& visitor) { + ReaderMutexLock mu(Thread::Current(), lock_); + for (ClassSet& class_set : classes_) { + if (cond(class_set)) { + for (TableSlot& table_slot : class_set) { + table_slot.VisitRoot(visitor); + } + } + } +} + template class ClassTable::TableSlot::ClassAndRootVisitor { public: -- cgit v1.2.3-59-g8ed1b