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/check_jni.cc b/src/check_jni.cc
index c6a628f..57ce432 100644
--- a/src/check_jni.cc
+++ b/src/check_jni.cc
@@ -22,6 +22,7 @@
 #include "base/logging.h"
 #include "class_linker.h"
 #include "class_linker-inl.h"
+#include "dex_file-inl.h"
 #include "gc/space.h"
 #include "mirror/class-inl.h"
 #include "mirror/field-inl.h"
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 725e710..76b3177 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -33,7 +33,7 @@
 #include "base/unix_file/fd_file.h"
 #include "class_linker-inl.h"
 #include "debugger.h"
-#include "dex_file.h"
+#include "dex_file-inl.h"
 #include "gc/card_table-inl.h"
 #include "heap.h"
 #include "intern_table.h"
diff --git a/src/common_test.h b/src/common_test.h
index 62e7561..368e4a7 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -27,7 +27,7 @@
 #include "base/unix_file/fd_file.h"
 #include "class_linker.h"
 #include "compiler/driver/compiler_driver.h"
-#include "dex_file.h"
+#include "dex_file-inl.h"
 #include "gtest/gtest.h"
 #include "heap.h"
 #include "instruction_set.h"
diff --git a/src/common_throws.cc b/src/common_throws.cc
index 734d544..8673d11 100644
--- a/src/common_throws.cc
+++ b/src/common_throws.cc
@@ -18,9 +18,11 @@
 
 #include "base/logging.h"
 #include "class_linker-inl.h"
+#include "dex_file-inl.h"
 #include "dex_instruction.h"
 #include "invoke_type.h"
 #include "mirror/abstract_method-inl.h"
+#include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
 #include "mirror/object_array-inl.h"
 #include "object_utils.h"
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"
diff --git a/src/debugger.cc b/src/debugger.cc
index 09c930a..a2ebddf 100644
--- a/src/debugger.cc
+++ b/src/debugger.cc
@@ -22,6 +22,7 @@
 
 #include "class_linker.h"
 #include "class_linker-inl.h"
+#include "dex_file-inl.h"
 #include "dex_instruction.h"
 #include "gc/card_table-inl.h"
 #include "gc/large_object_space.h"
diff --git a/src/dex2oat.cc b/src/dex2oat.cc
index 5c6b35e..2f9d579 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -29,6 +29,7 @@
 #include "base/unix_file/fd_file.h"
 #include "class_linker.h"
 #include "compiler/driver/compiler_driver.h"
+#include "dex_file-inl.h"
 #include "image_writer.h"
 #include "leb128.h"
 #include "mirror/abstract_method-inl.h"
diff --git a/src/dex_file-inl.h b/src/dex_file-inl.h
new file mode 100644
index 0000000..5d8216e
--- /dev/null
+++ b/src/dex_file-inl.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_DEX_FILE_INL_H_
+#define ART_SRC_DEX_FILE_INL_H_
+
+#include "base/logging.h"
+#include "dex_file.h"
+#include "leb128.h"
+#include "utils.h"
+
+namespace art {
+
+inline int32_t DexFile::GetStringLength(const StringId& string_id) const {
+  const byte* ptr = begin_ + string_id.string_data_off_;
+  return DecodeUnsignedLeb128(&ptr);
+}
+
+inline const char* DexFile::GetStringDataAndLength(const StringId& string_id, uint32_t* length) const {
+  DCHECK(length != NULL) << GetLocation();
+  const byte* ptr = begin_ + string_id.string_data_off_;
+  *length = DecodeUnsignedLeb128(&ptr);
+  return reinterpret_cast<const char*>(ptr);
+}
+
+inline const DexFile::TryItem* DexFile::GetTryItems(const CodeItem& code_item, uint32_t offset) {
+  const uint16_t* insns_end_ = &code_item.insns_[code_item.insns_size_in_code_units_];
+  return reinterpret_cast<const TryItem*>
+      (RoundUp(reinterpret_cast<uint32_t>(insns_end_), 4)) + offset;
+}
+
+}  // namespace art
+
+#endif  // ART_SRC_DEX_FILE_INL_H_
diff --git a/src/dex_file.cc b/src/dex_file.cc
index 12c11e8..8b87ee7 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -27,6 +27,7 @@
 #include "base/logging.h"
 #include "base/stringprintf.h"
 #include "class_linker.h"
+#include "dex_file-inl.h"
 #include "dex_file_verifier.h"
 #include "globals.h"
 #include "leb128.h"
@@ -337,19 +338,6 @@
   return atoi(version);
 }
 
