Add oat file generation and tests to build

- Currently builds boot.oat for host and target
  and target oat files for art tests.
- Added cross compilation support via --strip-prefix option to dex2oat
- Reduced output to prevent build log spam (Compiler::verbose_)
- Added image roots for recovering important pointers on image load
- Redid JNI stub creation and made the stub array an image root
- Fixed JNI stub test by making JNI stub array executable
- Fixed JNI UnregisterNative to having it reinstall the JNI stub
- Fixed ARM JNI stub to generate PIC code (with irogers)
- Fixed JniCompiler to generate PIC code (with irogers)
- Fixed FindNativeMethod to handle recursive calls
- Finished checkFieldType to use Object::InstanceOf
- Fixed thread unsafe access to ClassLinker::{dex_files_,dex_caches_}
- Added ResolvedMethod variant for use with Method* for context
- Fixed ImageWriter to call FixupMethod
- Fixed ImageWriter to rewrite JNI stub references
- Improved error reporting on lack of ANDROID_DATA dir or art-cache dir
- Fixed Runtime::Start to InitLibraries before creating thread peer
- Implemented Space::IsCondemned to skip spaces loaded from images
- Implemented artFindInterfaceMethodInCache,
  allowing interface invocation from managed code

Change-Id: I603e97fa0ac44508ae05a2e47c1cdb4481678d7b
diff --git a/src/object.cc b/src/object.cc
index 373c8c2..24fe628 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -513,6 +513,25 @@
   self->PopNativeToManagedRecord(record);
 }
 
+bool Method::IsRegistered() {
+  void* native_method = GetFieldPtr<void*>(OFFSET_OF_OBJECT_MEMBER(Method, native_method_), false);
+  void* jni_stub = Runtime::Current()->GetJniStubArray()->GetData();
+  return native_method != jni_stub;
+}
+
+void Method::RegisterNative(const void* native_method) {
+  CHECK(IsNative());
+  CHECK(native_method != NULL);
+  SetFieldPtr<const void*>(OFFSET_OF_OBJECT_MEMBER(Method, native_method_),
+                           native_method, false);
+}
+
+void Method::UnregisterNative() {
+  CHECK(IsNative());
+  // restore stub to lookup native pointer via dlsym
+  RegisterNative(Runtime::Current()->GetJniStubArray()->GetData());
+}
+
 void Class::SetStatus(Status new_status) {
   CHECK(new_status > GetStatus() || new_status == kStatusError ||
       !Runtime::Current()->IsStarted());
@@ -790,7 +809,7 @@
       return interface_entry->GetMethodArray()->Get(method->GetMethodIndex());
     }
   }
-  UNIMPLEMENTED(FATAL) << "Need to throw an error of some kind";
+  UNIMPLEMENTED(FATAL) << "Need to throw an error of some kind " << PrettyMethod(method);
   return NULL;
 }