Various performance improvements.

Performance had regressed due to verify object and method invocation changes.
Avoid trampolines for static calls in same class.
Various inlining changes.
Make verify object something that's only compiled-in in debug builds.

Change-Id: Ia261a52232c3b10667c668f8adfadc0da3048bc5
diff --git a/src/compiler/dex/compiler_utility.cc b/src/compiler/dex/compiler_utility.cc
index b5185b0..9dc90ce 100644
--- a/src/compiler/dex/compiler_utility.cc
+++ b/src/compiler/dex/compiler_utility.cc
@@ -15,6 +15,7 @@
  */
 
 #include "compiler_internals.h"
+#include "dex_file-inl.h"
 
 namespace art {
 
diff --git a/src/compiler/dex/frontend.cc b/src/compiler/dex/frontend.cc
index 5b8faf4..0d3cb2e 100644
--- a/src/compiler/dex/frontend.cc
+++ b/src/compiler/dex/frontend.cc
@@ -22,6 +22,7 @@
 #include "compiler/llvm/llvm_compilation_unit.h"
 #endif
 #include "dataflow.h"
+#include "dex_file-inl.h"
 #include "ssa_transformation.h"
 #include "leb128.h"
 #include "mirror/object.h"
diff --git a/src/compiler/dex/quick/codegen_util.cc b/src/compiler/dex/quick/codegen_util.cc
index 110146f..24955f6 100644
--- a/src/compiler/dex/quick/codegen_util.cc
+++ b/src/compiler/dex/quick/codegen_util.cc
@@ -15,6 +15,7 @@
  */
 
 #include "compiler/dex/compiler_internals.h"
+#include "dex_file-inl.h"
 #include "gc_map.h"
 #include "verifier/dex_gc_map.h"
 #include "verifier/method_verifier.h"
diff --git a/src/compiler/driver/compiler_driver.cc b/src/compiler/driver/compiler_driver.cc
index 9ed763c..cc17031 100644
--- a/src/compiler/driver/compiler_driver.cc
+++ b/src/compiler/driver/compiler_driver.cc
@@ -25,6 +25,7 @@
 #include "base/timing_logger.h"
 #include "class_linker.h"
 #include "dex_compilation_unit.h"
+#include "dex_file-inl.h"
 #include "jni_internal.h"
 #include "oat_file.h"
 #include "oat/runtime/stub.h"
@@ -832,6 +833,7 @@
 }
 
 void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType type, InvokeType sharp_type,
+                                                   mirror::Class* referrer_class,
                                                    mirror::AbstractMethod* method,
                                                    uintptr_t& direct_code,
                                                    uintptr_t& direct_method) {
@@ -855,7 +857,8 @@
     return;
   }
   bool has_clinit_trampoline = method->IsStatic() && !method->GetDeclaringClass()->IsInitialized();
-  if (has_clinit_trampoline) {
+  if (has_clinit_trampoline && (method->GetDeclaringClass() != referrer_class)) {
+    // Ensure we run the clinit trampoline unless we are invoking a static method in the same class.
     return;
   }
   if (sharp_type != kInterface) {  // Interfaces always go via a trampoline.
@@ -930,14 +933,16 @@
           CHECK(referrer_class->GetDexCache()->GetResolvedMethod(method_idx) == resolved_method)
               << PrettyMethod(resolved_method);
           stats_->VirtualMadeDirect(type);
-          GetCodeAndMethodForDirectCall(type, kDirect, resolved_method, direct_code, direct_method);
+          GetCodeAndMethodForDirectCall(type, kDirect, referrer_class, resolved_method,
+                                        direct_code, direct_method);
           type = kDirect;
           return true;
         } else if (type == kSuper) {
           // Unsharpened super calls are suspicious so go slow-path.
         } else {
           stats_->ResolvedMethod(type);
-          GetCodeAndMethodForDirectCall(type, type, resolved_method, direct_code, direct_method);
+          GetCodeAndMethodForDirectCall(type, type, referrer_class, resolved_method,
+                                        direct_code, direct_method);
           return true;
         }
       }