-int32_t DexFile::GetStringLength(const StringId& string_id) const {
-  const byte* ptr = begin_ + string_id.string_data_off_;
-  return DecodeUnsignedLeb128(&ptr);
-}
-
-// Returns a pointer to the UTF-8 string data referred to by the given string_id.
-const char* DexFile::GetStringDataAndLength(const StringId& string_id, uint32_t* length) const {
-  DCHECK(length != NULL) << GetLocation();
-  const byte* ptr = begin_ + string_id.string_data_off_;
-  *length = DecodeUnsignedLeb128(&ptr);
-  return reinterpret_cast<const char*>(ptr);
-}
-
 void DexFile::InitIndex() {
   CHECK_EQ(index_.size(), 0U) << GetLocation();
   for (size_t i = 0; i < NumClassDefs(); ++i) {
@@ -621,12 +609,6 @@
   return context.line_num_;
 }
 
-const DexFile::TryItem* DexFile::GetTryItems(const CodeItem& code_item, uint32_t offset) {
-  const uint16_t* insns_end_ = &code_item.insns_[code_item.insns_size_in_code_units_];
-  return reinterpret_cast<const TryItem*>
-      (RoundUp(reinterpret_cast<uint32_t>(insns_end_), 4)) + offset;
-}
-
 int32_t DexFile::FindCatchHandlerOffset(const CodeItem &code_item, int32_t tries_size,
                                         uint32_t address) {
   // Note: Signed type is important for max and min.
diff --git a/src/dex_file.h b/src/dex_file.h
index 14b4ba0..2da3e32 100644
--- a/src/dex_file.h
+++ b/src/dex_file.h
@@ -379,7 +379,7 @@
   jobject GetDexObject(JNIEnv* env) const;
 
   const Header& GetHeader() const {
-    CHECK(header_ != NULL) << GetLocation();
+    DCHECK(header_ != NULL) << GetLocation();
     return *header_;
   }
 
@@ -394,13 +394,13 @@
 
   // Returns the number of string identifiers in the .dex file.
   size_t NumStringIds() const {
-    CHECK(header_ != NULL) << GetLocation();
+    DCHECK(header_ != NULL) << GetLocation();
     return header_->string_ids_size_;
   }
 
   // Returns the StringId at the specified index.
   const StringId& GetStringId(uint32_t idx) const {
-    CHECK_LT(idx, NumStringIds()) << GetLocation();
+    DCHECK_LT(idx, NumStringIds()) << GetLocation();
     return string_ids_[idx];
   }
 
@@ -440,13 +440,13 @@
 
   // Returns the number of type identifiers in the .dex file.
   size_t NumTypeIds() const {
-    CHECK(header_ != NULL) << GetLocation();
+    DCHECK(header_ != NULL) << GetLocation();
     return header_->type_ids_size_;
   }
 
   // Returns the TypeId at the specified index.
   const TypeId& GetTypeId(uint32_t idx) const {
-    CHECK_LT(idx, NumTypeIds()) << GetLocation();
+    DCHECK_LT(idx, NumTypeIds()) << GetLocation();
     return type_ids_[idx];
   }
 
@@ -479,7 +479,7 @@
 
   // Returns the number of field identifiers in the .dex file.
   size_t NumFieldIds() const {
-    CHECK(header_ != NULL) << GetLocation();
+    DCHECK(header_ != NULL) << GetLocation();
     return header_->field_ids_size_;
   }
 
@@ -519,13 +519,13 @@
 
   // Returns the number of method identifiers in the .dex file.
   size_t NumMethodIds() const {
-    CHECK(header_ != NULL) << GetLocation();
+    DCHECK(header_ != NULL) << GetLocation();
     return header_->method_ids_size_;
   }
 
   // Returns the MethodId at the specified index.
   const MethodId& GetMethodId(uint32_t idx) const {
-    CHECK_LT(idx, NumMethodIds()) << GetLocation();
+    DCHECK_LT(idx, NumMethodIds()) << GetLocation();
     return method_ids_[idx];
   }
 
@@ -570,7 +570,7 @@
   }
   // Returns the number of class definitions in the .dex file.
   size_t NumClassDefs() const {
-    CHECK(header_ != NULL) << GetLocation();
+    DCHECK(header_ != NULL) << GetLocation();
     return header_->class_defs_size_;
   }
 
@@ -631,13 +631,13 @@
 
   // Returns the number of prototype identifiers in the .dex file.
   size_t NumProtoIds() const {
-    CHECK(header_ != NULL) << GetLocation();
+    DCHECK(header_ != NULL) << GetLocation();
     return header_->proto_ids_size_;
   }
 
   // Returns the ProtoId at the specified index.
   const ProtoId& GetProtoId(uint32_t idx) const {
-    CHECK_LT(idx, NumProtoIds()) << GetLocation();
+    DCHECK_LT(idx, NumProtoIds()) << GetLocation();
     return proto_ids_[idx];
   }
 
diff --git a/src/dex_file_verifier.cc b/src/dex_file_verifier.cc
index 2f9054e..b1efcaa 100644
--- a/src/dex_file_verifier.cc
+++ b/src/dex_file_verifier.cc
@@ -17,6 +17,7 @@
 #include "dex_file_verifier.h"
 
 #include "base/stringprintf.h"
+#include "dex_file-inl.h"
 #include "leb128.h"
 #include "safe_map.h"
 #include "UniquePtr.h"
diff --git a/src/dex_instruction.cc b/src/dex_instruction.cc
index 55f6eca..3224d77 100644
--- a/src/dex_instruction.cc
+++ b/src/dex_instruction.cc
@@ -16,7 +16,7 @@
 
 #include "dex_instruction.h"
 
-#include "dex_file.h"
+#include "dex_file-inl.h"
 #include "utils.h"
 #include <iomanip>
 
diff --git a/src/exception_test.cc b/src/exception_test.cc
index 1b4332f..0cd8123 100644
--- a/src/exception_test.cc
+++ b/src/exception_test.cc
@@ -18,6 +18,7 @@
 #include "common_test.h"
 #include "dex_file.h"
 #include "gtest/gtest.h"
+#include "mirror/class-inl.h"
 #include "mirror/object_array-inl.h"
 #include "mirror/object-inl.h"
 #include "mirror/stack_trace_element.h"
diff --git a/src/gc/space.cc b/src/gc/space.cc
index 9c71841..e618f07 100644
--- a/src/gc/space.cc
+++ b/src/gc/space.cc
@@ -24,6 +24,8 @@
 #include "image.h"
 #include "mirror/array.h"
 #include "mirror/abstract_method.h"
+#include "mirror/class-inl.h"
+#include "mirror/object-inl.h"
 #include "os.h"
 #include "runtime.h"
 #include "space_bitmap.h"
diff --git a/src/gc/space_bitmap.cc b/src/gc/space_bitmap.cc
index d90c090..773aa1e 100644
--- a/src/gc/space_bitmap.cc
+++ b/src/gc/space_bitmap.cc
@@ -17,6 +17,7 @@
 #include "heap_bitmap.h"
 
 #include "base/logging.h"
+#include "dex_file-inl.h"
 #include "mirror/class-inl.h"
 #include "mirror/field-inl.h"
 #include "mirror/object-inl.h"
diff --git a/src/hprof/hprof.cc b/src/hprof/hprof.cc
index e0a4c05..8f691f0 100644
--- a/src/hprof/hprof.cc
+++ b/src/hprof/hprof.cc
@@ -42,6 +42,7 @@
 #include "base/unix_file/fd_file.h"
 #include "class_linker.h"
 #include "debugger.h"
+#include "dex_file-inl.h"
 #include "globals.h"
 #include "heap.h"
 #include "mirror/class.h"
diff --git a/src/image.cc b/src/image.cc
index 8eeb772..d6bf635 100644
--- a/src/image.cc
+++ b/src/image.cc
@@ -18,6 +18,7 @@
 
 #include "mirror/object_array.h"
 #include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
 #include "utils.h"
 
 namespace art {
diff --git a/src/image_writer.cc b/src/image_writer.cc
index ad2c9b7..a56a4aa 100644
--- a/src/image_writer.cc
+++ b/src/image_writer.cc
@@ -25,6 +25,7 @@
 #include "class_linker.h"
 #include "compiled_method.h"
 #include "compiler/driver/compiler_driver.h"
+#include "dex_file-inl.h"
 #include "gc/card_table-inl.h"
 #include "gc/large_object_space.h"
 #include "gc/space.h"
diff --git a/src/indirect_reference_table.cc b/src/indirect_reference_table.cc
index 720380a..0287d74 100644
--- a/src/indirect_reference_table.cc
+++ b/src/indirect_reference_table.cc
@@ -65,7 +65,7 @@
 bool IndirectReferenceTable::CheckEntry(const char* what, IndirectRef iref, int idx) const {
   const mirror::Object* obj = table_[idx];
   IndirectRef checkRef = ToIndirectRef(obj, idx);
-  if (checkRef != iref) {
+  if (UNLIKELY(checkRef != iref)) {
     LOG(ERROR) << "JNI ERROR (app bug): attempt to " << what
                << " stale " << kind_ << " " << iref
                << " (should be " << checkRef << ")";
@@ -162,11 +162,11 @@
 // Verifies that the indirect table lookup is valid.
 // Returns "false" if something looks bad.
 bool IndirectReferenceTable::GetChecked(IndirectRef iref) const {
-  if (iref == NULL) {
+  if (UNLIKELY(iref == NULL)) {
     LOG(WARNING) << "Attempt to look up NULL " << kind_;
     return false;
   }
-  if (GetIndirectRefKind(iref) == kSirtOrInvalid) {
+  if (UNLIKELY(GetIndirectRefKind(iref) == kSirtOrInvalid)) {
     LOG(ERROR) << "JNI ERROR (app bug): invalid " << kind_ << " " << iref;
     AbortMaybe();
     return false;
@@ -174,20 +174,20 @@
 
   int topIndex = segment_state_.parts.topIndex;
   int idx = ExtractIndex(iref);
-  if (idx >= topIndex) {
+  if (UNLIKELY(idx >= topIndex)) {
     LOG(ERROR) << "JNI ERROR (app bug): accessed stale " << kind_ << " "
                << iref << " (index " << idx << " in a table of size " << topIndex << ")";
     AbortMaybe();
     return false;
   }
 
-  if (table_[idx] == NULL) {
+  if (UNLIKELY(table_[idx] == NULL)) {
     LOG(ERROR) << "JNI ERROR (app bug): accessed deleted " << kind_ << " " << iref;
     AbortMaybe();
     return false;
   }
 
-  if (!CheckEntry("use", iref, idx)) {
+  if (UNLIKELY(!CheckEntry("use", iref, idx))) {
     return false;
   }
 
diff --git a/src/instrumentation.cc b/src/instrumentation.cc
index 33f2495..81fe637 100644
--- a/src/instrumentation.cc
+++ b/src/instrumentation.cc
@@ -25,6 +25,7 @@
 #include "mirror/dex_cache.h"
 #include "mirror/abstract_method-inl.h"
 #include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
 #if !defined(ART_USE_PORTABLE_COMPILER)
 #include "oat/runtime/oat_support_entrypoints.h"
 #endif
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc
index 1a571ec..3564497 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -22,6 +22,7 @@
 #include "class_linker-inl.h"
 #include "common_throws.h"
 #include "debugger.h"
+#include "dex_file-inl.h"
 #include "dex_instruction.h"
 #include "gc/card_table-inl.h"
 #include "invoke_arg_array_builder.h"
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index 9cf12e0..344ce78 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -27,6 +27,7 @@
 #include "base/stl_util.h"
 #include "base/stringpiece.h"
 #include "class_linker.h"
+#include "dex_file-inl.h"
 #include "gc/card_table-inl.h"
 #include "invoke_arg_array_builder.h"
 #include "jni.h"
diff --git a/src/jni_internal_test.cc b/src/jni_internal_test.cc
index 5f7a6c8..5ef2281 100644
--- a/src/jni_internal_test.cc
+++ b/src/jni_internal_test.cc
@@ -22,6 +22,7 @@
 #include "common_test.h"
 #include "invoke_arg_array_builder.h"
 #include "mirror/abstract_method-inl.h"
+#include "mirror/class-inl.h"
 #include "mirror/object_array-inl.h"
 #include "mirror/object-inl.h"
 #include "ScopedLocalRef.h"
diff --git a/src/jobject_comparator.cc b/src/jobject_comparator.cc
index 738a186..e22d75f 100644
--- a/src/jobject_comparator.cc
+++ b/src/jobject_comparator.cc
@@ -17,7 +17,7 @@
 #include "jobject_comparator.h"
 
 #include "mirror/array-inl.h"
-#include "mirror/class.h"
+#include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
 #include "scoped_thread_state_change.h"
 
diff --git a/src/mirror/abstract_method-inl.h b/src/mirror/abstract_method-inl.h
index efb7c03..e14cce2 100644
--- a/src/mirror/abstract_method-inl.h
+++ b/src/mirror/abstract_method-inl.h
@@ -19,8 +19,8 @@
 
 #include "abstract_method.h"
 
-#include "array.h"
 #include "dex_file.h"
+#include "object_array.h"
 #include "runtime.h"
 
 namespace art {
@@ -52,6 +52,27 @@
   return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_dex_index_), false);
 }
 
+inline ObjectArray<String>* AbstractMethod::GetDexCacheStrings() const {
+  return GetFieldObject<ObjectArray<String>*>(
+      OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_), false);
+}
+
+inline ObjectArray<AbstractMethod>* AbstractMethod::GetDexCacheResolvedMethods() const {
+  return GetFieldObject<ObjectArray<AbstractMethod>*>(
+      OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_), false);
+}
+
+inline ObjectArray<Class>* AbstractMethod::GetDexCacheResolvedTypes() const {
+  return GetFieldObject<ObjectArray<Class>*>(
+      OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_), false);
+}
+
+inline ObjectArray<StaticStorageBase>* AbstractMethod::GetDexCacheInitializedStaticStorage() const {
+  return GetFieldObject<ObjectArray<StaticStorageBase>*>(
+      OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_),
+      false);
+}
+
 inline uint32_t AbstractMethod::GetCodeSize() const {
   DCHECK(!IsRuntimeMethod() && !IsProxyMethod()) << PrettyMethod(this);
   uintptr_t code = reinterpret_cast<uintptr_t>(GetCode());
diff --git a/src/mirror/abstract_method.cc b/src/mirror/abstract_method.cc
index e185c9c..c0c9a55 100644
--- a/src/mirror/abstract_method.cc
+++ b/src/mirror/abstract_method.cc
@@ -17,8 +17,9 @@
 #include "abstract_method.h"
 
 #include "abstract_method-inl.h"
-#include "class-inl.h"
 #include "base/stringpiece.h"
+#include "class-inl.h"
+#include "dex_file-inl.h"
 #include "gc/card_table-inl.h"
 #include "interpreter/interpreter.h"
 #include "jni_internal.h"
@@ -69,42 +70,21 @@
   java_lang_reflect_Method_ = NULL;
 }
 
-ObjectArray<String>* AbstractMethod::GetDexCacheStrings() const {
-  return GetFieldObject<ObjectArray<String>*>(
-      OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_), false);
-}
-
 void AbstractMethod::SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings) {
   SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_),
                  new_dex_cache_strings, false);
 }
 
-ObjectArray<AbstractMethod>* AbstractMethod::GetDexCacheResolvedMethods() const {
-  return GetFieldObject<ObjectArray<AbstractMethod>*>(
-      OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_), false);
-}
-
 void AbstractMethod::SetDexCacheResolvedMethods(ObjectArray<AbstractMethod>* new_dex_cache_methods) {
   SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_),
                  new_dex_cache_methods, false);
 }
 
