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/class_linker.h b/src/class_linker.h
index 88871f4..e143fd8 100644
--- a/src/class_linker.h
+++ b/src/class_linker.h
@@ -104,6 +104,15 @@
                         const ClassLoader* class_loader,
                         bool is_direct);
 
+  Method* ResolveMethod(uint32_t method_idx, const Method* referrer, bool is_direct) {
+    Class* declaring_class = referrer->GetDeclaringClass();
+    DexCache* dex_cache = declaring_class->GetDexCache();
+    // TODO: we could check for a dex cache hit here
+    const ClassLoader* class_loader = declaring_class->GetClassLoader();
+    const DexFile& dex_file = FindDexFile(dex_cache);
+    return ResolveMethod(dex_file, method_idx, dex_cache, class_loader, is_direct);
+  }
+
   Field* ResolveField(uint32_t field_idx, const Method* referrer) {
     Class* declaring_class = referrer->GetDeclaringClass();
     DexCache* dex_cache = declaring_class->GetDexCache();
@@ -113,7 +122,7 @@
     return ResolveField(dex_file, field_idx, dex_cache, class_loader, true);
   }
 
-  // Resolve a method with a given ID from the DexFile, storing the
+  // Resolve a field with a given ID from the DexFile, storing the
   // result in DexCache. The ClassLinker and ClassLoader are used as
   // in ResolveType. What is unique is the is_static argument which is
   // used to determine if we are resolving a static or non-static
@@ -252,16 +261,17 @@
   void CreateReferenceOffsets(Class *klass, bool instance,
                               uint32_t reference_offsets);
 
+  // lock to protect ClassLinker state
+  mutable Mutex lock_;
+
   std::vector<const DexFile*> boot_class_path_;
 
   std::vector<const DexFile*> dex_files_;
-
   std::vector<DexCache*> dex_caches_;
 
   // multimap from a StringPiece hash code of a class descriptor to
   // Class* instances. Results should be compared for a matching
   // Class::descriptor_ and Class::class_loader_.
-  mutable Mutex classes_lock_;
   typedef std::tr1::unordered_multimap<size_t, Class*> Table;
   Table classes_;