diff options
Diffstat (limited to 'runtime/mirror/array-inl.h')
| -rw-r--r-- | runtime/mirror/array-inl.h | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h index 2bdf8277cd..a7faa376cd 100644 --- a/runtime/mirror/array-inl.h +++ b/runtime/mirror/array-inl.h @@ -240,16 +240,13 @@ inline T PointerArray::GetElementPtrSizeUnchecked(uint32_t idx) { // C style casts here since we sometimes have T be a pointer, or sometimes an integer // (for stack traces). using ConversionType = typename std::conditional_t<std::is_pointer_v<T>, uintptr_t, T>; - // Note: we cast the array directly when unchecked as this code gets called by - // runtime_image, which can pass a 64bit pointer and therefore cannot be held - // by an ObjPtr. if (kPointerSize == PointerSize::k64) { uint64_t value = - static_cast<uint64_t>(reinterpret_cast<LongArray*>(this)->GetWithoutChecks(idx)); + static_cast<uint64_t>(AsLongArrayUnchecked<kVerifyFlags>()->GetWithoutChecks(idx)); return (T) dchecked_integral_cast<ConversionType>(value); } else { uint32_t value = - static_cast<uint32_t>(reinterpret_cast<IntArray*>(this)->GetWithoutChecks(idx)); + static_cast<uint32_t>(AsIntArrayUnchecked<kVerifyFlags>()->GetWithoutChecks(idx)); return (T) dchecked_integral_cast<ConversionType>(value); } } @@ -264,15 +261,12 @@ inline T PointerArray::GetElementPtrSize(uint32_t idx, PointerSize ptr_size) { template<bool kTransactionActive, bool kCheckTransaction, bool kUnchecked> inline void PointerArray::SetElementPtrSize(uint32_t idx, uint64_t element, PointerSize ptr_size) { - // Note: we cast the array directly when unchecked as this code gets called by - // runtime_image, which can pass a 64bit pointer and therefore cannot be held - // by an ObjPtr. if (ptr_size == PointerSize::k64) { - (kUnchecked ? reinterpret_cast<LongArray*>(this) : AsLongArray().Ptr())-> + (kUnchecked ? ObjPtr<LongArray>::DownCast(ObjPtr<Object>(this)) : AsLongArray())-> SetWithoutChecks<kTransactionActive, kCheckTransaction>(idx, element); } else { uint32_t element32 = dchecked_integral_cast<uint32_t>(element); - (kUnchecked ? reinterpret_cast<IntArray*>(this) : AsIntArray().Ptr()) + (kUnchecked ? ObjPtr<IntArray>::DownCast(ObjPtr<Object>(this)) : AsIntArray()) ->SetWithoutChecks<kTransactionActive, kCheckTransaction>(idx, element32); } } @@ -284,7 +278,7 @@ inline void PointerArray::SetElementPtrSize(uint32_t idx, T* element, PointerSiz } template <VerifyObjectFlags kVerifyFlags, typename Visitor> -inline void PointerArray::Fixup(mirror::PointerArray* dest, +inline void PointerArray::Fixup(ObjPtr<mirror::PointerArray> dest, PointerSize pointer_size, const Visitor& visitor) { for (size_t i = 0, count = GetLength(); i < count; ++i) { |