From 0f6af5e3b51a7f5905d09a98ec8d531541666015 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 30 Jan 2023 14:29:11 +0000 Subject: Reland "Write classes in runtime-generated app image." This reverts commit 24b3d648ff6c2c200003f55ac63fc910d7bfd40f. Bug: 260557058 Reason for revert: - Encode class loader context in image, and check it at load time. - Set nterp entrypoint to methods that can. Test: test.py Test: atest com.android.bluetooth.opp.BluetoothOppObexServerSessionTest#onPut_withUnsupportedMimeTypeInHeader_returnsHttpBadRequest Change-Id: Ibf4a8604c4a226d1acc021103668e211446bb53c --- runtime/mirror/array-inl.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'runtime/mirror/array-inl.h') diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h index a7faa376cd..2bdf8277cd 100644 --- a/runtime/mirror/array-inl.h +++ b/runtime/mirror/array-inl.h @@ -240,13 +240,16 @@ 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, 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(AsLongArrayUnchecked()->GetWithoutChecks(idx)); + static_cast(reinterpret_cast(this)->GetWithoutChecks(idx)); return (T) dchecked_integral_cast(value); } else { uint32_t value = - static_cast(AsIntArrayUnchecked()->GetWithoutChecks(idx)); + static_cast(reinterpret_cast(this)->GetWithoutChecks(idx)); return (T) dchecked_integral_cast(value); } } @@ -261,12 +264,15 @@ inline T PointerArray::GetElementPtrSize(uint32_t idx, PointerSize ptr_size) { template 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 ? ObjPtr::DownCast(ObjPtr(this)) : AsLongArray())-> + (kUnchecked ? reinterpret_cast(this) : AsLongArray().Ptr())-> SetWithoutChecks(idx, element); } else { uint32_t element32 = dchecked_integral_cast(element); - (kUnchecked ? ObjPtr::DownCast(ObjPtr(this)) : AsIntArray()) + (kUnchecked ? reinterpret_cast(this) : AsIntArray().Ptr()) ->SetWithoutChecks(idx, element32); } } @@ -278,7 +284,7 @@ inline void PointerArray::SetElementPtrSize(uint32_t idx, T* element, PointerSiz } template -inline void PointerArray::Fixup(ObjPtr dest, +inline void PointerArray::Fixup(mirror::PointerArray* dest, PointerSize pointer_size, const Visitor& visitor) { for (size_t i = 0, count = GetLength(); i < count; ++i) { -- cgit v1.2.3-59-g8ed1b