diff options
author | 2023-09-07 15:09:10 +0000 | |
---|---|---|
committer | 2023-09-12 08:30:09 +0000 | |
commit | b63b4a28ed2cdbfae75fb5e550313ce3ccec1eae (patch) | |
tree | 69f52aec5e0220ed951396aeded9c38869eb9a4d | |
parent | 82d1afc3d654823a4f0c6fbefc3da52575ac0370 (diff) |
Reland "Don't use shared hotness counters for debuggable runtimes""
This reverts commit 834fb38bc0fb16d7d79bc877fced920065bbff82.
Reason for revert: Reland after a fix for the failing test landed b/299090869
Bug: 296416302
Change-Id: Iddbde561e292d8d9177538a5d2ff162355041d9a
-rw-r--r-- | runtime/class_linker.cc | 5 | ||||
-rw-r--r-- | runtime/runtime.cc | 13 |
2 files changed, 13 insertions, 5 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 1edb694a1d..953cc676dc 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -2236,11 +2236,14 @@ bool ClassLinker::AddImageSpace(gc::space::ImageSpace* space, // If we are profiling the boot classpath, we disable the shared memory // optimization to make sure boot classpath methods all get properly // profiled. + // For debuggable runtimes we don't use AOT code, so don't use shared memory + // optimization so the methods can be JITed better. // // We need to disable the flag before doing ResetCounter below, as counters // of shared memory method always hold the "hot" value. if (!runtime->IsZygote() || - runtime->GetJITOptions()->GetProfileSaverOptions().GetProfileBootClassPath()) { + runtime->GetJITOptions()->GetProfileSaverOptions().GetProfileBootClassPath() || + runtime->IsJavaDebuggable()) { header.VisitPackedArtMethods([&](ArtMethod& method) REQUIRES_SHARED(Locks::mutator_lock_) { method.ClearMemorySharedMethod(); }, space->Begin(), image_pointer_size_); diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 8e70de5445..c234c6491d 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -3277,10 +3277,12 @@ RuntimeCallbacks* Runtime::GetRuntimeCallbacks() { return callbacks_.get(); } -// Used to patch boot image method entry point to interpreter bridge. -class UpdateEntryPointsClassVisitor : public ClassVisitor { +// Used to update boot image to not use AOT code. This is used when transitioning the runtime to +// java debuggable. This visitor re-initializes the entry points without using AOT code. This also +// disables shared hotness counters so the necessary methods can be JITed more efficiently. +class DeoptimizeBootImageClassVisitor : public ClassVisitor { public: - explicit UpdateEntryPointsClassVisitor(instrumentation::Instrumentation* instrumentation) + explicit DeoptimizeBootImageClassVisitor(instrumentation::Instrumentation* instrumentation) : instrumentation_(instrumentation) {} bool operator()(ObjPtr<mirror::Class> klass) override REQUIRES(Locks::mutator_lock_) { @@ -3314,6 +3316,9 @@ class UpdateEntryPointsClassVisitor : public ClassVisitor { m.ClearPreCompiled(); instrumentation_->InitializeMethodsCode(&m, /*aot_code=*/ nullptr); } + + // Clear MemorySharedAccessFlags so the boot class methods can be JITed better. + m.ClearMemorySharedMethod(); } return true; } @@ -3334,7 +3339,7 @@ void Runtime::DeoptimizeBootImage() { // If we've already started and we are setting this runtime to debuggable, // we patch entry points of methods in boot image to interpreter bridge, as // boot image code may be AOT compiled as not debuggable. - UpdateEntryPointsClassVisitor visitor(GetInstrumentation()); + DeoptimizeBootImageClassVisitor visitor(GetInstrumentation()); GetClassLinker()->VisitClasses(&visitor); jit::Jit* jit = GetJit(); if (jit != nullptr) { |