diff options
author | 2023-01-13 13:32:21 +0000 | |
---|---|---|
committer | 2023-01-16 13:32:54 +0000 | |
commit | 733b0202736dde8508f7764bbf98e92684002acc (patch) | |
tree | 4d6b6f6ff503b6639c36a281246780ee4637340d | |
parent | ae12f96965dd1fb1cf5fefb0188b749e921ba88b (diff) |
Reland "Limited deopt request from jvmti should enable entry / exit hooks""
This reverts commit b69a3ebf5a4a4ef8ae25db170fce9e25844a2f1b.
Reason for revert: Re-landing with a fix.
It is OK to use resolution stubs when entry / exit stubs are required.
Resolution stubs fetch code that supports entry / exit hooks when required.
Change-Id: I0e7d807df2c92249cd17e2a5df324ac47e248874
-rw-r--r-- | openjdkjvmti/deopt_manager.cc | 9 | ||||
-rw-r--r-- | runtime/instrumentation.cc | 14 | ||||
-rw-r--r-- | runtime/instrumentation.h | 5 |
3 files changed, 25 insertions, 3 deletions
diff --git a/openjdkjvmti/deopt_manager.cc b/openjdkjvmti/deopt_manager.cc index 129aa0ff4a..99acb87257 100644 --- a/openjdkjvmti/deopt_manager.cc +++ b/openjdkjvmti/deopt_manager.cc @@ -496,6 +496,15 @@ void DeoptManager::AddDeoptimizationRequester() { art::ScopedThreadStateChange stsc(self, art::ThreadState::kSuspended); deoptimization_status_lock_.ExclusiveLock(self); deopter_count_++; + if (deopter_count_ == 1) { + // When we add a deoptimization requester, we should enable entry / exit hooks. We only call + // this in debuggable runtimes and hence it won't be necessary to update entrypoints but we + // still need to inform instrumentation that we need to actually run entry / exit hooks. Though + // entrypoints are capable of running entry / exit hooks they won't run them unless enabled. + ScopedDeoptimizationContext sdc(self, this); + art::Runtime::Current()->GetInstrumentation()->EnableEntryExitHooks(kInstrumentationKey); + return; + } deoptimization_status_lock_.ExclusiveUnlock(self); } diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index 60511b546c..62a2d8f6b3 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -223,8 +223,11 @@ static bool CodeSupportsEntryExitHooks(const void* entry_point, ArtMethod* metho return false; } - // Code running in the interpreter doesn't need entry/exit stubs. - if (Runtime::Current()->GetClassLinker()->IsQuickToInterpreterBridge(entry_point)) { + ClassLinker* linker = Runtime::Current()->GetClassLinker(); + // Interpreter supports entry / exit hooks. Resolution stubs fetch code that supports entry / exit + // hooks when required. So return true for both cases. + if (linker->IsQuickToInterpreterBridge(entry_point) || + linker->IsQuickResolutionStub(entry_point)) { return true; } @@ -238,7 +241,7 @@ static bool CodeSupportsEntryExitHooks(const void* entry_point, ArtMethod* metho } // GenericJni trampoline can handle entry / exit hooks. - if (Runtime::Current()->GetClassLinker()->IsQuickGenericJniStub(entry_point)) { + if (linker->IsQuickGenericJniStub(entry_point)) { return true; } @@ -881,6 +884,11 @@ void Instrumentation::UpdateInstrumentationLevel(InstrumentationLevel requested_ instrumentation_level_ = requested_level; } +void Instrumentation::EnableEntryExitHooks(const char* key) { + DCHECK(Runtime::Current()->IsJavaDebuggable()); + ConfigureStubs(key, InstrumentationLevel::kInstrumentWithInstrumentationStubs); +} + void Instrumentation::MaybeRestoreInstrumentationStack() { // Restore stack only if there is no method currently deoptimized. if (!IsDeoptimizedMethodsEmpty()) { diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h index 3d868ebc09..626ff8e723 100644 --- a/runtime/instrumentation.h +++ b/runtime/instrumentation.h @@ -243,6 +243,11 @@ class Instrumentation { void DisableDeoptimization(const char* key) REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_); + // Enables entry exit hooks support. This is called in preparation for debug requests that require + // calling method entry / exit hooks. + void EnableEntryExitHooks(const char* key) + REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_); + bool AreAllMethodsDeoptimized() const { return InterpreterStubsInstalled(); } |