From 832336b3c9eb892045a8de1bb12c9361112ca3c5 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 8 Oct 2014 15:35:22 -0700 Subject: Don't copy fill array data to quick literal pool. Currently quick copies the fill array data from the dex file to the literal pool. It then has to go through hoops to pass this PC relative address down to out-of-line code. Instead, pass the offset of the table to the out-of-line code and use the CodeItem data associated with the ArtMethod. This reduces the size of oat code while greatly simplifying it. Unify the FillArrayData implementation in quick, portable and the interpreters. Change-Id: I9c6971cf46285fbf197856627368c0185fdc98ca --- runtime/entrypoints/entrypoint_utils.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'runtime/entrypoints/entrypoint_utils.cc') diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc index 835d6e2b7e..7b90339b68 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -344,4 +344,28 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessAlreadyRunnable& soa, cons return zero; } } + +bool FillArrayData(mirror::Object* obj, const Instruction::ArrayDataPayload* payload) { + DCHECK_EQ(payload->ident, static_cast(Instruction::kArrayDataSignature)); + if (UNLIKELY(obj == nullptr)) { + ThrowNullPointerException(nullptr, "null array in FILL_ARRAY_DATA"); + return false; + } + mirror::Array* array = obj->AsArray(); + DCHECK(!array->IsObjectArray()); + if (UNLIKELY(static_cast(payload->element_count) > array->GetLength())) { + Thread* self = Thread::Current(); + ThrowLocation throw_location = self->GetCurrentLocationForThrow(); + self->ThrowNewExceptionF(throw_location, + "Ljava/lang/ArrayIndexOutOfBoundsException;", + "failed FILL_ARRAY_DATA; length=%d, index=%d", + array->GetLength(), payload->element_count); + return false; + } + // Copy data from dex file to memory assuming both are little endian. + uint32_t size_in_bytes = payload->element_count * payload->element_width; + memcpy(array->GetRawData(payload->element_width, 0), payload->data, size_in_bytes); + return true; +} + } // namespace art -- cgit v1.2.3-59-g8ed1b