Revert "Add JIT"

Sorry, run-test crashes on target:
0-05 12:15:51.633 I/DEBUG   (27995): Abort message: 'art/runtime/mirror/art_method.cc:349] Check failed: PcIsWithinQuickCode(reinterpret_cast<uintptr_t>(code), pc) java.lang.Throwable java.lang.Throwable.fillInStackTrace() pc=71e3366b code=0x71e3362d size=ad000000'
10-05 12:15:51.633 I/DEBUG   (27995):     r0 00000000  r1 0000542b  r2 00000006  r3 00000000
10-05 12:15:51.633 I/DEBUG   (27995):     r4 00000006  r5 b6f9addc  r6 00000002  r7 0000010c
10-05 12:15:51.633 I/DEBUG   (27995):     r8 b63fe1e8  r9 be8e1418  sl b6427400  fp b63fcce0
10-05 12:15:51.633 I/DEBUG   (27995):     ip 0000542b  sp be8e1358  lr b6e9a27b  pc b6e9c280  cpsr 40070010
10-05 12:15:51.633 I/DEBUG   (27995): 

Bug: 17950037
This reverts commit 2535abe7d1fcdd0e6aca782b1f1932a703ed50a4.

Change-Id: I6f88849bc6f2befed0c0aaa0b7b2a08c967a83c3
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 749418d..f38f65e 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -65,8 +65,6 @@
 #include "image.h"
 #include "instrumentation.h"
 #include "intern_table.h"
-#include "interpreter/interpreter.h"
-#include "jit/jit.h"
 #include "jni_internal.h"
 #include "mirror/array.h"
 #include "mirror/art_field-inl.h"
@@ -227,12 +225,6 @@
   // Make sure to let the GC complete if it is running.
   heap_->WaitForGcToComplete(gc::kGcCauseBackground, self);
   heap_->DeleteThreadPool();
-  if (jit_.get() != nullptr) {
-    VLOG(jit) << "Deleting jit thread pool";
-    // Delete thread pool before the thread list since we don't want to wait forever on the
-    // JIT compiler threads.
-    jit_->DeleteThreadPool();
-  }
 
   // Make sure our internal threads are dead before we start tearing down things they're using.
   Dbg::StopJdwp();
@@ -241,13 +233,6 @@
   // Make sure all other non-daemon threads have terminated, and all daemon threads are suspended.
   delete thread_list_;
 
-  // Delete the JIT after thread list to ensure that there is no remaining threads which could be
-  // accessing the instrumentation when we delete it.
-  if (jit_.get() != nullptr) {
-    VLOG(jit) << "Deleting jit";
-    jit_.reset(nullptr);
-  }
-
   // Shutdown the fault manager if it was initialized.
   fault_manager.Shutdown();
 
@@ -470,24 +455,17 @@
 
   started_ = true;
 
-  // Use !IsAotCompiler so that we get test coverage, tests are never the zygote.
-  if (!IsAotCompiler()) {
+  // Use !IsCompiler so that we get test coverage, tests are never the zygote.
+  if (!IsCompiler()) {
     ScopedObjectAccess soa(self);
     gc::space::ImageSpace* image_space = heap_->GetImageSpace();
     if (image_space != nullptr) {
-      GetInternTable()->AddImageStringsToTable(image_space);
-      GetClassLinker()->MoveImageClassesToClassTable();
+      Runtime::Current()->GetInternTable()->AddImageStringsToTable(image_space);
+      Runtime::Current()->GetClassLinker()->MoveImageClassesToClassTable();
     }
   }
 
-  // If we are the zygote then we need to wait until after forking to create the code cache due to
-  // SELinux restrictions on r/w/x memory regions.
-  if (!IsZygote() && jit_.get() != nullptr) {
-    jit_->CreateInstrumentationCache(jit_options_->GetCompileThreshold());
-    jit_->CreateThreadPool();
-  }
-
-  if (!IsImageDex2OatEnabled() || !GetHeap()->HasImageSpace()) {
+  if (!IsImageDex2OatEnabled() || !Runtime::Current()->GetHeap()->HasImageSpace()) {
     ScopedObjectAccess soa(self);
     StackHandleScope<1> hs(soa.Self());
     auto klass(hs.NewHandle<mirror::Class>(mirror::Class::GetJavaLangClass()));
@@ -606,14 +584,8 @@
     }
   }
 
-  // Create the thread pools.
+  // Create the thread pool.
   heap_->CreateThreadPool();
-  if (jit_options_.get() != nullptr && jit_.get() == nullptr) {
-    // Create the JIT if the flag is set and we haven't already create it (happens for run-tests).
-    CreateJit();
-    jit_->CreateInstrumentationCache(jit_options_->GetCompileThreshold());
-    jit_->CreateThreadPool();
-  }
 
   StartSignalCatcher();
 
@@ -834,17 +806,6 @@
     Dbg::ConfigureJdwp(runtime_options.GetOrDefault(Opt::JdwpOptions));
   }
 
-  if (!IsCompiler()) {
-    // If we are already the compiler at this point, we must be dex2oat. Don't create the jit in
-    // this case.
-    // If runtime_options doesn't have UseJIT set to true then CreateFromRuntimeArguments returns
-    // nullptr and we don't create the jit.
-    jit_options_.reset(jit::JitOptions::CreateFromRuntimeArguments(runtime_options));
-  }
-  if (!IsZygote() && jit_options_.get() != nullptr) {
-    CreateJit();
-  }
-
   BlockSignals();
   InitPlatformSignalHandlers();
 
@@ -1093,26 +1054,26 @@
       env->NewGlobalRef(env->GetStaticObjectField(
           WellKnownClasses::java_lang_ThreadGroup,
           WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup));