-ObjectArray<Class>* AbstractMethod::GetDexCacheResolvedTypes() const {
-  return GetFieldObject<ObjectArray<Class>*>(
-      OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_), false);
-}
-
 void AbstractMethod::SetDexCacheResolvedTypes(ObjectArray<Class>* new_dex_cache_classes) {
   SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_),
                  new_dex_cache_classes, false);
 }
 
-ObjectArray<StaticStorageBase>* AbstractMethod::GetDexCacheInitializedStaticStorage() const {
-  return GetFieldObject<ObjectArray<StaticStorageBase>*>(
-      OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_),
-      false);
-}
-
 void AbstractMethod::SetDexCacheInitializedStaticStorage(ObjectArray<StaticStorageBase>* new_value) {
   SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_),
       new_value, false);
diff --git a/src/mirror/array.cc b/src/mirror/array.cc
index 103efa3..d0b3838 100644
--- a/src/mirror/array.cc
+++ b/src/mirror/array.cc
@@ -18,6 +18,7 @@
 
 #include "class.h"
 #include "class-inl.h"
+#include "dex_file-inl.h"
 #include "gc/card_table-inl.h"
 #include "object-inl.h"
 #include "object_array.h"
diff --git a/src/mirror/class-inl.h b/src/mirror/class-inl.h
index 3ca4c30..ec92c19 100644
--- a/src/mirror/class-inl.h
+++ b/src/mirror/class-inl.h
@@ -20,6 +20,8 @@
 #include "class.h"
 
 #include "abstract_method.h"
