Changed monitor to contain method and return pc values for logging.
The monitor saves method and return pc for logging, instead of the
source filename and line number. This saves it from having to do a
lookup every time a fat lock is acquired.
Change-Id: I88871abc90626b9e4dffc9677c093fd24937385c
diff --git a/src/thread.cc b/src/thread.cc
index 2bdfb3c..5dd0f2d 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -1191,35 +1191,6 @@
return result;
}
-void Thread::GetCurrentLocation(const char*& source_file, uint32_t& line_number) const {
- Frame f = top_of_managed_stack_;
- Method* m = f.GetMethod();
-
- // Check if the stack is empty
- if (m == NULL) {
- source_file = "UNKNOWN";
- line_number = 0;
- return;
- }
-
- // TODO: can this ever happen?
- if (m->IsCalleeSaveMethod()) {
- f.Next();
- m = f.GetMethod();
- }
-
- ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
- Class* c = m->GetDeclaringClass();
- DexCache* dex_cache = c->GetDexCache();
- const DexFile& dex_file = class_linker->FindDexFile(dex_cache);
- const DexFile::ClassDef* class_def = dex_file.FindClassDef(c->GetDescriptor()->ToModifiedUtf8());
-
- source_file = dex_file.dexGetSourceFile(*class_def);
-
- uint32_t pc = ManglePc(f.GetReturnPC());
- line_number = dex_file.GetLineNumFromPC(m, m->ToDexPC(pc));
-}
-
void Thread::ThrowNewExceptionF(const char* exception_class_descriptor, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
@@ -1399,7 +1370,7 @@
// 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()) {
+ if (m != NULL && m->IsCalleeSaveMethod()) {
Frame f = top_of_managed_stack_;
f.Next();
m = f.GetMethod();
@@ -1407,6 +1378,13 @@
return m;
}
+uint32_t Thread::GetCurrentReturnPc() const {
+ if (top_of_managed_stack_.GetMethod() == NULL) {
+ return 0;
+ }
+ return ManglePc(top_of_managed_stack_.GetReturnPC());
+}
+
bool Thread::HoldsLock(Object* object) {
if (object == NULL) {
return false;