From e159a3bce2dc2dda37127592e8f0b39c377e05ec Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 30 Sep 2024 09:04:41 +0000 Subject: Revert^5 "Object.clone() allocates more movable objects" This reverts commit ea269f69d05fe333e4b36634b925c3c40fc8ce95. Bug: 355291033 Bug: 354087169 Bug: 360363656 Bug: 361327909 Bug: 364629185 Reason for revert: Failure on asan: +addressOf succeeded on movable object +Unexpectedly got 0 address in checkMovable Change-Id: I1f27845bf3fb7a1542f24b943d999f2d4da5e23a --- runtime/mirror/object_array-alloc-inl.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime/mirror/object_array-alloc-inl.h') diff --git a/runtime/mirror/object_array-alloc-inl.h b/runtime/mirror/object_array-alloc-inl.h index d3688762a4..e79d154f84 100644 --- a/runtime/mirror/object_array-alloc-inl.h +++ b/runtime/mirror/object_array-alloc-inl.h @@ -66,8 +66,9 @@ inline ObjPtr> ObjectArray::CopyOf(Handle> h_th int32_t new_length) { DCHECK_GE(new_length, 0); gc::Heap* heap = Runtime::Current()->GetHeap(); - DCHECK(heap->PossiblyAllocatedMovable(h_this.Get())); - gc::AllocatorType allocator_type = heap->GetCurrentAllocator(); + gc::AllocatorType allocator_type = heap->IsMovableObject(h_this.Get()) + ? heap->GetCurrentAllocator() + : heap->GetCurrentNonMovingAllocator(); ObjPtr> new_array = Alloc(self, h_this->GetClass(), new_length, allocator_type); if (LIKELY(new_array != nullptr)) { new_array->AssignableMemcpy(0, h_this.Get(), 0, std::min(h_this->GetLength(), new_length)); -- cgit v1.2.3-59-g8ed1b