+#include "class_loader.h"
+#include "dex_cache.h"
 #include "field.h"
 #include "iftable.h"
 #include "object_array.h"
@@ -30,10 +32,10 @@
 namespace mirror {
 
 inline size_t Class::GetObjectSize() const {
-  CHECK(!IsVariableSize()) << " class=" << PrettyTypeOf(this);
+  DCHECK(!IsVariableSize()) << " class=" << PrettyTypeOf(this);
   DCHECK_EQ(sizeof(size_t), sizeof(int32_t));
   size_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, object_size_), false);
-  CHECK_GE(result, sizeof(Object)) << " class=" << PrettyTypeOf(this);
+  DCHECK_GE(result, sizeof(Object)) << " class=" << PrettyTypeOf(this);
   return result;
 }
 
@@ -44,6 +46,14 @@
   return GetFieldObject<Class*>(OFFSET_OF_OBJECT_MEMBER(Class, super_class_), false);
 }
 
+inline ClassLoader* Class::GetClassLoader() const {
+  return GetFieldObject<ClassLoader*>(OFFSET_OF_OBJECT_MEMBER(Class, class_loader_), false);
+}
+
+inline DexCache* Class::GetDexCache() const {
+  return GetFieldObject<DexCache*>(OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_), false);
+}
+
 inline ObjectArray<AbstractMethod>* Class::GetDirectMethods() const {
   DCHECK(IsLoaded() || IsErroneous());
   return GetFieldObject<ObjectArray<AbstractMethod>*>(
diff --git a/src/mirror/class.cc b/src/mirror/class.cc
index e3347a8..f4d87a4 100644
--- a/src/mirror/class.cc
+++ b/src/mirror/class.cc
@@ -21,6 +21,7 @@
 #include "class_linker.h"
 #include "class_loader.h"
 #include "dex_cache.h"
+#include "dex_file-inl.h"
 #include "field-inl.h"
 #include "gc/card_table-inl.h"
 #include "object-inl.h"
@@ -83,10 +84,6 @@
   return SetField32(OFFSET_OF_OBJECT_MEMBER(Class, status_), new_status, false);
 }
 
-DexCache* Class::GetDexCache() const {
-  return GetFieldObject<DexCache*>(OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_), false);
-}
-
 void Class::SetDexCache(DexCache* new_dex_cache) {
   SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_), new_dex_cache, false);
 }
@@ -302,10 +299,6 @@
 
 }
 
-ClassLoader* Class::GetClassLoader() const {
-  return GetFieldObject<ClassLoader*>(OFFSET_OF_OBJECT_MEMBER(Class, class_loader_), false);
-}
-
 void Class::SetClassLoader(ClassLoader* new_class_loader) {
   SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, class_loader_), new_class_loader, false);
 }
diff --git a/src/mirror/object-inl.h b/src/mirror/object-inl.h
index 3913c81..1a91dd3 100644
--- a/src/mirror/object-inl.h
+++ b/src/mirror/object-inl.h
@@ -21,7 +21,7 @@
 
 #include "abstract_method.h"
 #include "atomic.h"
-#include "array.h"
+#include "array-inl.h"
 #include "field.h"
 #include "class.h"
 #include "monitor.h"
@@ -264,7 +264,9 @@
 }
 
 inline void Object::VerifyObject(const Object* obj) {
-  Runtime::Current()->GetHeap()->VerifyObject(obj);
+  if (kIsDebugBuild) {
+    Runtime::Current()->GetHeap()->VerifyObject(obj);
+  }
 }
 
 }  // namespace mirror
