ClassLinker changes

- Add ClassLinker::LockOwner for SignalCatcher
- ClassLinker::ResolveMethod now sets CodeAndDirectMethod when code is available

Change-Id: I404b80d1994808e018d00e0b30e8ba4f9d08fecc
diff --git a/Android.mk b/Android.mk
index 4ec396b..a1124ce 100644
--- a/Android.mk
+++ b/Android.mk
@@ -209,6 +209,7 @@
 	cp $(call intermediates-dir-for,SHARED_LIBRARIES,libdvm)/LINKED/libdvm.so $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/libdvm.so
 	cp $(call intermediates-dir-for,EXECUTABLES,dexopt)/dexopt $(TARGET_OUT_EXECUTABLES)/dexopt
 	cp $(call intermediates-dir-for,EXECUTABLES,dexopt)/LINKED/dexopt $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/dexopt
+	rm -f $(TARGET_OUT_DATA)/property/persist.sys.strictmode.disabled
 	adb shell rm /data/property/persist.sys.strictmode.disabled
 	adb remount
 	adb sync
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 82f42c4..86f2769 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -2614,6 +2614,9 @@
   }
   if (resolved != NULL) {
     dex_cache->SetResolvedMethod(method_idx, resolved);
+    if (is_direct && resolved->GetCode() != NULL) {
+      dex_cache->GetCodeAndDirectMethods()->SetResolvedDirectMethod(method_idx, resolved);
+    }
   } else {
     ThrowNoSuchMethodError(is_direct ? "direct" : "virtual", klass, name, signature);
   }
@@ -2686,4 +2689,8 @@
   return classes_.size();
 }
 
+pid_t ClassLinker::GetLockOwner() {
+  return lock_.GetOwner();
+}
+
 }  // namespace art
diff --git a/src/class_linker.h b/src/class_linker.h
index 3a44310..21944d1 100644
--- a/src/class_linker.h
+++ b/src/class_linker.h
@@ -229,6 +229,8 @@
   Class* CreateProxyClass(String* name, ObjectArray<Class>* interfaces, ClassLoader* loader,
       ObjectArray<Method>* methods, ObjectArray<ObjectArray<Class> >* throws);
 
+  pid_t GetLockOwner(); // For SignalCatcher.
+
  private:
   explicit ClassLinker(InternTable*);
 
diff --git a/src/heap.cc b/src/heap.cc
index d9db50b..e9900ba 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -584,7 +584,7 @@
   SetIdealFootprint(target_size);
 }
 
-uint32_t Heap::GetLockOwner() {
+pid_t Heap::GetLockOwner() {
   return lock_->GetOwner();
 }
 
diff --git a/src/heap.h b/src/heap.h
index ea4901d..18b521d 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -100,7 +100,7 @@
   // Blocks the caller until the garbage collector becomes idle.
   static void WaitForConcurrentGcToComplete();
 
-  static uint32_t GetLockOwner(); // For SignalCatcher.
+  static pid_t GetLockOwner(); // For SignalCatcher.
   static void Lock();
   static void Unlock();
 
diff --git a/src/monitor.cc b/src/monitor.cc
index d428564..aede4b8 100644
--- a/src/monitor.cc
+++ b/src/monitor.cc
@@ -866,7 +866,7 @@
   }
 }
 
