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/compiler/Compiler.h b/src/compiler/Compiler.h
index c1eadcc..ba97aac 100644
--- a/src/compiler/Compiler.h
+++ b/src/compiler/Compiler.h
@@ -61,12 +61,12 @@
 struct GrowableList;
 struct MIR;
 
-void oatInit(void);
+void oatInit(const Compiler& compiler);
 bool oatArchInit(void);
 void oatArchDump(void);
 bool oatStartup(void);
 void oatShutdown(void);
-bool oatCompileMethod(Method* method, OatInstructionSetType);
+bool oatCompileMethod(const Compiler& compiler, Method* method, OatInstructionSetType);
 void oatDumpStats(void);
 void oatScanAllClassPointers(void (*callback)(void* ptr));
 void oatInitializeSSAConversion(struct CompilationUnit* cUnit);
diff --git a/src/compiler/Dalvik.h b/src/compiler/Dalvik.h
index a9ddcd8..f4f94e2 100644
--- a/src/compiler/Dalvik.h
+++ b/src/compiler/Dalvik.h
@@ -28,6 +28,7 @@
 #include "object.h"
 #include "thread.h"
 #include "class_linker.h"
+#include "compiler.h"
 #include "dex_cache.h"
 #include "utils.h"
 
@@ -51,14 +52,15 @@
 #include "DexOpcodes.h"
 #include "InstrUtils.h"
 
-typedef art::JValue JValue;
-typedef art::Thread Thread;
-typedef art::Class Class;
 typedef art::Array Array;
+typedef art::Class Class;
+typedef art::Compiler Compiler;
+typedef art::Field Field;
+typedef art::JValue JValue;
 typedef art::Method Method;
 typedef art::Object Object;
-typedef art::Field Field;
 typedef art::String String;
+typedef art::Thread Thread;
 
 // From alloc/CardTable.h
 #define GC_CARD_SHIFT 7
diff --git a/src/compiler/Frontend.cc b/src/compiler/Frontend.cc
index 086c0bb..9e6617e 100644
--- a/src/compiler/Frontend.cc
+++ b/src/compiler/Frontend.cc
@@ -669,9 +669,11 @@
 /*
  * Compile a method.
  */
-bool oatCompileMethod(Method* method, art::InstructionSet insnSet)
+bool oatCompileMethod(const Compiler& compiler, Method* method, art::InstructionSet insnSet)
 {
-    LOG(INFO) << "Compiling " << PrettyMethod(method) << "...";
+    if (compiler.IsVerbose()) {
+        LOG(INFO) << "Compiling " << PrettyMethod(method) << "...";
+    }
     oatArenaReset();
 
     CompilationUnit cUnit;
@@ -687,7 +689,7 @@
 
 #if 1
     // FIXME - temp 'till properly integrated
-    oatInit();
+    oatInit(compiler);
 #endif
 
     memset(&cUnit, 0, sizeof(cUnit));
@@ -697,8 +699,8 @@
     cUnit.insnsSize = code_item->insns_size_;
 #if 1
     // TODO: Use command-line argument passing mechanism
-    cUnit.printMe = false;
-    cUnit.printMeVerbose = false;
+    cUnit.printMe = compiler.IsVerbose();
+    cUnit.printMeVerbose = compiler.IsVerbose();
     cUnit.disableOpt = 0 |
          (1 << kLoadStoreElimination) |
          (1 << kLoadHoisting) |
@@ -889,9 +891,11 @@
     method->SetFrameSizeInBytes(cUnit.frameSize);
     method->SetCoreSpillMask(cUnit.coreSpillMask);
     method->SetFpSpillMask(cUnit.fpSpillMask);
-    LOG(INFO) << "Compiled " << PrettyMethod(method)
-              << " code at " << reinterpret_cast<void*>(managed_code->GetData())
-              << " (" << managed_code->GetLength() << " bytes)";
+    if (compiler.IsVerbose()) {
+        LOG(INFO) << "Compiled " << PrettyMethod(method)
+                  << " code at " << reinterpret_cast<void*>(managed_code->GetData())
+                  << " (" << managed_code->GetLength() << " bytes)";
+    }
 #if 0
     oatDumpCFG(&cUnit, "/sdcard/cfg/");
 #endif
@@ -899,7 +903,7 @@
     return true;
 }
 
-void oatInit(void)
+void oatInit(const Compiler& compiler)
 {
 #if 1
     // FIXME - temp hack 'till properly integrated
@@ -907,7 +911,9 @@
     if (initialized)
         return;
     initialized = true;
-    LOG(INFO) << "Initializing compiler";
+    if (compiler.IsVerbose()) {
+        LOG(INFO) << "Initializing compiler";
+    }
 #endif
     if (!oatArchInit()) {
         LOG(FATAL) << "Failed to initialize oat";
diff --git a/src/compiler/Utility.cc b/src/compiler/Utility.cc
index 6254b3d..fbdf62c 100644
--- a/src/compiler/Utility.cc
+++ b/src/compiler/Utility.cc
@@ -78,7 +78,7 @@
         currentArena->next = newArena;
         currentArena = newArena;
         numArenaBlocks++;
-        if (numArenaBlocks > 10) {
+        if (numArenaBlocks > 1000) {
             LOG(INFO) << "Total arena pages: " << numArenaBlocks;
         }
         goto retry;