summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author Lokesh Gidra <lokeshgidra@google.com> 2023-09-13 22:11:52 +0000
committer Lokesh Gidra <lokeshgidra@google.com> 2023-10-17 15:52:15 +0000
commit97a6f7cd191cde0abaaf6323ae2f67d8e42a1236 (patch)
tree209182e3e2c56973463e7dad320520a08667cfb2 /runtime/class_linker.cc
parentd5c097bcda44e237ecabcdba9b3dca2348289138 (diff)
Update class-table and intern-table concurrently with uffd GC
Bug: 160737021 Test: art/testrunner/testrunner.py Change-Id: I4413ead05947f3f865116ae8dc7d67d860106b37
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc20
1 files changed, 7 insertions, 13 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 9d175cdba5..d4666e5f9c 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2426,17 +2426,9 @@ void ClassLinker::VisitClassRoots(RootVisitor* visitor, VisitRootFlags flags) {
boot_class_table_->VisitRoots(root_visitor);
// If tracing is enabled, then mark all the class loaders to prevent unloading.
if ((flags & kVisitRootFlagClassLoader) != 0 || tracing_enabled) {
- gc::Heap* const heap = Runtime::Current()->GetHeap();
- // Don't visit class-loaders if compacting with userfaultfd GC as these
- // weaks are updated using Runtime::SweepSystemWeaks() and the GC doesn't
- // tolerate double updates.
- if (!heap->IsPerformingUffdCompaction()) {
- for (const ClassLoaderData& data : class_loaders_) {
- GcRoot<mirror::Object> root(GcRoot<mirror::Object>(self->DecodeJObject(data.weak_root)));
- root.VisitRoot(visitor, RootInfo(kRootVMInternal));
- }
- } else {
- DCHECK_EQ(heap->CurrentCollectorType(), gc::CollectorType::kCollectorTypeCMC);
+ for (const ClassLoaderData& data : class_loaders_) {
+ GcRoot<mirror::Object> root(GcRoot<mirror::Object>(self->DecodeJObject(data.weak_root)));
+ root.VisitRoot(visitor, RootInfo(kRootVMInternal));
}
}
} else if (!gUseReadBarrier && (flags & kVisitRootFlagNewRoots) != 0) {
@@ -2476,9 +2468,11 @@ void ClassLinker::VisitClassRoots(RootVisitor* visitor, VisitRootFlags flags) {
// Keep in sync with InitCallback. Anything we visit, we need to
// reinit references to when reinitializing a ClassLinker from a
// mapped image.
-void ClassLinker::VisitRoots(RootVisitor* visitor, VisitRootFlags flags) {
+void ClassLinker::VisitRoots(RootVisitor* visitor, VisitRootFlags flags, bool visit_class_roots) {
class_roots_.VisitRootIfNonNull(visitor, RootInfo(kRootVMInternal));
- VisitClassRoots(visitor, flags);
+ if (visit_class_roots) {
+ VisitClassRoots(visitor, flags);
+ }
// Instead of visiting the find_array_class_cache_ drop it so that it doesn't prevent class
// unloading if we are marking roots.
DropFindArrayClassCache();