diff --git a/src/compiler/driver/compiler_driver.h b/src/compiler/driver/compiler_driver.h
index 54a2f55..139bcd1 100644
--- a/src/compiler/driver/compiler_driver.h
+++ b/src/compiler/driver/compiler_driver.h
@@ -277,6 +277,7 @@
  private:
   // Compute constant code and method pointers when possible
   void GetCodeAndMethodForDirectCall(InvokeType type, InvokeType sharp_type,
+                                     mirror::Class* referrer_class,
                                      mirror::AbstractMethod* method,
                                      uintptr_t& direct_code, uintptr_t& direct_method)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
diff --git a/src/compiler/jni/jni_compiler_test.cc b/src/compiler/jni/jni_compiler_test.cc
index 6c9a6df..ef532f2 100644
--- a/src/compiler/jni/jni_compiler_test.cc
+++ b/src/compiler/jni/jni_compiler_test.cc
@@ -21,7 +21,7 @@
 #include "indirect_reference_table.h"
 #include "jni_internal.h"
 #include "mem_map.h"
-#include "mirror/class.h"
+#include "mirror/class-inl.h"
 #include "mirror/class_loader.h"
 #include "mirror/abstract_method-inl.h"
 #include "mirror/object_array-inl.h"
diff --git a/src/compiler/jni/portable/jni_compiler.cc b/src/compiler/jni/portable/jni_compiler.cc
index 8495150..ecc1eb7 100644
--- a/src/compiler/jni/portable/jni_compiler.cc
+++ b/src/compiler/jni/portable/jni_compiler.cc
@@ -26,6 +26,7 @@
 #include "compiler/llvm/llvm_compilation_unit.h"
 #include "compiler/llvm/runtime_support_func.h"
 #include "compiler/llvm/utils_llvm.h"
+#include "dex_file-inl.h"
 #include "mirror/abstract_method.h"
 #include "runtime.h"
 #include "stack.h"
diff --git a/src/compiler/jni/quick/jni_compiler.cc b/src/compiler/jni/quick/jni_compiler.cc
index c4919fb..3b85384 100644
--- a/src/compiler/jni/quick/jni_compiler.cc
+++ b/src/compiler/jni/quick/jni_compiler.cc
@@ -23,6 +23,7 @@
 #include "class_linker.h"
 #include "compiled_method.h"
 #include "compiler/driver/compiler_driver.h"
+#include "dex_file-inl.h"
 #include "disassembler.h"
 #include "jni_internal.h"
 #include "oat/runtime/oat_support_entrypoints.h"
diff --git a/src/compiler/llvm/gbc_expander.cc b/src/compiler/llvm/gbc_expander.cc
index 559ce4c..9b71694 100644
--- a/src/compiler/llvm/gbc_expander.cc
+++ b/src/compiler/llvm/gbc_expander.cc
@@ -16,6 +16,7 @@
 
 #include "compiler/driver/compiler_driver.h"
 #include "compiler/driver/dex_compilation_unit.h"
+#include "dex_file-inl.h"
 #include "intrinsic_helper.h"
 #include "ir_builder.h"
 #include "mirror/abstract_method.h"
diff --git a/src/compiler/llvm/runtime_support_llvm.cc b/src/compiler/llvm/runtime_support_llvm.cc
index b18eefe..d9b879a 100644
--- a/src/compiler/llvm/runtime_support_llvm.cc
+++ b/src/compiler/llvm/runtime_support_llvm.cc
@@ -20,7 +20,7 @@
 #include "asm_support.h"
 #include "class_linker.h"
 #include "class_linker-inl.h"
-#include "dex_file.h"
+#include "dex_file-inl.h"
 #include "dex_instruction.h"
 #include "mirror/abstract_method-inl.h"
 #include "mirror/class-inl.h"