summaryrefslogtreecommitdiffstats
path: root/runtime/mirror/array.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/mirror/array.cc')
-rw-r--r--runtime/mirror/array.cc38
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;
}