-uint32_t Monitor::GetLockOwner(uint32_t raw_lock_word) {
+uint32_t Monitor::GetThinLockId(uint32_t raw_lock_word) {
   if (LW_SHAPE(raw_lock_word) == LW_SHAPE_THIN) {
     return LW_LOCK_OWNER(raw_lock_word);
   } else {
@@ -891,7 +891,7 @@
     os << "  - waiting to lock ";
     object = thread->monitor_enter_object_;
     if (object != NULL) {
-      lock_owner = object->GetLockOwner();
+      lock_owner = object->GetThinLockId();
     }
   } else {
     // We're not waiting on anything.
diff --git a/src/monitor.h b/src/monitor.h
index 459cb04..829f0fb 100644
--- a/src/monitor.h
+++ b/src/monitor.h
@@ -65,7 +65,7 @@
   static bool IsVerbose();
   static void SetVerbose(bool is_verbose);
 
-  static uint32_t GetLockOwner(uint32_t raw_lock_word);
+  static uint32_t GetThinLockId(uint32_t raw_lock_word);
 
   static void MonitorEnter(Thread* thread, Object* obj);
   static bool MonitorExit(Thread* thread, Object* obj);
diff --git a/src/object.cc b/src/object.cc
index 174388a..d9dfc4f 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -49,8 +49,8 @@
   return copy;
 }
 
-uint32_t Object::GetLockOwner() {
-  return Monitor::GetLockOwner(monitor_);
+uint32_t Object::GetThinLockId() {
+  return Monitor::GetThinLockId(monitor_);
 }
 
 bool Object::IsString() const {
diff --git a/src/object.h b/src/object.h
index c60f580..35acc27 100644
--- a/src/object.h
+++ b/src/object.h
@@ -184,7 +184,7 @@
     return const_cast<volatile int32_t*>(word_addr);
   }
 
-  uint32_t GetLockOwner();
+  uint32_t GetThinLockId();
 
   void MonitorEnter(Thread* thread);
 
diff --git a/src/signal_catcher.cc b/src/signal_catcher.cc
index 06491e4..22d08b5 100644
--- a/src/signal_catcher.cc
+++ b/src/signal_catcher.cc
@@ -22,6 +22,7 @@
 #include <sys/time.h>
 #include <unistd.h>
 
+#include "class_linker.h"
 #include "heap.h"
 #include "runtime.h"
 #include "thread.h"
@@ -64,9 +65,11 @@
 void SignalCatcher::HandleSigQuit() {
   Runtime* runtime = Runtime::Current();
   ThreadList* thread_list = runtime->GetThreadList();
+  ClassLinker* class_linker = runtime->GetClassLinker();
 
-  LOG(INFO) << "Heap lock owner: " << Heap::GetLockOwner() << "\n"
-            << "Thread lock owner: " << thread_list->GetLockOwner() << "\n";
+  LOG(INFO) << "Heap lock owner tid: " << Heap::GetLockOwner() << "\n"
+            << "ThreadList lock owner tid: " << thread_list->GetLockOwner() << "\n"
+            << "ClassLinker lock owner tid: " << class_linker->GetLockOwner() << "\n";
 
   thread_list->SuspendAll();
 
diff --git a/src/thread.cc b/src/thread.cc
index fbea315..95c2995 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -1303,7 +1303,7 @@
   if (object == NULL) {
     return false;
   }
-  return object->GetLockOwner() == thin_lock_id_;
+  return object->GetThinLockId() == thin_lock_id_;
 }
 
 bool Thread::IsDaemon() {
diff --git a/src/thread_list.cc b/src/thread_list.cc
index 77ee31a..84edf46 100644
--- a/src/thread_list.cc
+++ b/src/thread_list.cc
@@ -43,7 +43,7 @@
   return find(list_.begin(), list_.end(), thread) != list_.end();
 }
 
-uint32_t ThreadList::GetLockOwner() {
+pid_t ThreadList::GetLockOwner() {
   return thread_list_lock_.GetOwner();
 }
 
diff --git a/src/thread_list.h b/src/thread_list.h
index f650174..125a559 100644
--- a/src/thread_list.h
+++ b/src/thread_list.h
@@ -32,7 +32,7 @@
   ~ThreadList();
 
   void Dump(std::ostream& os);
-  uint32_t GetLockOwner(); // For SignalCatcher.
+  pid_t GetLockOwner(); // For SignalCatcher.
 
   // Thread suspension support.
   void FullSuspendCheck(Thread* thread);