Deduplicate the code that hardcodes the array header layout.

Get rid of HeaderSize() in array-inl.h and use DataOffset() instead.

Bug: 12687968
Change-Id: Ic81cf3fa6bb9b2440d351a73f5fd6a2d6908d15b
diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h
index 1d37775..dac287f 100644
--- a/runtime/mirror/array-inl.h
+++ b/runtime/mirror/array-inl.h
@@ -27,10 +27,6 @@
 namespace art {
 namespace mirror {
 
-static inline size_t HeaderSize(size_t component_size) {
-  return sizeof(Object) + (component_size == sizeof(int64_t) ? 8 : 4);
-}
-
 template<VerifyObjectFlags kVerifyFlags>
 inline size_t Array::SizeOf() {
   // This is safe from overflow because the array was already allocated, so we know it's sane.
@@ -38,7 +34,7 @@
   // Don't need to check this since we already check this in GetClass.
   int32_t component_count =
       GetLength<static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis)>();
-  size_t header_size = HeaderSize(component_size);
+  size_t header_size = DataOffset(component_size).SizeValue();
   size_t data_size = component_count * component_size;
   return header_size + data_size;
 }
@@ -50,7 +46,7 @@
   DCHECK_GE(component_count, 0);
   DCHECK(array_class->IsArrayClass());
 
-  size_t header_size = HeaderSize(component_size);
+  size_t header_size = Array::DataOffset(component_size).SizeValue();
   size_t data_size = component_count * component_size;
   size_t size = header_size + data_size;
 
@@ -134,7 +130,7 @@
         heap->AllocObjectWithAllocator<kIsInstrumented, true>(self, array_class, size,
                                                               allocator_type, visitor));
   } else {
-    SetLengthToUsableSizeVisitor visitor(component_count, HeaderSize(component_size),
+    SetLengthToUsableSizeVisitor visitor(component_count, DataOffset(component_size).SizeValue(),
                                          component_size);
     result = down_cast<Array*>(
         heap->AllocObjectWithAllocator<kIsInstrumented, true>(self, array_class, size,
diff --git a/runtime/offsets.h b/runtime/offsets.h
index e2dba9d..ed4e49e 100644
--- a/runtime/offsets.h
+++ b/runtime/offsets.h
@@ -32,6 +32,10 @@
   uint32_t Uint32Value() const {
     return static_cast<uint32_t>(val_);
   }
+  size_t SizeValue() const {
+    return val_;
+  }
+
  protected:
   size_t val_;
 };