Import the heap verification code from the copying collector.  The
reference verification routine adds an extra argument so the base
address of an object can be passed to the verification code without
provoking a warning from GCC about breaking alias analysis.

Change-Id: Idd921bcc0e084c18bff1e209a8591ef55f57843a
diff --git a/vm/oo/Array.c b/vm/oo/Array.c
index 7edb823..c76ea53 100644
--- a/vm/oo/Array.c
+++ b/vm/oo/Array.c
@@ -761,6 +761,40 @@
     return true;
 }
 
+static size_t arrayElementWidth(const ArrayObject *array)
+{
+    const char *descriptor;
+
+    if (dvmIsObjectArray(array)) {
+        return sizeof(Object *);
+    } else {
+        descriptor = array->obj.clazz->descriptor;
+        switch (descriptor[1]) {
+        case 'B': return 1;  /* byte */
+        case 'C': return 2;  /* char */
+        case 'D': return 8;  /* double */
+        case 'F': return 4;  /* float */
+        case 'I': return 4;  /* int */
+        case 'J': return 8;  /* long */
+        case 'S': return 2;  /* short */
+        case 'Z': return 1;  /* boolean */
+        }
+    }
+    LOGE("object %p has an unhandled descriptor '%s'", array, descriptor);
+    dvmDumpThread(dvmThreadSelf(), false);
+    dvmAbort();
+    return 0;  /* Quiet the compiler. */
+}
+
+size_t dvmArrayObjectLength(const ArrayObject *array)
+{
+    size_t length;
+
+    length = offsetof(ArrayObject, contents);
+    length += array->length * arrayElementWidth(array);
+    return length;
+}
+
 /*
  * Add all primitive classes to the root set of objects.
 TODO: do these belong to the root class loader?