Favor Object* over void* for the heap bitmap interfaces.

Change-Id: I615dbff3e81a1128dc3ba43d6d426c370ae3abcf
diff --git a/vm/alloc/Alloc.cpp b/vm/alloc/Alloc.cpp
index 1dbac53..46b21c0 100644
--- a/vm/alloc/Alloc.cpp
+++ b/vm/alloc/Alloc.cpp
@@ -320,11 +320,9 @@
     size_t count;
 };
 
-static void countInstancesOfClassCallback(void *ptr, void *arg)
+static void countInstancesOfClassCallback(Object *obj, void *arg)
 {
     CountContext *ctx = (CountContext *)arg;
-    const Object *obj = (const Object *)ptr;
-
     assert(ctx != NULL);
     if (obj->clazz == ctx->clazz) {
         ctx->count += 1;
@@ -341,11 +339,9 @@
     return ctx.count;
 }
 
-static void countAssignableInstancesOfClassCallback(void *ptr, void *arg)
+static void countAssignableInstancesOfClassCallback(Object *obj, void *arg)
 {
     CountContext *ctx = (CountContext *)arg;
-    const Object *obj = (const Object *)ptr;
-
     assert(ctx != NULL);
     if (obj->clazz != NULL && dvmInstanceof(obj->clazz, ctx->clazz)) {
         ctx->count += 1;
diff --git a/vm/alloc/CardTable.cpp b/vm/alloc/CardTable.cpp
index ec8ba97..65861c6 100644
--- a/vm/alloc/CardTable.cpp
+++ b/vm/alloc/CardTable.cpp
@@ -300,16 +300,15 @@
     }
 }
 
-static void dumpReferencesCallback(void *ptr, void *arg)
+static void dumpReferencesCallback(Object *obj, void *arg)
 {
-    Object *obj = (Object *)arg;
-    if (ptr == obj) {
+    if (obj == (Object *)arg) {
         return;
     }
-    dvmVisitObject(dumpReferencesVisitor, (Object *)ptr, &obj);
-    if (obj == NULL) {
-        LOGD("Found %p in the heap @ %p", arg, ptr);
-        dvmDumpObject((Object *)ptr);
+    dvmVisitObject(dumpReferencesVisitor, obj, &arg);
+    if (arg == NULL) {
+        LOGD("Found %p in the heap @ %p", arg, obj);
+        dvmDumpObject(obj);
     }
 }
 
@@ -395,9 +394,8 @@
  * references specially as it is permissible for these objects to be
  * gray and on an unmarked card.
  */
-static void verifyCardTableCallback(void *ptr, void *arg)
+static void verifyCardTableCallback(Object *obj, void *arg)
 {
-    Object *obj = (Object *)ptr;
     WhiteReferenceCounter ctx = { (HeapBitmap *)arg, 0 };
 
     dvmVisitObject(countWhiteReferenceVisitor, obj, &ctx);
diff --git a/vm/alloc/HeapBitmap.cpp b/vm/alloc/HeapBitmap.cpp
index 02b715f..cf02708 100644
--- a/vm/alloc/HeapBitmap.cpp
+++ b/vm/alloc/HeapBitmap.cpp
@@ -108,8 +108,8 @@
             uintptr_t ptrBase = HB_INDEX_TO_OFFSET(i) + bitmap->base;
             while (word != 0) {
                 const int shift = CLZ(word);
-                void *addr = (void *)(ptrBase + shift * HB_OBJECT_ALIGNMENT);
-                (*callback)(addr, arg);
+                Object* obj = (Object *)(ptrBase + shift * HB_OBJECT_ALIGNMENT);
+                (*callback)(obj, arg);
                 word &= ~(highBit >> shift);
             }
         }
@@ -147,8 +147,8 @@
             void *finger = (void *)(HB_INDEX_TO_OFFSET(i + 1) + bitmap->base);
             while (word != 0) {
                 const int shift = CLZ(word);
-                void *addr = (void *)(ptrBase + shift * HB_OBJECT_ALIGNMENT);
-                (*callback)(addr, finger, arg);
+                Object *obj = (Object *)(ptrBase + shift * HB_OBJECT_ALIGNMENT);
+                (*callback)(obj, finger, arg);
                 word &= ~(highBit >> shift);
             }
             end = HB_OFFSET_TO_INDEX(bitmap->max - bitmap->base);
diff --git a/vm/alloc/HeapBitmap.h b/vm/alloc/HeapBitmap.h
index 90cfea9..eba5998 100644
--- a/vm/alloc/HeapBitmap.h
+++ b/vm/alloc/HeapBitmap.h
@@ -73,8 +73,8 @@
 /*
  * Callback types used by the walking routines.
  */
-typedef void BitmapCallback(void *addr, void *arg);
-typedef void BitmapScanCallback(void *addr, void *finger, void *arg);
+typedef void BitmapCallback(Object *obj, void *arg);
+typedef void BitmapScanCallback(Object *obj, void *finger, void *arg);
 typedef void BitmapSweepCallback(size_t numPtrs, void **ptrs, void *arg);
 
 /*
diff --git a/vm/alloc/MarkSweep.cpp b/vm/alloc/MarkSweep.cpp
index 710f2e6..309bd03 100644
--- a/vm/alloc/MarkSweep.cpp
+++ b/vm/alloc/MarkSweep.cpp
@@ -293,11 +293,10 @@
  * Visitor that searches for immune objects and verifies that all
  * threatened referents are marked.
  */
-static void verifyImmuneObjectsCallback(void *addr, void *arg)
+static void verifyImmuneObjectsCallback(Object *obj, void *arg)
 {
-    assert(addr != NULL);
+    assert(obj != NULL);
     assert(arg != NULL);
-    Object *obj = (Object *)addr;
     GcMarkContext *ctx = (GcMarkContext *)arg;
     if (obj->clazz == NULL) {
         LOGI("uninitialized object @ %p (has null clazz pointer)", obj);
@@ -686,11 +685,11 @@
  * to the address corresponding to the lowest address in the next word
  * of bits in the bitmap.
  */
-static void scanBitmapCallback(void *addr, void *finger, void *arg)
+static void scanBitmapCallback(Object *obj, void *finger, void *arg)
 {
     GcMarkContext *ctx = (GcMarkContext *)arg;
     ctx->finger = (void *)finger;
-    scanObject((Object *)addr, ctx);
+    scanObject(obj, ctx);
 }
 
 /* Given bitmaps with the root set marked, find and mark all
diff --git a/vm/alloc/Verify.cpp b/vm/alloc/Verify.cpp
index 1a8307a..6d830c7 100644
--- a/vm/alloc/Verify.cpp
+++ b/vm/alloc/Verify.cpp
@@ -38,16 +38,15 @@
  * Visitor applied to each bitmap element to search for things that
  * point to an object.  Logs a message when a match is found.
  */
-static void dumpReferencesCallback(void *ptr, void *arg)
+static void dumpReferencesCallback(Object *obj, void *arg)
 {
-    Object *obj = (Object *)arg;
-    if (ptr == obj) {
+    if (obj == (Object *)arg) {
         return;
     }
-    dvmVisitObject(dumpReferencesVisitor, (Object *)ptr, &obj);
-    if (obj == NULL) {
-        LOGD("Found %p in the heap @ %p", arg, ptr);
-        dvmDumpObject((Object *)ptr);
+    dvmVisitObject(dumpReferencesVisitor, obj, &arg);
+    if (arg == NULL) {
+        LOGD("Found %p in the heap @ %p", arg, obj);
+        dvmDumpObject(obj);
     }
 }
 
@@ -108,8 +107,8 @@
  */
 void dvmVerifyObject(const Object *obj)
 {
-    Object *arg = (Object *)obj;
-    dvmVisitObject(verifyReference, (Object *)obj, &arg);
+    Object *arg = const_cast<Object*>(obj);
+    dvmVisitObject(verifyReference, arg, &arg);
     if (arg == NULL) {
         dumpReferences(obj);
         dvmAbort();
@@ -119,9 +118,9 @@
 /*
  * Helper function to call dvmVerifyObject from a bitmap walker.
  */
-static void verifyBitmapCallback(void *ptr, void *arg)
+static void verifyBitmapCallback(Object *obj, void *arg)
 {
-    dvmVerifyObject((Object *)ptr);
+    dvmVerifyObject(obj);
 }
 
 /*
diff --git a/vm/hprof/Hprof.cpp b/vm/hprof/Hprof.cpp
index ff8e872..4a6b1a6 100644
--- a/vm/hprof/Hprof.cpp
+++ b/vm/hprof/Hprof.cpp
@@ -214,15 +214,11 @@
 /*
  * Visitor invoked on every heap object.
  */
-static void hprofBitmapCallback(void *ptr, void *arg)
+static void hprofBitmapCallback(Object *obj, void *arg)
 {
-    Object *obj;
-    hprof_context_t *ctx;
-
-    assert(ptr != NULL);
+    assert(obj != NULL);
     assert(arg != NULL);
-    obj = (Object *)ptr;
-    ctx = (hprof_context_t *)arg;
+    hprof_context_t *ctx = (hprof_context_t *)arg;
     hprofDumpHeapObject(ctx, obj);
 }