-  CHECK(main_thread_group_ != NULL || IsAotCompiler());
+  CHECK(main_thread_group_ != NULL || IsCompiler());
   system_thread_group_ =
       env->NewGlobalRef(env->GetStaticObjectField(
           WellKnownClasses::java_lang_ThreadGroup,
           WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup));
-  CHECK(system_thread_group_ != NULL || IsAotCompiler());
+  CHECK(system_thread_group_ != NULL || IsCompiler());
 }
 
 jobject Runtime::GetMainThreadGroup() const {
-  CHECK(main_thread_group_ != NULL || IsAotCompiler());
+  CHECK(main_thread_group_ != NULL || IsCompiler());
   return main_thread_group_;
 }
 
 jobject Runtime::GetSystemThreadGroup() const {
-  CHECK(system_thread_group_ != NULL || IsAotCompiler());
+  CHECK(system_thread_group_ != NULL || IsCompiler());
   return system_thread_group_;
 }
 
 jobject Runtime::GetSystemClassLoader() const {
-  CHECK(system_class_loader_ != NULL || IsAotCompiler());
+  CHECK(system_class_loader_ != NULL || IsCompiler());
   return system_class_loader_;
 }
 
@@ -1368,7 +1329,7 @@
   // TODO: use a special method for imt conflict method saves.
   method->SetDexMethodIndex(DexFile::kDexNoIndex);
   // When compiling, the code pointer will get set later when the image is loaded.
-  if (runtime->IsAotCompiler()) {
+  if (runtime->IsCompiler()) {
     size_t pointer_size = GetInstructionSetPointerSize(instruction_set_);
     method->SetEntryPointFromQuickCompiledCodePtrSize(nullptr, pointer_size);
   } else {
@@ -1377,10 +1338,6 @@
   return method.Get();
 }
 
-void Runtime::SetImtConflictMethod(mirror::ArtMethod* method) {
-  imt_conflict_method_ = GcRoot<mirror::ArtMethod>(method);
-}
-
 mirror::ArtMethod* Runtime::CreateResolutionMethod() {
   Thread* self = Thread::Current();
   Runtime* runtime = Runtime::Current();
@@ -1391,7 +1348,7 @@
   // TODO: use a special method for resolution method saves
   method->SetDexMethodIndex(DexFile::kDexNoIndex);
   // When compiling, the code pointer will get set later when the image is loaded.
-  if (runtime->IsAotCompiler()) {
+  if (runtime->IsCompiler()) {
     size_t pointer_size = GetInstructionSetPointerSize(instruction_set_);
     method->SetEntryPointFromQuickCompiledCodePtrSize(nullptr, pointer_size);
   } else {
@@ -1522,14 +1479,14 @@
 
 // Transaction support.
 void Runtime::EnterTransactionMode(Transaction* transaction) {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(transaction != nullptr);
   DCHECK(!IsActiveTransaction());
   preinitialization_transaction_ = transaction;
 }
 
 void Runtime::ExitTransactionMode() {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(IsActiveTransaction());
   preinitialization_transaction_ = nullptr;
 }
@@ -1589,51 +1546,51 @@
 
 void Runtime::RecordWriteField32(mirror::Object* obj, MemberOffset field_offset,
                                  uint32_t value, bool is_volatile) const {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(IsActiveTransaction());
   preinitialization_transaction_->RecordWriteField32(obj, field_offset, value, is_volatile);
 }
 
 void Runtime::RecordWriteField64(mirror::Object* obj, MemberOffset field_offset,
                                  uint64_t value, bool is_volatile) const {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(IsActiveTransaction());
   preinitialization_transaction_->RecordWriteField64(obj, field_offset, value, is_volatile);
 }
 
 void Runtime::RecordWriteFieldReference(mirror::Object* obj, MemberOffset field_offset,
                                         mirror::Object* value, bool is_volatile) const {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(IsActiveTransaction());
   preinitialization_transaction_->RecordWriteFieldReference(obj, field_offset, value, is_volatile);
 }
 
 void Runtime::RecordWriteArray(mirror::Array* array, size_t index, uint64_t value) const {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(IsActiveTransaction());
   preinitialization_transaction_->RecordWriteArray(array, index, value);
 }
 
 void Runtime::RecordStrongStringInsertion(mirror::String* s) const {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(IsActiveTransaction());
   preinitialization_transaction_->RecordStrongStringInsertion(s);
 }
 
 void Runtime::RecordWeakStringInsertion(mirror::String* s) const {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(IsActiveTransaction());
   preinitialization_transaction_->RecordWeakStringInsertion(s);
 }
 
 void Runtime::RecordStrongStringRemoval(mirror::String* s) const {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(IsActiveTransaction());
   preinitialization_transaction_->RecordStrongStringRemoval(s);
 }
 
 void Runtime::RecordWeakStringRemoval(mirror::String* s) const {
-  DCHECK(IsAotCompiler());
+  DCHECK(IsCompiler());
   DCHECK(IsActiveTransaction());
   preinitialization_transaction_->RecordWeakStringRemoval(s);
 }
@@ -1665,16 +1622,4 @@
 void Runtime::UpdateProfilerState(int state) {
   VLOG(profiler) << "Profiler state updated to " << state;
 }
-
-void Runtime::CreateJit() {
-  CHECK(jit_options_.get() != nullptr);
-  std::string error_msg;
-  jit_.reset(jit::Jit::Create(jit_options_.get(), &error_msg));
-  if (jit_.get() != nullptr) {
-    compiler_callbacks_ = jit_->GetCompilerCallbacks();
-  } else {
-    LOG(WARNING) << "Failed to create JIT " << error_msg;
-  }
-}
-
 }  // namespace art