diff options
| author | 2014-05-07 15:43:14 -0700 | |
|---|---|---|
| committer | 2014-05-13 14:45:54 -0700 | |
| commit | eb8167a4f4d27fce0530f6724ab8032610cd146b (patch) | |
| tree | bcfeaf13ad78f2dd68466bbd0e20c71944f7e854 /runtime/mirror/array.cc | |
| parent | 6fb66a2bc4e1c0b7931101153e58714991237af7 (diff) | |
Add Handle/HandleScope and delete SirtRef.
Delete SirtRef and replaced it with Handle. Handles are value types
which wrap around StackReference*.
Renamed StackIndirectReferenceTable to HandleScope.
Added a scoped handle wrapper which wraps around an Object** and
restores it in its destructor.
Renamed Handle::get -> Get.
Bug: 8473721
Change-Id: Idbfebd4f35af629f0f43931b7c5184b334822c7a
Diffstat (limited to 'runtime/mirror/array.cc')
| -rw-r--r-- | runtime/mirror/array.cc | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/runtime/mirror/array.cc b/runtime/mirror/array.cc index 139e2d030a..552652cd24 100644 --- a/runtime/mirror/array.cc +++ b/runtime/mirror/array.cc @@ -26,7 +26,7 @@ #include "object_array.h" #include "object_array-inl.h" #include "object_utils.h" -#include "sirt_ref.h" +#include "handle_scope-inl.h" #include "thread.h" #include "utils.h" @@ -42,22 +42,25 @@ namespace mirror { // Recursively create an array with multiple dimensions. Elements may be // Objects or primitive types. static Array* RecursiveCreateMultiArray(Thread* self, - const SirtRef<Class>& array_class, int current_dimension, - const SirtRef<mirror::IntArray>& dimensions) + const Handle<Class>& array_class, int current_dimension, + const Handle<mirror::IntArray>& dimensions) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { int32_t array_length = dimensions->Get(current_dimension); - SirtRef<Array> new_array(self, Array::Alloc<true>(self, array_class.get(), array_length, - array_class->GetComponentSize(), - Runtime::Current()->GetHeap()->GetCurrentAllocator())); - if (UNLIKELY(new_array.get() == nullptr)) { + StackHandleScope<1> hs(self); + Handle<Array> new_array( + hs.NewHandle( + Array::Alloc<true>(self, array_class.Get(), array_length, array_class->GetComponentSize(), + Runtime::Current()->GetHeap()->GetCurrentAllocator()))); + if (UNLIKELY(new_array.Get() == nullptr)) { CHECK(self->IsExceptionPending()); return nullptr; } if (current_dimension + 1 < dimensions->GetLength()) { // Create a new sub-array in every element of the array. for (int32_t i = 0; i < array_length; i++) { - SirtRef<mirror::Class> sirt_component_type(self, array_class->GetComponentType()); - Array* sub_array = RecursiveCreateMultiArray(self, sirt_component_type, + StackHandleScope<1> hs(self); + Handle<mirror::Class> h_component_type(hs.NewHandle(array_class->GetComponentType())); + Array* sub_array = RecursiveCreateMultiArray(self, h_component_type, current_dimension + 1, dimensions); if (UNLIKELY(sub_array == nullptr)) { CHECK(self->IsExceptionPending()); @@ -67,11 +70,11 @@ static Array* RecursiveCreateMultiArray(Thread* self, new_array->AsObjectArray<Array>()->Set<false, false>(i, sub_array); } } - return new_array.get(); + return new_array.Get(); } -Array* Array::CreateMultiArray(Thread* self, const SirtRef<Class>& element_class, - const SirtRef<IntArray>& dimensions) { +Array* Array::CreateMultiArray(Thread* self, const Handle<Class>& element_class, + const Handle<IntArray>& dimensions) { // Verify dimensions. // // The caller is responsible for verifying that "dimArray" is non-null @@ -90,15 +93,16 @@ Array* Array::CreateMultiArray(Thread* self, const SirtRef<Class>& element_class // Find/generate the array class. ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - SirtRef<mirror::Class> array_class(self, - class_linker->FindArrayClass(self, element_class.get())); - if (UNLIKELY(array_class.get() == nullptr)) { + StackHandleScope<1> hs(self); + Handle<mirror::Class> array_class( + hs.NewHandle(class_linker->FindArrayClass(self, element_class.Get()))); + if (UNLIKELY(array_class.Get() == nullptr)) { CHECK(self->IsExceptionPending()); return nullptr; } for (int32_t i = 1; i < dimensions->GetLength(); ++i) { - array_class.reset(class_linker->FindArrayClass(self, array_class.get())); - if (UNLIKELY(array_class.get() == nullptr)) { + array_class.Assign(class_linker->FindArrayClass(self, array_class.Get())); + if (UNLIKELY(array_class.Get() == nullptr)) { CHECK(self->IsExceptionPending()); return nullptr; } |