Add an explicit type for the dex "payload" data.

Change-Id: Ie5ed81c8ea0bed2a4bb6f5f6d5fd238b28236e8e
diff --git a/src/dex_file.h b/src/dex_file.h
index 9c16440..70c2059 100644
--- a/src/dex_file.h
+++ b/src/dex_file.h
@@ -307,6 +307,15 @@
     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 2ef162e..638a7c3 100644
--- a/src/oat/runtime/arm/runtime_support_arm.S
+++ b/src/oat/runtime/arm/runtime_support_arm.S
@@ -254,7 +254,7 @@
     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 9b082bf..d4e87c0 100644
--- a/src/oat/runtime/mips/runtime_support_mips.S
+++ b/src/oat/runtime/mips/runtime_support_mips.S
@@ -416,7 +416,7 @@
 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 eb1c46c..6f40177 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 @@
  *  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
 }