From 3068d582eff4552ff260d7966fcbdc93e17d0207 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 28 May 2019 16:39:29 +0100 Subject: Clean up creating handles from `this`. Make these member functions static and take an additional parameter `Handle<.> h_this`. Callers mostly already have a Handle<> to pass, so we avoid an extra StackHandleScope. This pattern was already used for some functions. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --interpreter Change-Id: I4f4478b0526bcb2f3c23305d3b3cc4a65fff9ff5 --- runtime/mirror/object_array-alloc-inl.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 b417b62b11..594b0a6346 100644 --- a/runtime/mirror/object_array-alloc-inl.h +++ b/runtime/mirror/object_array-alloc-inl.h @@ -61,15 +61,15 @@ inline ObjPtr> ObjectArray::Alloc(Thread* self, } template -inline ObjPtr> ObjectArray::CopyOf(Thread* self, int32_t new_length) { +inline ObjPtr> ObjectArray::CopyOf(Handle> h_this, + Thread* self, + int32_t new_length) { DCHECK_GE(new_length, 0); - // We may get copied by a compacting GC. - StackHandleScope<1> hs(self); - Handle> h_this(hs.NewHandle(this)); gc::Heap* heap = Runtime::Current()->GetHeap(); - gc::AllocatorType allocator_type = heap->IsMovableObject(this) ? heap->GetCurrentAllocator() : - heap->GetCurrentNonMovingAllocator(); - ObjPtr> new_array = Alloc(self, GetClass(), new_length, allocator_type); + 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