diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dex_file.h | 9 | ||||
| -rw-r--r-- | src/oat/runtime/arm/runtime_support_arm.S | 2 | ||||
| -rw-r--r-- | src/oat/runtime/mips/runtime_support_mips.S | 2 | ||||
| -rw-r--r-- | src/oat/runtime/support_fillarray.cc | 18 |
4 files changed, 20 insertions, 11 deletions
diff --git a/src/dex_file.h b/src/dex_file.h index 9c16440992..70c205930e 100644 --- a/src/dex_file.h +++ b/src/dex_file.h @@ -307,6 +307,15 @@ class DexFile { DISALLOW_COPY_AND_ASSIGN(AnnotationItem); }; + struct PACKED Payload { + uint16_t ident; // kPackedSwitchSignature, kSparseSwitchSignature, or kArrayDataSignature. + uint16_t element_width; + uint32_t element_count; + uint8_t data[]; + private: + DISALLOW_COPY_AND_ASSIGN(Payload); + }; + typedef std::pair<const DexFile*, const DexFile::ClassDef*> ClassPathEntry; typedef std::vector<const DexFile*> ClassPath; diff --git a/src/oat/runtime/arm/runtime_support_arm.S b/src/oat/runtime/arm/runtime_support_arm.S index 2ef162ebf0..638a7c31b5 100644 --- a/src/oat/runtime/arm/runtime_support_arm.S +++ b/src/oat/runtime/arm/runtime_support_arm.S @@ -254,7 +254,7 @@ art_handle_fill_data_from_code: SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP - bl artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table, Thread*, SP) + bl artHandleFillArrayDataFromCode @ (Array*, const DexFile::Payload*, Thread*, SP) RESTORE_REF_ONLY_CALLEE_SAVE_FRAME cmp r0, #0 @ success? bxeq lr @ return on success diff --git a/src/oat/runtime/mips/runtime_support_mips.S b/src/oat/runtime/mips/runtime_support_mips.S index 9b082bf84e..d4e87c0f2e 100644 --- a/src/oat/runtime/mips/runtime_support_mips.S +++ b/src/oat/runtime/mips/runtime_support_mips.S @@ -416,7 +416,7 @@ art_work_around_app_jni_bugs: art_handle_fill_data_from_code: SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC move a2, rSELF @ pass Thread::Current - jal artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table, Thread*, SP) + jal artHandleFillArrayDataFromCode @ (Array*, const DexFile::Payload*, Thread*, SP) move a3, sp @ pass SP RESTORE_REF_ONLY_CALLEE_SAVE_FRAME bnez v0, 1f @ success? diff --git a/src/oat/runtime/support_fillarray.cc b/src/oat/runtime/support_fillarray.cc index eb1c46c67d..6f40177713 100644 --- a/src/oat/runtime/support_fillarray.cc +++ b/src/oat/runtime/support_fillarray.cc @@ -15,6 +15,7 @@ */ #include "callee_save_frame.h" +#include "dex_instruction.h" #include "object.h" namespace art { @@ -34,25 +35,24 @@ namespace art { * ubyte data[size*width] table of data values (may contain a single-byte * padding at the end) */ -extern "C" int artHandleFillArrayDataFromCode(Array* array, const uint16_t* table, +extern "C" int artHandleFillArrayDataFromCode(Array* array, const DexFile::Payload* payload, Thread* self, Method** sp) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - DCHECK_EQ(table[0], 0x0300); + DCHECK_EQ(payload->ident, static_cast<uint16_t>(Instruction::kArrayDataSignature)); if (UNLIKELY(array == NULL)) { Thread::Current()->ThrowNewExceptionF("Ljava/lang/NullPointerException;", - "null array in fill array"); + "null array in FILL_ARRAY_DATA"); return -1; // Error } DCHECK(array->IsArrayInstance() && !array->IsObjectArray()); - uint32_t size = (uint32_t)table[2] | (((uint32_t)table[3]) << 16); - if (UNLIKELY(static_cast<int32_t>(size) > array->GetLength())) { + if (UNLIKELY(static_cast<int32_t>(payload->element_count) > array->GetLength())) { Thread::Current()->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;", - "failed array fill. length=%d; index=%d", array->GetLength(), size); + "failed FILL_ARRAY_DATA; length=%d, index=%d", + array->GetLength(), payload->element_count); return -1; // Error } - uint16_t width = table[1]; - uint32_t size_in_bytes = size * width; - memcpy((char*)array + Array::DataOffset(width).Int32Value(), (char*)&table[4], size_in_bytes); + uint32_t size_in_bytes = payload->element_count * payload->element_width; + memcpy(array->GetRawData(payload->element_width), payload->data, size_in_bytes); return 0; // Success } |