summaryrefslogtreecommitdiff
path: root/runtime/mirror/array-inl.h
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2019-02-01 09:34:43 -0800
committer Andreas Gampe <agampe@google.com> 2019-02-05 08:00:37 -0800
commita2fed081e33bcc956ebc545aacd654ec6a32673d (patch)
tree13e1fc19a737dff8cd416725bce6329086516c99 /runtime/mirror/array-inl.h
parent2860c19944b64c581a8af63339805409c0584d2f (diff)
ART: Optimize array accesses
Optimize computation of the data offset of arrays by adding a constant for the array payload field offset, and templatized versions of the computation. Add a correctness check on runtime creation. Templatize CheckVTableHasNoDuplicates. Decreases dex2oatd preopting of a big app from 165s to 151s. Bug: 123888325 Test: m test-art-host Change-Id: I8db9df545dc807a307aef8af7dad7a15757670b1
Diffstat (limited to 'runtime/mirror/array-inl.h')
-rw-r--r--runtime/mirror/array-inl.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h
index a6a5ba298c..40507e7aee 100644
--- a/runtime/mirror/array-inl.h
+++ b/runtime/mirror/array-inl.h
@@ -224,14 +224,23 @@ inline void PrimitiveArray<T>::Memcpy(int32_t dst_pos,
}
}
+template<typename T, PointerSize kPointerSize, VerifyObjectFlags kVerifyFlags>
+inline T PointerArray::GetElementPtrSize(uint32_t idx) {
+ // C style casts here since we sometimes have T be a pointer, or sometimes an integer
+ // (for stack traces).
+ if (kPointerSize == PointerSize::k64) {
+ return (T)static_cast<uintptr_t>(AsLongArray<kVerifyFlags>()->GetWithoutChecks(idx));
+ }
+ return (T)static_cast<uintptr_t>(AsIntArray<kVerifyFlags>()->GetWithoutChecks(idx));
+}
template<typename T, VerifyObjectFlags kVerifyFlags>
inline T PointerArray::GetElementPtrSize(uint32_t idx, PointerSize ptr_size) {
// C style casts here since we sometimes have T be a pointer, or sometimes an integer
// (for stack traces).
if (ptr_size == PointerSize::k64) {
- return (T)static_cast<uintptr_t>(AsLongArray<kVerifyFlags>()->GetWithoutChecks(idx));
+ return GetElementPtrSize<T, PointerSize::k64, kVerifyFlags>(idx);
}
- return (T)static_cast<uintptr_t>(AsIntArray<kVerifyFlags>()->GetWithoutChecks(idx));
+ return GetElementPtrSize<T, PointerSize::k32, kVerifyFlags>(idx);
}
template<bool kTransactionActive, bool kUnchecked>