diff --git a/src/mirror/object.h b/src/mirror/object.h
index 0cce8d8..71b628d 100644
--- a/src/mirror/object.h
+++ b/src/mirror/object.h
@@ -233,7 +233,7 @@
   }
 
  private:
-  static void VerifyObject(const Object* obj);
+  static void VerifyObject(const Object* obj) ALWAYS_INLINE;
 
   // Verify the type correctness of stores to fields.
   void CheckFieldAssignmentImpl(MemberOffset field_offset, const Object* new_value)
diff --git a/src/mirror/throwable.cc b/src/mirror/throwable.cc
index bbab1dd..d1192b0 100644
--- a/src/mirror/throwable.cc
+++ b/src/mirror/throwable.cc
@@ -18,6 +18,7 @@
 
 #include "abstract_method-inl.h"
 #include "class-inl.h"
+#include "dex_file-inl.h"
 #include "gc/card_table-inl.h"
 #include "object-inl.h"
 #include "object_array.h"
diff --git a/src/monitor.cc b/src/monitor.cc
index b4c3964..2377734 100644
--- a/src/monitor.cc
+++ b/src/monitor.cc
@@ -21,8 +21,10 @@
 #include "base/mutex.h"
 #include "base/stl_util.h"
 #include "class_linker.h"
+#include "dex_file-inl.h"
 #include "dex_instruction.h"
 #include "mirror/abstract_method-inl.h"
+#include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
 #include "mirror/object_array-inl.h"
 #include "object_utils.h"
diff --git a/src/native/dalvik_system_DexFile.cc b/src/native/dalvik_system_DexFile.cc
index 0390703..7c6fbd9 100644
--- a/src/native/dalvik_system_DexFile.cc
+++ b/src/native/dalvik_system_DexFile.cc
@@ -18,7 +18,7 @@
 
 #include "base/logging.h"
 #include "class_linker.h"
-#include "dex_file.h"
+#include "dex_file-inl.h"
 #include "gc/space.h"
 #include "image.h"
 #include "jni_internal.h"
diff --git a/src/native/dalvik_system_VMRuntime.cc b/src/native/dalvik_system_VMRuntime.cc
index 4c6777a..a13d07a 100644
--- a/src/native/dalvik_system_VMRuntime.cc
+++ b/src/native/dalvik_system_VMRuntime.cc
@@ -18,7 +18,9 @@
 
 #include "class_linker.h"
 #include "debugger.h"
+#include "dex_file-inl.h"
 #include "jni_internal.h"
+#include "mirror/class-inl.h"
 #include "mirror/object.h"
 #include "mirror/object-inl.h"
 #include "object_utils.h"
diff --git a/src/native/dalvik_system_VMStack.cc b/src/native/dalvik_system_VMStack.cc
index bb2ed88..1a80d62 100644
--- a/src/native/dalvik_system_VMStack.cc
+++ b/src/native/dalvik_system_VMStack.cc
@@ -17,8 +17,9 @@
 #include "jni_internal.h"
 #include "nth_caller_visitor.h"
 #include "mirror/abstract_method-inl.h"
-#include "mirror/class.h"
+#include "mirror/class-inl.h"
 #include "mirror/class_loader.h"
+#include "mirror/object-inl.h"
 #include "scoped_thread_state_change.h"
 #include "thread_list.h"
 
diff --git a/src/native/java_lang_Class.cc b/src/native/java_lang_Class.cc
index dded787..72f4c18 100644
--- a/src/native/java_lang_Class.cc
+++ b/src/native/java_lang_Class.cc
@@ -15,9 +15,10 @@
  */
 
 #include "class_linker.h"
+#include "dex_file-inl.h"
 #include "jni_internal.h"
 #include "nth_caller_visitor.h"
-#include "mirror/class.h"
+#include "mirror/class-inl.h"
 #include "mirror/class_loader.h"
 #include "mirror/object-inl.h"
 #include "mirror/proxy.h"
diff --git a/src/native/java_lang_VMClassLoader.cc b/src/native/java_lang_VMClassLoader.cc
index 02b7c25..c23b08c 100644
--- a/src/native/java_lang_VMClassLoader.cc
+++ b/src/native/java_lang_VMClassLoader.cc
@@ -17,6 +17,7 @@
 #include "class_linker.h"
 #include "jni_internal.h"
 #include "mirror/class_loader.h"
+#include "mirror/object-inl.h"
 #include "scoped_thread_state_change.h"
 #include "ScopedUtfChars.h"
 #include "zip_archive.h"
diff --git a/src/native/java_lang_reflect_Array.cc b/src/native/java_lang_reflect_Array.cc
index 2833cb0..af7a77a 100644
--- a/src/native/java_lang_reflect_Array.cc
+++ b/src/native/java_lang_reflect_Array.cc
@@ -15,8 +15,9 @@
  */
 
 #include "class_linker.h"
+#include "dex_file-inl.h"
 #include "jni_internal.h"
-#include "mirror/class.h"
+#include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
 #include "object_utils.h"
 #include "scoped_thread_state_change.h"
diff --git a/src/native/java_lang_reflect_Field.cc b/src/native/java_lang_reflect_Field.cc
index 9a2671c..922fe00 100644
--- a/src/native/java_lang_reflect_Field.cc
+++ b/src/native/java_lang_reflect_Field.cc
@@ -16,7 +16,9 @@
 
 #include "class_linker.h"
 #include "class_linker-inl.h"
+#include "dex_file-inl.h"
 #include "jni_internal.h"
+#include "mirror/class-inl.h"
 #include "mirror/field.h"
 #include "mirror/field-inl.h"
 #include "object_utils.h"
diff --git a/src/oat.cc b/src/oat.cc
index 145abc6..479339a 100644
--- a/src/oat.cc
+++ b/src/oat.cc
@@ -74,11 +74,6 @@
   return reinterpret_cast<const char*>(magic_);
 }
 
