summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ian Rogers <irogers@google.com> 2013-03-18 15:27:28 -0700
committer Ian Rogers <irogers@google.com> 2013-03-18 15:29:59 -0700
commit4f6ad8ab428038129b2d0d6c40b7fd625cca15e1 (patch)
treed1025ed9203d0cdf7aa959d9cecd8dc1f0c0bfeb
parentaabe8adacc7bf3a8ab6f6f3dd37fc839b6fd762f (diff)
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
-rw-r--r--src/check_jni.cc1
-rw-r--r--src/class_linker.cc2
-rw-r--r--src/common_test.h2
-rw-r--r--src/common_throws.cc2
-rw-r--r--src/compiler/dex/compiler_utility.cc1
-rw-r--r--src/compiler/dex/frontend.cc1
-rw-r--r--src/compiler/dex/quick/codegen_util.cc1
-rw-r--r--src/compiler/driver/compiler_driver.cc11
-rw-r--r--src/compiler/driver/compiler_driver.h1
-rw-r--r--src/compiler/jni/jni_compiler_test.cc2
-rw-r--r--src/compiler/jni/portable/jni_compiler.cc1
-rw-r--r--src/compiler/jni/quick/jni_compiler.cc1
-rw-r--r--src/compiler/llvm/gbc_expander.cc1
-rw-r--r--src/compiler/llvm/runtime_support_llvm.cc2
-rw-r--r--src/debugger.cc1
-rw-r--r--src/dex2oat.cc1
-rw-r--r--src/dex_file-inl.h47
-rw-r--r--src/dex_file.cc20
-rw-r--r--src/dex_file.h22
-rw-r--r--src/dex_file_verifier.cc1
-rw-r--r--src/dex_instruction.cc2
-rw-r--r--src/exception_test.cc1
-rw-r--r--src/gc/space.cc2
-rw-r--r--src/gc/space_bitmap.cc1
-rw-r--r--src/hprof/hprof.cc1
-rw-r--r--src/image.cc1
-rw-r--r--src/image_writer.cc1
-rw-r--r--src/indirect_reference_table.cc12
-rw-r--r--src/instrumentation.cc1
-rw-r--r--src/interpreter/interpreter.cc1
-rw-r--r--src/jni_internal.cc1
-rw-r--r--src/jni_internal_test.cc1
-rw-r--r--src/jobject_comparator.cc2
-rw-r--r--src/mirror/abstract_method-inl.h23
-rw-r--r--src/mirror/abstract_method.cc24
-rw-r--r--src/mirror/array.cc1
-rw-r--r--src/mirror/class-inl.h14
-rw-r--r--src/mirror/class.cc9
-rw-r--r--src/mirror/object-inl.h6
-rw-r--r--src/mirror/object.h2
-rw-r--r--src/mirror/throwable.cc1
-rw-r--r--src/monitor.cc2
-rw-r--r--src/native/dalvik_system_DexFile.cc2
-rw-r--r--src/native/dalvik_system_VMRuntime.cc2
-rw-r--r--src/native/dalvik_system_VMStack.cc3
-rw-r--r--src/native/java_lang_Class.cc3
-rw-r--r--src/native/java_lang_VMClassLoader.cc1
-rw-r--r--src/native/java_lang_reflect_Array.cc3
-rw-r--r--src/native/java_lang_reflect_Field.cc2
-rw-r--r--src/oat.cc5
-rw-r--r--src/oat.h5
-rw-r--r--src/oat/runtime/arm/context_arm.cc6
-rw-r--r--src/oat/runtime/arm/stub_arm.cc1
-rw-r--r--src/oat/runtime/mips/stub_mips.cc1
-rw-r--r--src/oat/runtime/support_alloc.cc1
-rw-r--r--src/oat/runtime/support_deoptimize.cc3
-rw-r--r--src/oat/runtime/support_dexcache.cc1
-rw-r--r--src/oat/runtime/support_field.cc1
-rw-r--r--src/oat/runtime/support_interpreter.cc4
-rw-r--r--src/oat/runtime/support_jni.cc1
-rw-r--r--src/oat/runtime/support_proxy.cc3
-rw-r--r--src/oat/runtime/support_stubs.cc3
-rw-r--r--src/oat/runtime/x86/context_x86.cc1
-rw-r--r--src/oat/runtime/x86/stub_x86.cc1
-rw-r--r--src/oat_file.cc1
-rw-r--r--src/oat_writer.cc2
-rw-r--r--src/oatdump.cc1
-rw-r--r--src/object_utils.h8
-rw-r--r--src/reflection.cc1
-rw-r--r--src/runtime_support.cc1
-rw-r--r--src/stack.cc1
-rw-r--r--src/thread.cc56
-rw-r--r--src/trace.cc3
-rw-r--r--src/utf.cc1
-rw-r--r--src/utils.cc3
-rw-r--r--src/verifier/method_verifier.cc2
-rw-r--r--src/verifier/reg_type.cc1
-rw-r--r--src/verifier/reg_type_cache.cc1
-rw-r--r--test/ReferenceMap/stack_walk_refmap_jni.cc2
79 files changed, 232 insertions, 135 deletions
diff --git a/src/check_jni.cc b/src/check_jni.cc
index c6a628f2a1..57ce43265e 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 725e710a89..76b31776fd 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 62e75614e9..368e4a7a5c 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 734d544bd2..8673d11894 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 b5185b00e6..9dc90ce311 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 5b8faf4551..0d3cb2e4c6 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 110146fbb4..24955f68b6 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 9ed763cdfd..cc170312e0 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 @@ bool CompilerDriver::ComputeStaticFieldInfo(uint32_t field_idx, const DexCompila
}
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 @@ void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType type, InvokeType s
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 @@ bool CompilerDriver::ComputeInvokeInfo(uint32_t method_idx, const DexCompilation
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 54a2f55b74..139bcd1bfa 100644
--- a/src/compiler/driver/compiler_driver.h
+++ b/src/compiler/driver/compiler_driver.h
@@ -277,6 +277,7 @@ class CompilerDriver {
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 6c9a6dfda1..ef532f2310 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 8495150c1e..ecc1eb75ae 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 c4919fbc6f..3b85384446 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 559ce4c8cb..9b71694a09 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 b18eefe562..d9b879afbd 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 09c930a374..a2ebddf2a2 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 5c6b35ea84..2f9d579d2d 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 0000000000..5d8216eda5
--- /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 12c11e8c91..8b87ee7c30 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 @@ uint32_t DexFile::GetVersion() const {
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 @@ int32_t DexFile::GetLineNumFromPC(const mirror::AbstractMethod* method, uint32_t
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 14b4ba0b68..2da3e32552 100644
--- a/src/dex_file.h
+++ b/src/dex_file.h
@@ -379,7 +379,7 @@ class DexFile {
jobject GetDexObject(JNIEnv* env) const;
const Header& GetHeader() const {
- CHECK(header_ != NULL) << GetLocation();
+ DCHECK(header_ != NULL) << GetLocation();
return *header_;
}
@@ -394,13 +394,13 @@ class DexFile {
// 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 @@ class DexFile {
// 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 @@ class DexFile {
// 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 @@ class DexFile {
// 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 @@ class DexFile {
}
// 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 @@ class DexFile {
// 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 2f9054e414..b1efcaadbd 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 55f6eca326..3224d77a46 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 1b4332f313..0cd8123953 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 9c71841a55..e618f07e5f 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 d90c090187..773aa1e707 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 e0a4c05402..8f691f0e57 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 8eeb772a5d..d6bf6354fc 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 ad2c9b727d..a56a4aacee 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 720380a2eb..0287d745c5 100644
--- a/src/indirect_reference_table.cc
+++ b/src/indirect_reference_table.cc
@@ -65,7 +65,7 @@ IndirectReferenceTable::~IndirectReferenceTable() {
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 @@ void IndirectReferenceTable::AssertEmpty() {
// 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 @@ bool IndirectReferenceTable::GetChecked(IndirectRef iref) const {
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 33f24950dc..81fe63777f 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 1a571ecab1..3564497412 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 9cf12e084a..344ce78e14 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 5f7a6c8337..5ef22814e7 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 738a186874..e22d75f941 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 efb7c03300..e14cce2e01 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 @@ inline uint32_t AbstractMethod::GetDexMethodIndex() const {
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 e185c9cb0a..c0c9a5558c 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 @@ void AbstractMethod::ResetClasses() {
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 103efa36b5..d0b3838525 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 3ca4c3023c..ec92c199ee 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 art {
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 @@ inline Class* Class::GetSuperClass() const {
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 e3347a88f4..f4d87a4ab1 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 @@ void Class::SetStatus(Status new_status) {
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 @@ bool Class::IsMethodClass() const {
}
-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 3913c817ee..1a91dd3e6f 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::WriteBarrierField(const Object* dst, MemberOffset field_offs
}
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 0cce8d8eee..71b628db52 100644
--- a/src/mirror/object.h
+++ b/src/mirror/object.h
@@ -233,7 +233,7 @@ class MANAGED Object {
}
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 bbab1dd60d..d1192b0728 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 b4c3964bb4..2377734a2d 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 0390703914..7c6fbd9234 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 4c6777a607..a13d07a0d3 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 bb2ed8889d..1a80d6286b 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 dded787214..72f4c18244 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 02b7c25523..c23b08ca66 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 2833cb09cb..af7a77a0d3 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 9a2671c167..922fe00b29 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 145abc612d..479339ab71 100644
--- a/src/oat.cc
+++ b/src/oat.cc
@@ -74,11 +74,6 @@ const char* OatHeader::GetMagic() const {
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 b4747d4bd4..2ad44c0827 100644
--- a/src/oat.h
+++ b/src/oat.h
@@ -38,7 +38,10 @@ class PACKED(4) OatHeader {
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 814e649ac2..7b45bc2a7d 100644
--- a/src/oat/runtime/arm/context_arm.cc
+++ b/src/oat/runtime/arm/context_arm.cc
@@ -70,9 +70,9 @@ void ArmContext::FillCalleeSaves(const StackVisitor& fr) {
}
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 9091928d19..33354bd97a 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 1b5e6cc5ee..60ec9de0fb 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 5e3af78c94..f66fc848d5 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 c77d034c0d..2cc5dd36d7 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 da15917ed8..6811d20c97 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 a564fa95df..43d5c9bcce 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 a02ef2719a..7f413c350a 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 6799159fdc..ee19d4e969 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 65e404ab55..040a701e1d 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 1807a3daa2..25d7cd27f5 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 9d930ca5a8..338a5ae2ed 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 d3140317b4..14c9ce4ae9 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 32a8a861e1..7f7bab98af 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 e299a2757b..622010bd8b 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 c378353167..7e920249a2 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 2c9f7a2c53..616c65c1e8 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -597,7 +597,7 @@ class MethodHelper {
}
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 @@ class MethodHelper {
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 addb5a3f1a..6b643110db 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 d76999c5e2..5b2c58c55c 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 914e7ec403..66051f2287 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 bf1f7f7b24..a85d22ac01 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 @@ mirror::Object* Thread::DecodeJObject(jobject obj) const {
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 @@ mirror::Object* Thread::DecodeJObject(jobject obj) const {
} 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 09c1d3f898..859f523ef0 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 cc7e2629db..8d3547e70c 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 0416e37d41..50db7fa33a 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 fb60c904a1..6018bf88b6 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 f4125812eb..0cca343612 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 6ca54dea9a..96a6c24b24 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 59284f43cb..9ef4a59dc1 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"