diff options
author | 2023-12-13 10:32:06 +0000 | |
---|---|---|
committer | 2023-12-13 18:55:21 +0000 | |
commit | e39ccf2ea19ca241b7f1dbd9761db696f2055e29 (patch) | |
tree | 204936e6768fe1f591a6d2ae9fe7cb78ef9e2bd7 /runtime/class_linker.cc | |
parent | 67b7c65d4bc854c5db929cae6864d4d544ab578a (diff) |
Remove the extra compilation sets in the JIT.
They were redundant with the compilation queue. For simplicity, we now
always keep live class loaders if there is JIT activity.
This prevents mutator threads from taking the JIT lock when requesting a
new compilation.
Test: test.py
Bug: 315300060
Change-Id: Iba30078209906474fa9800a834e3a557dcd99cfc
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r-- | runtime/class_linker.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 838d6c1a80..151abeb3db 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -2405,6 +2405,10 @@ void ClassLinker::VisitClassRoots(RootVisitor* visitor, VisitRootFlags flags) { // enabling tracing requires the mutator lock, there are no race conditions here. const bool tracing_enabled = Trace::IsTracingEnabled(); Thread* const self = Thread::Current(); + // For simplicity, if there is JIT activity, we'll trace all class loaders. + // This prevents class unloading while a method is being compiled or is going + // to be compiled. + const bool is_jit_active = jit::Jit::IsActive(self); WriterMutexLock mu(self, *Locks::classlinker_classes_lock_); if (gUseReadBarrier) { // We do not track new roots for CC. @@ -2435,8 +2439,8 @@ void ClassLinker::VisitClassRoots(RootVisitor* visitor, VisitRootFlags flags) { // these objects. UnbufferedRootVisitor root_visitor(visitor, RootInfo(kRootStickyClass)); 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) { + // If tracing is enabled or jit is active, mark all the class loaders to prevent unloading. + if ((flags & kVisitRootFlagClassLoader) != 0 || tracing_enabled || is_jit_active) { for (const ClassLoaderData& data : class_loaders_) { GcRoot<mirror::Object> root(GcRoot<mirror::Object>(self->DecodeJObject(data.weak_root))); root.VisitRoot(visitor, RootInfo(kRootVMInternal)); |