-uint32_t OatHeader::GetDexFileCount() const {
-  DCHECK(IsValid());
-  return dex_file_count_;
-}
-
 uint32_t OatHeader::GetChecksum() const {
   CHECK(IsValid());
   return adler32_checksum_;
diff --git a/src/oat.h b/src/oat.h
index b4747d4..2ad44c0 100644
--- a/src/oat.h
+++ b/src/oat.h
@@ -38,7 +38,10 @@
   const char* GetMagic() const;
   uint32_t GetChecksum() const;
   void UpdateChecksum(const void* data, size_t length);
-  uint32_t GetDexFileCount() const;
+  uint32_t GetDexFileCount() const {
+    DCHECK(IsValid());
+    return dex_file_count_;
+  }
   uint32_t GetExecutableOffset() const;
   InstructionSet GetInstructionSet() const;
   void SetExecutableOffset(uint32_t executable_offset);
diff --git a/src/oat/runtime/arm/context_arm.cc b/src/oat/runtime/arm/context_arm.cc
index 814e649..7b45bc2a7 100644
--- a/src/oat/runtime/arm/context_arm.cc
+++ b/src/oat/runtime/arm/context_arm.cc
@@ -70,9 +70,9 @@
 }
 
 void ArmContext::SetGPR(uint32_t reg, uintptr_t value) {
-  CHECK_LT(reg, kNumberOfCoreRegisters);
-  CHECK_NE(gprs_[reg], &gZero); // Can't overwrite this static value since they are never reset.
-  CHECK(gprs_[reg] != NULL);
+  DCHECK_LT(reg, kNumberOfCoreRegisters);
+  DCHECK_NE(gprs_[reg], &gZero); // Can't overwrite this static value since they are never reset.
+  DCHECK(gprs_[reg] != NULL);
   *gprs_[reg] = value;
 }
 
diff --git a/src/oat/runtime/arm/stub_arm.cc b/src/oat/runtime/arm/stub_arm.cc
index 9091928..33354bd 100644
--- a/src/oat/runtime/arm/stub_arm.cc
+++ b/src/oat/runtime/arm/stub_arm.cc
@@ -16,6 +16,7 @@
 
 #include "jni_internal.h"
 #include "mirror/array.h"
+#include "mirror/object-inl.h"
 #include "oat/utils/arm/assembler_arm.h"
 #include "oat/runtime/oat_support_entrypoints.h"
 #include "oat/runtime/stub.h"
diff --git a/src/oat/runtime/mips/stub_mips.cc b/src/oat/runtime/mips/stub_mips.cc
index 1b5e6cc..60ec9de 100644
--- a/src/oat/runtime/mips/stub_mips.cc
+++ b/src/oat/runtime/mips/stub_mips.cc
@@ -16,6 +16,7 @@
 
 #include "jni_internal.h"
 #include "mirror/array.h"
+#include "mirror/object-inl.h"
 #include "oat/runtime/oat_support_entrypoints.h"
 #include "oat/runtime/stub.h"
 #include "oat/utils/mips/assembler_mips.h"
