Merge "Fix GetCurrentMethod to cope with callee-save frames." into dalvik-dev
diff --git a/src/thread.cc b/src/thread.cc
index e143af5..79dbf81 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -1245,6 +1245,20 @@
return result;
}
+const Method* Thread::GetCurrentMethod() const {
+ Method* m = top_of_managed_stack_.GetMethod();
+ // We use JNI internally for exception throwing, so it's possible to arrive
+ // here via a "FromCode" function, in which case there's a synthetic
+ // callee-save method at the top of the stack. These shouldn't be user-visible,
+ // so if we find one, skip it and return the compiled method underneath.
+ if (m->IsCalleeSaveMethod()) {
+ Frame f = top_of_managed_stack_;
+ f.Next();
+ m = f.GetMethod();
+ }
+ return m;
+}
+
bool Thread::HoldsLock(Object* object) {
if (object == NULL) {
return false;
diff --git a/src/thread.h b/src/thread.h
index 8fd0985..74e6f83 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -233,9 +233,7 @@
// Returns the Method* for the current method.
// This is used by the JNI implementation for logging and diagnostic purposes.
- const Method* GetCurrentMethod() const {
- return top_of_managed_stack_.GetMethod();
- }
+ const Method* GetCurrentMethod() const;
bool IsExceptionPending() const {
return exception_ != NULL;