Don't deoptimize everything with can_access_local_variables
Change the can_access_local_variables setup to not need to deoptimize
everything immediately. Instead ensure all methods are
async-deoptimizable and deoptimize the thread we are examining prior
to examining the stack.
Test: ./test.py --host -j50
Bug: 33616143
Bug: 34414073
Change-Id: I312a4865c09e63a8d3fe3b2d201f1c071fb4305f
diff --git a/openjdkjvmti/ti_method.cc b/openjdkjvmti/ti_method.cc
index f99b167..05943e7 100644
--- a/openjdkjvmti/ti_method.cc
+++ b/openjdkjvmti/ti_method.cc
@@ -39,6 +39,7 @@
#include "base/mutex-inl.h"
#include "dex_file_annotations.h"
#include "events-inl.h"
+#include "jit/jit.h"
#include "jni_internal.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
@@ -552,7 +553,7 @@
return;
}
art::ArtMethod* method = visitor.GetMethod();
- if (method->IsNative() || !visitor.IsShadowFrame()) {
+ if (method->IsNative()) {
// TODO We really should support get/set for non-shadow frames.
result_ = ERR(OPAQUE_FRAME);
return;
@@ -560,6 +561,7 @@
result_ = ERR(INVALID_SLOT);
return;
}
+ bool needs_instrument = !visitor.IsShadowFrame();
uint32_t pc = visitor.GetDexPc(/*abort_on_failure*/ false);
if (pc == art::DexFile::kDexNoIndex) {
// Cannot figure out current PC.
@@ -580,6 +582,9 @@
return;
}
result_ = Execute(method, visitor);
+ if (needs_instrument) {
+ art::Runtime::Current()->GetInstrumentation()->InstrumentThreadStack(self);
+ }
}
jvmtiError GetResult() const {
@@ -751,6 +756,8 @@
return ERR(ILLEGAL_ARGUMENT);
}
art::Thread* self = art::Thread::Current();
+ // Suspend JIT since it can get confused if we deoptimize methods getting jitted.
+ art::jit::ScopedJitSuspend suspend_jit;
art::ScopedObjectAccess soa(self);
art::MutexLock mu(self, *art::Locks::thread_list_lock_);
art::Thread* target = ThreadUtil::GetNativeThread(thread, soa);
@@ -878,6 +885,8 @@
return ERR(ILLEGAL_ARGUMENT);
}
art::Thread* self = art::Thread::Current();
+ // Suspend JIT since it can get confused if we deoptimize methods getting jitted.
+ art::jit::ScopedJitSuspend suspend_jit;
art::ScopedObjectAccess soa(self);
art::MutexLock mu(self, *art::Locks::thread_list_lock_);
art::Thread* target = ThreadUtil::GetNativeThread(thread, soa);