Remove unused code related to method entry / exit events
This Cl:
- Drops this_object and dex_pc arguments for MethodExitEvent
which aren't used in any of the listeners.
- Removes the code to maintain dex_pcs_ which were earlier used
by MethodEnteredEvent but are no longer used.
Test: test/tes.py
Change-Id: I0345598897004b7b6b9f26bd8940c88b5bb798f7
diff --git a/openjdkjvmti/events.cc b/openjdkjvmti/events.cc
index 12aba6a..c69ee7b 100644
--- a/openjdkjvmti/events.cc
+++ b/openjdkjvmti/events.cc
@@ -639,9 +639,7 @@
// TODO Maybe try to combine this with below using templates?
// Callback for when a method is exited with a reference return value.
void MethodExited(art::Thread* self,
- art::Handle<art::mirror::Object> this_object ATTRIBUTE_UNUSED,
art::ArtMethod* method,
- uint32_t dex_pc ATTRIBUTE_UNUSED,
art::instrumentation::OptionalFrame frame,
art::MutableHandle<art::mirror::Object>& return_value)
REQUIRES_SHARED(art::Locks::mutator_lock_) override {
@@ -694,9 +692,7 @@
// Call-back for when a method is exited.
void MethodExited(art::Thread* self,
- art::Handle<art::mirror::Object> this_object ATTRIBUTE_UNUSED,
art::ArtMethod* method,
- uint32_t dex_pc ATTRIBUTE_UNUSED,
art::instrumentation::OptionalFrame frame,
art::JValue& return_value) REQUIRES_SHARED(art::Locks::mutator_lock_) override {
if (frame.has_value() &&
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 28025be..127ea46 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -874,9 +874,7 @@
}
} else if (instr->HasMethodExitListeners()) {
instr->MethodExitEvent(self,
- soa.Decode<mirror::Object>(rcvr_jobj),
proxy_method,
- 0,
{},
result);
}
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 4b4ce45..e664eb1 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -59,9 +59,7 @@
void InstrumentationListener::MethodExited(
Thread* thread,
- Handle<mirror::Object> this_object,
ArtMethod* method,
- uint32_t dex_pc,
OptionalFrame frame,
MutableHandle<mirror::Object>& return_value) {
DCHECK_EQ(method->GetInterfaceMethodIfProxy(kRuntimePointerSize)->GetReturnTypePrimitive(),
@@ -69,7 +67,7 @@
const void* original_ret = return_value.Get();
JValue v;
v.SetL(return_value.Get());
- MethodExited(thread, this_object, method, dex_pc, frame, v);
+ MethodExited(thread, method, frame, v);
DCHECK(original_ret == v.GetL()) << "Return value changed";
}
@@ -307,7 +305,6 @@
instrumentation_stack_(thread_in->GetInstrumentationStack()),
instrumentation_exit_pc_(instrumentation_exit_pc),
reached_existing_instrumentation_frames_(false),
- last_return_pc_(0),
force_deopt_id_(force_deopt_id) {}
bool VisitFrame() override REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -316,7 +313,6 @@
if (kVerboseInstrumentation) {
LOG(INFO) << " Skipping upcall. Frame " << GetFrameId();
}
- last_return_pc_ = 0;
return true; // Ignore upcalls.
}
if (GetCurrentQuickFrame() == nullptr) {
@@ -343,13 +339,6 @@
const InstrumentationStackFrame& frame = it->second;
if (m->IsRuntimeMethod()) {
if (frame.interpreter_entry_) {
- // This instrumentation frame is for an interpreter bridge and is
- // pushed when executing the instrumented interpreter bridge. So method
- // enter event must have been reported. However we need to push a DEX pc
- // into the dex_pcs_ list to match size of instrumentation stack.
- uint32_t dex_pc = dex::kDexNoIndex;
- dex_pcs_.push_back(dex_pc);
- last_return_pc_ = frame.return_pc_;
return true;
}
}
@@ -372,16 +361,10 @@
// inserted by the interpreter or runtime.
std::string thread_name;
GetThread()->GetThreadName(thread_name);
- uint32_t dex_pc = dex::kDexNoIndex;
- if (last_return_pc_ != 0 && GetCurrentOatQuickMethodHeader() != nullptr) {
- dex_pc = GetCurrentOatQuickMethodHeader()->ToDexPc(
- GetCurrentQuickFrame(), last_return_pc_);
- }
LOG(FATAL) << "While walking " << thread_name << " found unexpected non-runtime method"
<< " without instrumentation exit return or interpreter frame."
<< " method is " << GetMethod()->PrettyMethod()
- << " return_pc is " << std::hex << return_pc
- << " dex pc: " << dex_pc;
+ << " return_pc is " << std::hex << return_pc;
UNREACHABLE();
}
if (m->IsRuntimeMethod()) {
@@ -407,20 +390,12 @@
instrumentation_stack_->insert({GetReturnPcAddr(), instrumentation_frame});
SetReturnPc(instrumentation_exit_pc_);
}
- uint32_t dex_pc = dex::kDexNoIndex;
- if (last_return_pc_ != 0 && GetCurrentOatQuickMethodHeader() != nullptr) {
- dex_pc = GetCurrentOatQuickMethodHeader()->ToDexPc(GetCurrentQuickFrame(), last_return_pc_);
- }
- dex_pcs_.push_back(dex_pc);
- last_return_pc_ = return_pc;
return true; // Continue.
}
std::map<uintptr_t, InstrumentationStackFrame>* const instrumentation_stack_;
std::vector<InstrumentationStackFrame> shadow_stack_;
- std::vector<uint32_t> dex_pcs_;
const uintptr_t instrumentation_exit_pc_;
bool reached_existing_instrumentation_frames_;
- uintptr_t last_return_pc_;
uint64_t force_deopt_id_;
};
if (kVerboseInstrumentation) {
@@ -435,7 +410,6 @@
InstallStackVisitor visitor(
thread, context.get(), instrumentation_exit_pc, instrumentation->current_force_deopt_id_);
visitor.WalkStack(true);
- CHECK_EQ(visitor.dex_pcs_.size(), thread->GetInstrumentationStack()->size());
if (instrumentation->ShouldNotifyMethodEnterExitEvents()) {
// Create method enter events for all methods currently on the thread's stack. We only do this
@@ -449,7 +423,6 @@
instrumentation->MethodEnterEvent(thread, (*ssi).method_);
++ssi;
}
- visitor.dex_pcs_.pop_back();
if (!isi->second.interpreter_entry_ && !isi->second.method_->IsRuntimeMethod()) {
instrumentation->MethodEnterEvent(thread, isi->second.method_);
}
@@ -516,8 +489,7 @@
// Create the method exit events. As the methods didn't really exit the result is 0.
// We only do this if no debugger is attached to prevent from posting events twice.
JValue val;
- instrumentation_->MethodExitEvent(thread_, instrumentation_frame.this_object_, m,
- GetDexPc(), OptionalFrame{}, val);
+ instrumentation_->MethodExitEvent(thread_, m, OptionalFrame{}, val);
}
frames_removed_++;
} else {
@@ -1198,43 +1170,35 @@
template <>
void Instrumentation::MethodExitEventImpl(Thread* thread,
- ObjPtr<mirror::Object> this_object,
ArtMethod* method,
- uint32_t dex_pc,
OptionalFrame frame,
MutableHandle<mirror::Object>& return_value) const {
if (HasMethodExitListeners()) {
- Thread* self = Thread::Current();
- StackHandleScope<1> hs(self);
- Handle<mirror::Object> thiz(hs.NewHandle(this_object));
for (InstrumentationListener* listener : method_exit_listeners_) {
if (listener != nullptr) {
- listener->MethodExited(thread, thiz, method, dex_pc, frame, return_value);
+ listener->MethodExited(thread, method, frame, return_value);
}
}
}
}
template<> void Instrumentation::MethodExitEventImpl(Thread* thread,
- ObjPtr<mirror::Object> this_object,
ArtMethod* method,
- uint32_t dex_pc,
OptionalFrame frame,
JValue& return_value) const {
if (HasMethodExitListeners()) {
Thread* self = Thread::Current();
- StackHandleScope<2> hs(self);
- Handle<mirror::Object> thiz(hs.NewHandle(this_object));
+ StackHandleScope<1> hs(self);
if (method->GetInterfaceMethodIfProxy(kRuntimePointerSize)->GetReturnTypePrimitive() !=
Primitive::kPrimNot) {
for (InstrumentationListener* listener : method_exit_listeners_) {
if (listener != nullptr) {
- listener->MethodExited(thread, thiz, method, dex_pc, frame, return_value);
+ listener->MethodExited(thread, method, frame, return_value);
}
}
} else {
MutableHandle<mirror::Object> ret(hs.NewHandle(return_value.GetL()));
- MethodExitEventImpl(thread, thiz.Get(), method, dex_pc, frame, ret);
+ MethodExitEventImpl(thread, method, frame, ret);
return_value.SetL(ret.Get());
}
}
@@ -1531,14 +1495,9 @@
// DCHECK_ALIGNED(return_value.GetL(), kObjectAlignment);
res.Assign(return_value.GetL());
}
- // TODO: improve the dex pc information here, requires knowledge of current PC as opposed to
- // return_pc.
- uint32_t dex_pc = dex::kDexNoIndex;
if (!method->IsRuntimeMethod() && !instrumentation_frame.interpreter_entry_) {
- ObjPtr<mirror::Object> this_object = instrumentation_frame.this_object_;
// Note that sending the event may change the contents of *return_pc_addr.
- MethodExitEvent(
- self, this_object, instrumentation_frame.method_, dex_pc, OptionalFrame{}, return_value);
+ MethodExitEvent(self, instrumentation_frame.method_, OptionalFrame{}, return_value);
}
// Deoptimize if the caller needs to continue execution in the interpreter. Do nothing if we get
diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h
index bdeaf30..988627c 100644
--- a/runtime/instrumentation.h
+++ b/runtime/instrumentation.h
@@ -79,9 +79,7 @@
REQUIRES_SHARED(Locks::mutator_lock_) = 0;
virtual void MethodExited(Thread* thread,
- Handle<mirror::Object> this_object,
ArtMethod* method,
- uint32_t dex_pc,
OptionalFrame frame,
MutableHandle<mirror::Object>& return_value)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -90,9 +88,7 @@
// value (if appropriate) or use the alternate MethodExited callback instead if they need to
// go through a suspend point.
virtual void MethodExited(Thread* thread,
- Handle<mirror::Object> this_object,
ArtMethod* method,
- uint32_t dex_pc,
OptionalFrame frame,
JValue& return_value)
REQUIRES_SHARED(Locks::mutator_lock_) = 0;
@@ -406,14 +402,12 @@
// Inform listeners that a method has been exited.
template<typename T>
void MethodExitEvent(Thread* thread,
- ObjPtr<mirror::Object> this_object,
ArtMethod* method,
- uint32_t dex_pc,
OptionalFrame frame,
T& return_value) const
REQUIRES_SHARED(Locks::mutator_lock_) {
if (UNLIKELY(HasMethodExitListeners())) {
- MethodExitEventImpl(thread, this_object, method, dex_pc, frame, return_value);
+ MethodExitEventImpl(thread, method, frame, return_value);
}
}
@@ -596,9 +590,7 @@
REQUIRES_SHARED(Locks::mutator_lock_);
template <typename T>
void MethodExitEventImpl(Thread* thread,
- ObjPtr<mirror::Object> this_object,
ArtMethod* method,
- uint32_t dex_pc,
OptionalFrame frame,
T& return_value) const
REQUIRES_SHARED(Locks::mutator_lock_);
diff --git a/runtime/instrumentation_test.cc b/runtime/instrumentation_test.cc
index 4584d25..d35847e 100644
--- a/runtime/instrumentation_test.cc
+++ b/runtime/instrumentation_test.cc
@@ -61,9 +61,7 @@
}
void MethodExited(Thread* thread ATTRIBUTE_UNUSED,
- Handle<mirror::Object> this_object ATTRIBUTE_UNUSED,
ArtMethod* method ATTRIBUTE_UNUSED,
- uint32_t dex_pc ATTRIBUTE_UNUSED,
instrumentation::OptionalFrame frame ATTRIBUTE_UNUSED,
MutableHandle<mirror::Object>& return_value ATTRIBUTE_UNUSED)
override REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -71,9 +69,7 @@
}
void MethodExited(Thread* thread ATTRIBUTE_UNUSED,
- Handle<mirror::Object> this_object ATTRIBUTE_UNUSED,
ArtMethod* method ATTRIBUTE_UNUSED,
- uint32_t dex_pc ATTRIBUTE_UNUSED,
instrumentation::OptionalFrame frame ATTRIBUTE_UNUSED,
JValue& return_value ATTRIBUTE_UNUSED)
override REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -393,7 +389,7 @@
break;
case instrumentation::Instrumentation::kMethodExited: {
JValue value;
- instr->MethodExitEvent(self, obj, method, dex_pc, {}, value);
+ instr->MethodExitEvent(self, method, {}, value);
break;
}
case instrumentation::Instrumentation::kMethodUnwind:
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index edb3d3b..299892e 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -281,12 +281,7 @@
DCHECK(Runtime::Current()->AreNonStandardExitsEnabled());
JValue ret = JValue();
PerformNonStandardReturn<MonitorState::kNoMonitorsLocked>(
- self,
- shadow_frame,
- ret,
- instrumentation,
- accessor.InsSize(),
- 0);
+ self, shadow_frame, ret, instrumentation, accessor.InsSize());
return ret;
}
if (UNLIKELY(self->IsExceptionPending())) {
@@ -298,12 +293,7 @@
if (UNLIKELY(shadow_frame.GetForcePopFrame())) {
DCHECK(Runtime::Current()->AreNonStandardExitsEnabled());
PerformNonStandardReturn<MonitorState::kNoMonitorsLocked>(
- self,
- shadow_frame,
- ret,
- instrumentation,
- accessor.InsSize(),
- 0);
+ self, shadow_frame, ret, instrumentation, accessor.InsSize());
}
return ret;
}
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index 4e88eda..da8915e 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -92,21 +92,16 @@
bool SendMethodExitEvents(Thread* self,
const instrumentation::Instrumentation* instrumentation,
ShadowFrame& frame,
- ObjPtr<mirror::Object> thiz,
ArtMethod* method,
- uint32_t dex_pc,
T& result) {
bool had_event = false;
// We can get additional ForcePopFrame requests during handling of these events. We should
// respect these and send additional instrumentation events.
- StackHandleScope<1> hs(self);
- Handle<mirror::Object> h_thiz(hs.NewHandle(thiz));
do {
frame.SetForcePopFrame(false);
if (UNLIKELY(instrumentation->HasMethodExitListeners() && !frame.GetSkipMethodExitEvents())) {
had_event = true;
- instrumentation->MethodExitEvent(
- self, h_thiz.Get(), method, dex_pc, instrumentation::OptionalFrame{ frame }, result);
+ instrumentation->MethodExitEvent(self, method, instrumentation::OptionalFrame{frame}, result);
}
// We don't send method-exit if it's a pop-frame. We still send frame_popped though.
if (UNLIKELY(frame.NeedsNotifyPop() && instrumentation->HasWatchedFramePopListeners())) {
@@ -125,18 +120,14 @@
bool SendMethodExitEvents(Thread* self,
const instrumentation::Instrumentation* instrumentation,
ShadowFrame& frame,
- ObjPtr<mirror::Object> thiz,
ArtMethod* method,
- uint32_t dex_pc,
MutableHandle<mirror::Object>& result);
template
bool SendMethodExitEvents(Thread* self,
const instrumentation::Instrumentation* instrumentation,
ShadowFrame& frame,
- ObjPtr<mirror::Object> thiz,
ArtMethod* method,
- uint32_t dex_pc,
JValue& result);
// We execute any instrumentation events that are triggered by this exception and change the
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index 2619573..327594b 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -141,9 +141,7 @@
Thread* self,
const instrumentation::Instrumentation* instrumentation,
ShadowFrame& frame,
- ObjPtr<mirror::Object> thiz,
ArtMethod* method,
- uint32_t dex_pc,
T& result) REQUIRES_SHARED(Locks::mutator_lock_);
static inline ALWAYS_INLINE WARN_UNUSED bool
@@ -198,12 +196,10 @@
ShadowFrame& frame,
JValue& result,
const instrumentation::Instrumentation* instrumentation,
- uint16_t num_dex_inst,
- uint32_t dex_pc) REQUIRES_SHARED(Locks::mutator_lock_) {
+ uint16_t num_dex_inst) REQUIRES_SHARED(Locks::mutator_lock_) {
static constexpr bool kMonitorCounting = (kMonitorState == MonitorState::kCountingMonitors);
ObjPtr<mirror::Object> thiz(frame.GetThisObject(num_dex_inst));
StackHandleScope<1u> hs(self);
- Handle<mirror::Object> h_thiz(hs.NewHandle(thiz));
if (UNLIKELY(self->IsExceptionPending())) {
LOG(WARNING) << "Suppressing exception for non-standard method exit: "
<< self->GetException()->Dump();
@@ -215,8 +211,7 @@
DoMonitorCheckOnExit<kMonitorCounting>(self, &frame);
result = JValue();
if (UNLIKELY(NeedsMethodExitEvent(instrumentation))) {
- SendMethodExitEvents(
- self, instrumentation, frame, h_thiz.Get(), frame.GetMethod(), dex_pc, result);
+ SendMethodExitEvents(self, instrumentation, frame, frame.GetMethod(), result);
}
}
diff --git a/runtime/interpreter/interpreter_switch_impl-inl.h b/runtime/interpreter/interpreter_switch_impl-inl.h
index 8e16e04..42f7fc7 100644
--- a/runtime/interpreter/interpreter_switch_impl-inl.h
+++ b/runtime/interpreter/interpreter_switch_impl-inl.h
@@ -64,12 +64,8 @@
DCHECK(abort_exception != nullptr);
DCHECK(abort_exception->GetClass()->DescriptorEquals(Transaction::kAbortExceptionDescriptor));
Self()->ClearException();
- PerformNonStandardReturn<kMonitorState>(Self(),
- shadow_frame_,
- ctx_->result,
- Instrumentation(),
- Accessor().InsSize(),
- inst_->GetDexPc(Insns()));
+ PerformNonStandardReturn<kMonitorState>(
+ Self(), shadow_frame_, ctx_->result, Instrumentation(), Accessor().InsSize());
Self()->SetException(abort_exception.Get());
ExitInterpreterLoop();
return false;
@@ -80,12 +76,8 @@
HANDLER_ATTRIBUTES bool CheckForceReturn() {
if (shadow_frame_.GetForcePopFrame()) {
DCHECK(Runtime::Current()->AreNonStandardExitsEnabled());
- PerformNonStandardReturn<kMonitorState>(Self(),
- shadow_frame_,
- ctx_->result,
- Instrumentation(),
- Accessor().InsSize(),
- inst_->GetDexPc(Insns()));
+ PerformNonStandardReturn<kMonitorState>(
+ Self(), shadow_frame_, ctx_->result, Instrumentation(), Accessor().InsSize());
ExitInterpreterLoop();
return false;
}
@@ -216,9 +208,7 @@
!SendMethodExitEvents(Self(),
Instrumentation(),
shadow_frame_,
- shadow_frame_.GetThisObject(Accessor().InsSize()),
shadow_frame_.GetMethod(),
- inst_->GetDexPc(Insns()),
result))) {
DCHECK(Self()->IsExceptionPending());
// Do not raise exception event if it is caused by other instrumentation event.
@@ -495,9 +485,7 @@
!SendMethodExitEvents(Self(),
Instrumentation(),
shadow_frame_,
- shadow_frame_.GetThisObject(Accessor().InsSize()),
shadow_frame_.GetMethod(),
- inst_->GetDexPc(Insns()),
h_result))) {
DCHECK(Self()->IsExceptionPending());
// Do not raise exception event if it is caused by other instrumentation event.
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 5996a57..ca0fe10 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -741,9 +741,7 @@
}
void Trace::MethodExited(Thread* thread,
- Handle<mirror::Object> this_object ATTRIBUTE_UNUSED,
ArtMethod* method,
- uint32_t dex_pc ATTRIBUTE_UNUSED,
instrumentation::OptionalFrame frame ATTRIBUTE_UNUSED,
JValue& return_value ATTRIBUTE_UNUSED) {
uint32_t thread_clock_diff = 0;
diff --git a/runtime/trace.h b/runtime/trace.h
index 170f0b0..c6f36e4 100644
--- a/runtime/trace.h
+++ b/runtime/trace.h
@@ -178,9 +178,7 @@
void MethodEntered(Thread* thread, ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!unique_methods_lock_, !streaming_lock_) override;
void MethodExited(Thread* thread,
- Handle<mirror::Object> this_object,
ArtMethod* method,
- uint32_t dex_pc,
instrumentation::OptionalFrame frame,
JValue& return_value)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!unique_methods_lock_, !streaming_lock_)
diff --git a/tools/tracefast-plugin/tracefast.cc b/tools/tracefast-plugin/tracefast.cc
index c2516c7..618742d 100644
--- a/tools/tracefast-plugin/tracefast.cc
+++ b/tools/tracefast-plugin/tracefast.cc
@@ -48,17 +48,13 @@
REQUIRES_SHARED(art::Locks::mutator_lock_) {}
void MethodExited(art::Thread* thread ATTRIBUTE_UNUSED,
- art::Handle<art::mirror::Object> this_object ATTRIBUTE_UNUSED,
art::ArtMethod* method ATTRIBUTE_UNUSED,
- uint32_t dex_pc ATTRIBUTE_UNUSED,
art::instrumentation::OptionalFrame frame ATTRIBUTE_UNUSED,
art::MutableHandle<art::mirror::Object>& return_value ATTRIBUTE_UNUSED)
override REQUIRES_SHARED(art::Locks::mutator_lock_) { }
void MethodExited(art::Thread* thread ATTRIBUTE_UNUSED,
- art::Handle<art::mirror::Object> this_object ATTRIBUTE_UNUSED,
art::ArtMethod* method ATTRIBUTE_UNUSED,
- uint32_t dex_pc ATTRIBUTE_UNUSED,
art::instrumentation::OptionalFrame frame ATTRIBUTE_UNUSED,
art::JValue& return_value ATTRIBUTE_UNUSED)
override REQUIRES_SHARED(art::Locks::mutator_lock_) { }