diff --git a/src/oat/runtime/support_alloc.cc b/src/oat/runtime/support_alloc.cc
index 5e3af78..f66fc84 100644
--- a/src/oat/runtime/support_alloc.cc
+++ b/src/oat/runtime/support_alloc.cc
@@ -18,6 +18,7 @@
 #include "mirror/class-inl.h"
 #include "mirror/abstract_method-inl.h"
 #include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
 #include "runtime_support.h"
 
 namespace art {
diff --git a/src/oat/runtime/support_deoptimize.cc b/src/oat/runtime/support_deoptimize.cc
index c77d034..2cc5dd3 100644
--- a/src/oat/runtime/support_deoptimize.cc
+++ b/src/oat/runtime/support_deoptimize.cc
@@ -15,9 +15,12 @@
  */
 
 #include "callee_save_frame.h"
+#include "dex_file-inl.h"
 #include "interpreter/interpreter.h"
 #include "mirror/abstract_method-inl.h"
+#include "mirror/class-inl.h"
 #include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
 #include "object_utils.h"
 #include "stack.h"
 #include "thread.h"
diff --git a/src/oat/runtime/support_dexcache.cc b/src/oat/runtime/support_dexcache.cc
index da15917..6811d20 100644
--- a/src/oat/runtime/support_dexcache.cc
+++ b/src/oat/runtime/support_dexcache.cc
@@ -18,6 +18,7 @@
 #include "class_linker-inl.h"
 #include "mirror/abstract_method-inl.h"
 #include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
 #include "runtime_support.h"
 
 namespace art {
diff --git a/src/oat/runtime/support_field.cc b/src/oat/runtime/support_field.cc
index a564fa9..43d5c9b 100644
--- a/src/oat/runtime/support_field.cc
+++ b/src/oat/runtime/support_field.cc
@@ -15,6 +15,7 @@
  */
 
 #include "callee_save_frame.h"
+#include "dex_file-inl.h"
 #include "mirror/abstract_method-inl.h"
 #include "mirror/class-inl.h"
 #include "mirror/field-inl.h"
diff --git a/src/oat/runtime/support_interpreter.cc b/src/oat/runtime/support_interpreter.cc
index a02ef27..7f413c3 100644
--- a/src/oat/runtime/support_interpreter.cc
+++ b/src/oat/runtime/support_interpreter.cc
@@ -16,10 +16,12 @@
 
 #include "argument_visitor.h"
 #include "callee_save_frame.h"
+#include "dex_file-inl.h"
 #include "interpreter/interpreter.h"
 #include "mirror/abstract_method-inl.h"
-#include "mirror/object.h"
+#include "mirror/class-inl.h"
 #include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
 #include "object_utils.h"
 
 namespace art {
diff --git a/src/oat/runtime/support_jni.cc b/src/oat/runtime/support_jni.cc
index 6799159..ee19d4e 100644
--- a/src/oat/runtime/support_jni.cc
+++ b/src/oat/runtime/support_jni.cc
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include "dex_file-inl.h"
 #include "mirror/class-inl.h"
 #include "mirror/abstract_method-inl.h"
 #include "mirror/object.h"
diff --git a/src/oat/runtime/support_proxy.cc b/src/oat/runtime/support_proxy.cc
index 65e404a..040a701 100644
--- a/src/oat/runtime/support_proxy.cc
+++ b/src/oat/runtime/support_proxy.cc
@@ -15,9 +15,10 @@
  */
 
 #include "argument_visitor.h"
+#include "dex_file-inl.h"
 #include "mirror/abstract_method-inl.h"
-#include "mirror/object.h"
 #include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
 #include "object_utils.h"
 #include "reflection.h"
 #include "runtime_support.h"
diff --git a/src/oat/runtime/support_stubs.cc b/src/oat/runtime/support_stubs.cc
index 1807a3d..25d7cd2 100644
--- a/src/oat/runtime/support_stubs.cc
+++ b/src/oat/runtime/support_stubs.cc
@@ -18,11 +18,12 @@
 #include "callee_save_frame.h"
 #endif
 #include "class_linker-inl.h"
+#include "dex_file-inl.h"
 #include "dex_instruction.h"
 #include "mirror/class-inl.h"
 #include "mirror/abstract_method-inl.h"
-#include "mirror/object.h"
 #include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
 #include "object_utils.h"
 #if defined(ART_USE_PORTABLE_COMPILER)
 #include "nth_caller_visitor.h"
diff --git a/src/oat/runtime/x86/context_x86.cc b/src/oat/runtime/x86/context_x86.cc
index 9d930ca..338a5ae 100644
--- a/src/oat/runtime/x86/context_x86.cc
+++ b/src/oat/runtime/x86/context_x86.cc
@@ -17,6 +17,7 @@
 #include "context_x86.h"
 
 #include "mirror/abstract_method.h"
+#include "mirror/object-inl.h"
 #include "stack.h"
 
 namespace art {
diff --git a/src/oat/runtime/x86/stub_x86.cc b/src/oat/runtime/x86/stub_x86.cc
index d314031..14c9ce4 100644
--- a/src/oat/runtime/x86/stub_x86.cc
+++ b/src/oat/runtime/x86/stub_x86.cc
@@ -16,6 +16,7 @@
 
 #include "jni_internal.h"
 #include "mirror/array.h"
+#include "mirror/object-inl.h"
 #include "oat/runtime/oat_support_entrypoints.h"
 #include "oat/runtime/stub.h"
 #include "oat/utils/x86/assembler_x86.h"
diff --git a/src/oat_file.cc b/src/oat_file.cc
index 32a8a86..7f7bab9 100644
--- a/src/oat_file.cc
+++ b/src/oat_file.cc
@@ -25,6 +25,7 @@
 #include "mirror/class.h"
 #include "mirror/abstract_method.h"
 #include "mirror/abstract_method-inl.h"
+#include "mirror/object-inl.h"
 #include "os.h"
 #include "utils.h"
 
diff --git a/src/oat_writer.cc b/src/oat_writer.cc
index e299a27..622010b 100644
--- a/src/oat_writer.cc
+++ b/src/oat_writer.cc
@@ -21,9 +21,11 @@
 #include "base/stl_util.h"
 #include "base/unix_file/fd_file.h"
 #include "class_linker.h"
+#include "dex_file-inl.h"
 #include "mirror/abstract_method-inl.h"
 #include "mirror/array.h"
 #include "mirror/class_loader.h"
+#include "mirror/object-inl.h"
 #include "os.h"
 #include "output_stream.h"
 #include "safe_map.h"
diff --git a/src/oatdump.cc b/src/oatdump.cc
index c378353..7e92024 100644
--- a/src/oatdump.cc
+++ b/src/oatdump.cc
@@ -26,6 +26,7 @@
 #include "base/unix_file/fd_file.h"
 #include "class_linker.h"
 #include "class_linker-inl.h"
+#include "dex_file-inl.h"
 #include "dex_instruction.h"
 #include "disassembler.h"
 #include "gc_map.h"
diff --git a/src/object_utils.h b/src/object_utils.h
index 2c9f7a2..616c65c 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -597,7 +597,7 @@
   }
 
   bool IsReturnFloatOrDouble() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
-    const char ret_shorty = GetReturnTypeDescriptor()[0];
+    const char ret_shorty = GetShorty()[0];
     return (ret_shorty == 'F') || (ret_shorty == 'D');
   }
 
@@ -679,11 +679,11 @@
   void SetMethod(const mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
     if (method != NULL) {
       mirror::Class* klass = method->GetDeclaringClass();
-      if (klass->IsProxyClass()) {
+      if (UNLIKELY(klass->IsProxyClass())) {
         mirror::AbstractMethod* interface_method =
             method->GetDexCacheResolvedMethods()->Get(method->GetDexMethodIndex());
-        CHECK(interface_method != NULL);
-        CHECK(interface_method == GetClassLinker()->FindMethodForProxy(klass, method));
+        DCHECK(interface_method != NULL);
+        DCHECK(interface_method == GetClassLinker()->FindMethodForProxy(klass, method));
         method = interface_method;
       }
     }
diff --git a/src/reflection.cc b/src/reflection.cc
index addb5a3..6b64311 100644
--- a/src/reflection.cc
+++ b/src/reflection.cc
@@ -17,6 +17,7 @@
 #include "reflection.h"
 
 #include "class_linker.h"
+#include "dex_file-inl.h"
 #include "invoke_arg_array_builder.h"
 #include "jni_internal.h"
 #include "mirror/abstract_method.h"
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index d76999c..5b2c58c 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -17,6 +17,7 @@
 #include "runtime_support.h"
 
 #include "class_linker-inl.h"
+#include "dex_file-inl.h"
 #include "gc/card_table-inl.h"
 #include "mirror/abstract_method-inl.h"
 #include "mirror/class-inl.h"
diff --git a/src/stack.cc b/src/stack.cc
index 914e7ec4..66051f2 100644
--- a/src/stack.cc
+++ b/src/stack.cc
@@ -18,6 +18,7 @@
 
 #include "oat/runtime/context.h"
 #include "mirror/abstract_method-inl.h"
+#include "mirror/class-inl.h"
 #include "mirror/object.h"
 #include "mirror/object-inl.h"
 #include "mirror/object_array-inl.h"
diff --git a/src/thread.cc b/src/thread.cc
index bf1f7f7..a85d22a 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -34,6 +34,7 @@
 #include "cutils/atomic.h"
 #include "cutils/atomic-inline.h"
 #include "debugger.h"
+#include "dex_file-inl.h"
 #include "gc_map.h"
 #include "gc/card_table-inl.h"
 #include "heap.h"
@@ -1113,38 +1114,14 @@
   IndirectRef ref = reinterpret_cast<IndirectRef>(obj);
   IndirectRefKind kind = GetIndirectRefKind(ref);
   mirror::Object* result;
-  switch (kind) {
-  case kLocal:
-    {
-      IndirectReferenceTable& locals = jni_env_->locals;
-      result = const_cast<mirror::Object*>(locals.Get(ref));
-      break;
-    }
-  case kGlobal:
-    {
-      JavaVMExt* vm = Runtime::Current()->GetJavaVM();
-      IndirectReferenceTable& globals = vm->globals;
-      MutexLock mu(const_cast<Thread*>(this), vm->globals_lock);
-      result = const_cast<mirror::Object*>(globals.Get(ref));
-      break;
-    }
-  case kWeakGlobal:
-    {
-      JavaVMExt* vm = Runtime::Current()->GetJavaVM();
-      IndirectReferenceTable& weak_globals = vm->weak_globals;
-      MutexLock mu(const_cast<Thread*>(this), vm->weak_globals_lock);
-      result = const_cast<mirror::Object*>(weak_globals.Get(ref));
-      if (result == kClearedJniWeakGlobal) {
-        // This is a special case where it's okay to return NULL.
-        return NULL;
-      }
-      break;
-    }
-  case kSirtOrInvalid:
-  default:
+  // The "kinds" below are sorted by the frequency we expect to encounter them.
+  if (kind == kLocal) {
+    IndirectReferenceTable& locals = jni_env_->locals;
+    result = const_cast<mirror::Object*>(locals.Get(ref));
+  } else if (kind == kSirtOrInvalid) {
     // TODO: make stack indirect reference table lookup more efficient
     // Check if this is a local reference in the SIRT
-    if (SirtContains(obj)) {
+    if (LIKELY(SirtContains(obj))) {
       result = *reinterpret_cast<mirror::Object**>(obj);  // Read from SIRT
     } else if (Runtime::Current()->GetJavaVM()->work_around_app_jni_bugs) {
       // Assume an invalid local reference is actually a direct pointer.
@@ -1152,12 +1129,27 @@
     } else {
       result = kInvalidIndirectRefObject;
     }
+  } else if (kind == kGlobal) {
+    JavaVMExt* vm = Runtime::Current()->GetJavaVM();
+    IndirectReferenceTable& globals = vm->globals;
+    MutexLock mu(const_cast<Thread*>(this), vm->globals_lock);
+    result = const_cast<mirror::Object*>(globals.Get(ref));
+  } else {
+    DCHECK_EQ(kind, kWeakGlobal);
+    JavaVMExt* vm = Runtime::Current()->GetJavaVM();
+    IndirectReferenceTable& weak_globals = vm->weak_globals;
+    MutexLock mu(const_cast<Thread*>(this), vm->weak_globals_lock);
+    result = const_cast<mirror::Object*>(weak_globals.Get(ref));
+    if (result == kClearedJniWeakGlobal) {
+      // This is a special case where it's okay to return NULL.
+      return NULL;
+    }
   }
 
-  if (result == NULL) {
+  if (UNLIKELY(result == NULL)) {
     JniAbortF(NULL, "use of deleted %s %p", ToStr<IndirectRefKind>(kind).c_str(), obj);
   } else {
-    if (result != kInvalidIndirectRefObject) {
+    if (kIsDebugBuild && (result != kInvalidIndirectRefObject)) {
       Runtime::Current()->GetHeap()->VerifyObject(result);
     }
   }
diff --git a/src/trace.cc b/src/trace.cc
index 09c1d3f..859f523 100644
--- a/src/trace.cc
+++ b/src/trace.cc
@@ -21,10 +21,13 @@
 #include "base/unix_file/fd_file.h"
 #include "class_linker.h"
 #include "debugger.h"
+#include "dex_file-inl.h"
 #include "instrumentation.h"
 #include "mirror/abstract_method-inl.h"
+#include "mirror/class-inl.h"
 #include "mirror/dex_cache.h"
 #include "mirror/object_array-inl.h"
+#include "mirror/object-inl.h"
 #if !defined(ART_USE_PORTABLE_COMPILER)
 #include "oat/runtime/oat_support_entrypoints.h"
 #endif
diff --git a/src/utf.cc b/src/utf.cc
index cc7e262..8d3547e 100644
--- a/src/utf.cc
+++ b/src/utf.cc
@@ -18,6 +18,7 @@
 
 #include "base/logging.h"
 #include "mirror/array.h"
+#include "mirror/object-inl.h"
 
 namespace art {
 
diff --git a/src/utils.cc b/src/utils.cc
index 0416e37..50db7fa 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -25,8 +25,9 @@
 
 #include "UniquePtr.h"
 #include "base/unix_file/fd_file.h"
+#include "dex_file-inl.h"
 #include "mirror/abstract_method-inl.h"
-#include "mirror/class.h"
+#include "mirror/class-inl.h"
 #include "mirror/class_loader.h"
 #include "mirror/field.h"
 #include "mirror/field-inl.h"
diff --git a/src/verifier/method_verifier.cc b/src/verifier/method_verifier.cc
index fb60c90..6018bf8 100644
--- a/src/verifier/method_verifier.cc
+++ b/src/verifier/method_verifier.cc
@@ -22,7 +22,7 @@
 #include "base/stringpiece.h"
 #include "class_linker.h"
 #include "compiler/driver/compiler_driver.h"
-#include "dex_file.h"
+#include "dex_file-inl.h"
 #include "dex_instruction.h"
 #include "dex_instruction_visitor.h"
 #include "gc/card_table-inl.h"
diff --git a/src/verifier/reg_type.cc b/src/verifier/reg_type.cc
index f412581..0cca343 100644
--- a/src/verifier/reg_type.cc
+++ b/src/verifier/reg_type.cc
@@ -16,6 +16,7 @@
 
 #include "reg_type.h"
 
+#include "dex_file-inl.h"
 #include "mirror/class.h"
 #include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
diff --git a/src/verifier/reg_type_cache.cc b/src/verifier/reg_type_cache.cc
index 6ca54de..96a6c24 100644
--- a/src/verifier/reg_type_cache.cc
+++ b/src/verifier/reg_type_cache.cc
@@ -16,6 +16,7 @@
 
 #include "reg_type_cache.h"
 
+#include "dex_file-inl.h"
 #include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
 #include "object_utils.h"
diff --git a/test/ReferenceMap/stack_walk_refmap_jni.cc b/test/ReferenceMap/stack_walk_refmap_jni.cc
index 59284f4..9ef4a59 100644
--- a/test/ReferenceMap/stack_walk_refmap_jni.cc
+++ b/test/ReferenceMap/stack_walk_refmap_jni.cc
@@ -18,9 +18,11 @@
 
 #include "UniquePtr.h"
 #include "class_linker.h"
+#include "dex_file-inl.h"
 #include "gc_map.h"
 #include "mirror/abstract_method.h"
 #include "mirror/abstract_method-inl.h"
+#include "mirror/class-inl.h"
 #include "mirror/object_array-inl.h"
 #include "object_utils.h"
 #include "scoped_thread_state_change.h"