From 104883b04617a850adf11f05e57c2fd29e09c83c Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 9 Nov 2018 17:12:23 +0000 Subject: Clean up primitive array helpers in Object. Refactor these helpers and avoid read barriers. Remove Class::Is{Int,Long}ArrayClass() and use the Object helpers instead. Remove the AsByteSizedArray() and AsShortSizedArray() helpers that essentially break the type system and rewrite their users, adding appropriate notes. {Float,Double}Array uses in Unsafe would have previously failed a DCHECK(). Test: Additional test in 004-UnsafeTest. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I88b7e3df7de883f64cfc5eb437a40646f2884685 --- runtime/mirror/array-inl.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'runtime/mirror/array-inl.h') diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h index 442733234b..a6a5ba298c 100644 --- a/runtime/mirror/array-inl.h +++ b/runtime/mirror/array-inl.h @@ -224,16 +224,14 @@ inline void PrimitiveArray::Memcpy(int32_t dst_pos, } } -template +template 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( - AsLongArray()->GetWithoutChecks(idx)); + return (T)static_cast(AsLongArray()->GetWithoutChecks(idx)); } - return (T)static_cast(static_cast( - AsIntArray()->GetWithoutChecks(idx))); + return (T)static_cast(AsIntArray()->GetWithoutChecks(idx)); } template @@ -255,12 +253,12 @@ inline void PointerArray::SetElementPtrSize(uint32_t idx, T* element, PointerSiz ptr_size); } -template +template inline void PointerArray::Fixup(mirror::PointerArray* dest, PointerSize pointer_size, const Visitor& visitor) { for (size_t i = 0, count = GetLength(); i < count; ++i) { - void* ptr = GetElementPtrSize(i, pointer_size); + void* ptr = GetElementPtrSize(i, pointer_size); void* new_ptr = visitor(ptr); if (ptr != new_ptr) { dest->SetElementPtrSize(i, new_ptr, pointer_size); -- cgit v1.2.3-59-g8ed1b