Change to implement fill-array-data with runtime function.
We can get the array data payload from the DexFile, thus
we don't have to duplicate it in the ELF image. As the
result we can reduce the size of the Oat file.
Change-Id: I08e241a43e2d7fb1b20638da68b5dfae61b120bb
diff --git a/src/compiler_llvm/runtime_support_llvm.cc b/src/compiler_llvm/runtime_support_llvm.cc
index bdfd222..d0f6e8c 100644
--- a/src/compiler_llvm/runtime_support_llvm.cc
+++ b/src/compiler_llvm/runtime_support_llvm.cc
@@ -15,6 +15,8 @@
*/
#include "class_linker.h"
+#include "dex_file.h"
+#include "dex_instruction.h"
#include "nth_caller_visitor.h"
#include "object.h"
#include "object_utils.h"
@@ -496,6 +498,42 @@
return thread->DecodeJObject(obj);
}
+void art_fill_array_data_from_code(Method* method, uint32_t dex_pc,
+ Array* array, uint32_t payload_offset) {
+ // Test: Is array equal to null? (Guard NullPointerException)
+ if (UNLIKELY(array == NULL)) {
+ art_throw_null_pointer_exception_from_code(dex_pc);
+ return;
+ }
+
+ // Find the payload from the CodeItem
+ MethodHelper mh(method);
+ const DexFile::CodeItem* code_item = mh.GetCodeItem();
+
+ DCHECK_GT(code_item->insns_size_in_code_units_, payload_offset);
+
+ const Instruction::ArrayDataPayload* payload =
+ reinterpret_cast<const Instruction::ArrayDataPayload*>(
+ code_item->insns_ + payload_offset);
+
+ DCHECK_EQ(payload->ident,
+ static_cast<uint16_t>(Instruction::kArrayDataSignature));
+
+ // Test: Is array big enough?
+ uint32_t array_len = static_cast<uint32_t>(array->GetLength());
+ if (UNLIKELY(array_len < payload->element_count)) {
+ int32_t last_index = payload->element_count - 1;
+ art_throw_array_bounds_from_code(array_len, last_index);
+ return;
+ }
+
+ // Copy the data
+ size_t size = payload->element_width * payload->element_count;
+ memcpy(array->GetRawData(payload->element_width), payload->data, size);
+}
+
+
+
//----------------------------------------------------------------------------
// Type checking, in the nature of casting
//----------------------------------------------------------------------------