Make it possible to enable native debugging through debug flags

* Add support for a new debug flag disabling the optimizations in
  the compiler and enable the generation of some additional debug
  info (--native-debuggable).
* Ignore the content of the oat files if force JIT is enabled so
  the runtime ignores the AOT-ed code what doesn't contain any
  debug info.

Time measurements on a Nexus 5 with running:
am start -n com.facebook.katana/com.facebook.katana.LoginActivity -W

Before change:             | AVG | DEV
--------------------------------------
ThisTime:  549 492 512 511 | 516 | 24
TotalTime: 549 492 512 511 | 516 | 24
WaitTime:  662 511 528 526 | 557 | 71

After change:              | AVG | DEV
--------------------------------------
ThisTime:  530 467 503 544 | 511 | 34
TotalTime: 530 467 503 544 | 511 | 34
WaitTime:  551 497 536 583 | 541 | 36

Based on the numbers the speed impact of the change is less then the
accuracy of the measurement and it is also negligible.

The minor speed improvement displayed in the measurements are just
the cause of the variance of the measurement and not caused by this
change.

Change-Id: Ia9022cbc1bbfcc072314b6c95f63a4bf8060c36c
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index 09d8601..2c7f1fd 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -20,6 +20,7 @@
 
 #include "debugger.h"
 #include "entrypoints/runtime_asm_entrypoints.h"
+#include "jit/jit.h"
 #include "mirror/array-inl.h"
 #include "stack.h"
 #include "unstarted_runtime.h"
@@ -501,23 +502,6 @@
                                 uint32_t (&arg)[kVarArgMax],
                                 uint32_t vregC) ALWAYS_INLINE;
 
-SHARED_REQUIRES(Locks::mutator_lock_)
-static inline bool NeedsInterpreter(Thread* self, ShadowFrame* new_shadow_frame) ALWAYS_INLINE;
-
-static inline bool NeedsInterpreter(Thread* self, ShadowFrame* new_shadow_frame) {
-  ArtMethod* target = new_shadow_frame->GetMethod();
-  if (UNLIKELY(target->IsNative() || target->IsProxyMethod())) {
-    return false;
-  }
-  Runtime* runtime = Runtime::Current();
-  ClassLinker* class_linker = runtime->GetClassLinker();
-  return runtime->GetInstrumentation()->IsForcedInterpretOnly() ||
-        // Doing this check avoids doing compiled/interpreter transitions.
-        class_linker->IsQuickToInterpreterBridge(target->GetEntryPointFromQuickCompiledCode()) ||
-        // Force the use of interpreter when it is required by the debugger.
-        Dbg::IsForcedInterpreterNeededForCalling(self, target);
-}
-
 void ArtInterpreterToCompiledCodeBridge(Thread* self,
                                         const DexFile::CodeItem* code_item,
                                         ShadowFrame* shadow_frame,
@@ -736,10 +720,11 @@
 
   // Do the call now.
   if (LIKELY(Runtime::Current()->IsStarted())) {
-    if (NeedsInterpreter(self, new_shadow_frame)) {
-      ArtInterpreterToInterpreterBridge(self, code_item, new_shadow_frame, result);
-    } else {
+    ArtMethod* target = new_shadow_frame->GetMethod();
+    if (ClassLinker::CanUseAOTCode(target, target->GetEntryPointFromQuickCompiledCode())) {
       ArtInterpreterToCompiledCodeBridge(self, code_item, new_shadow_frame, result);
+    } else {
+      ArtInterpreterToInterpreterBridge(self, code_item, new_shadow_frame, result);
     }
   } else {
     UnstartedRuntime::Invoke(self, code_item, new_shadow_frame, result, first_dest_reg);