Change the bitmap callback signature to have a void return value.
Previously, a bitmap callback could abort the bitmap traversal by
returning false. All of the bitmap callbacks used in the garbage
collector are hardwired to return true. This change eliminates the
early termination facility and its attendant complexity.
Change-Id: I5490dd74b56b9700ec1b7e657637fae5eb4cc339
diff --git a/vm/alloc/HeapBitmap.c b/vm/alloc/HeapBitmap.c
index 1f4a9c9..4df30e7 100644
--- a/vm/alloc/HeapBitmap.c
+++ b/vm/alloc/HeapBitmap.c
@@ -92,11 +92,8 @@
* the current XorWalk. <finger> will be set to ULONG_MAX when the
* end of the bitmap is reached.
*/
-bool
-dvmHeapBitmapXorWalk(const HeapBitmap *hb1, const HeapBitmap *hb2,
- bool (*callback)(size_t numPtrs, void **ptrs,
- const void *finger, void *arg),
- void *callbackArg)
+void dvmHeapBitmapXorWalk(const HeapBitmap *hb1, const HeapBitmap *hb2,
+ BitmapCallback *callback, void *callbackArg)
{
static const size_t kPointerBufSize = 128;
void *pointerBuf[kPointerBufSize];
@@ -106,12 +103,8 @@
#define FLUSH_POINTERBUF(finger_) \
do { \
- if (!callback(pb - pointerBuf, (void **)pointerBuf, \
- (void *)(finger_), callbackArg)) \
- { \
- LOGW("dvmHeapBitmapXorWalk: callback failed\n"); \
- return false; \
- } \
+ (*callback)(pb - pointerBuf, (void **)pointerBuf, \
+ (void *)(finger_), callbackArg); \
pb = pointerBuf; \
} while (false)
@@ -151,17 +144,17 @@
LOGW("dvmHeapBitmapXorWalk: bitmaps cover different heaps "
"(0x%08x != 0x%08x)\n",
(uintptr_t)hb1->base, (uintptr_t)hb2->base);
- return false;
+ return;
}
if (hb1->bitsLen != hb2->bitsLen) {
LOGW("dvmHeapBitmapXorWalk: size of bitmaps differ (%zd != %zd)\n",
hb1->bitsLen, hb2->bitsLen);
- return false;
+ return;
}
if (hb1->max < hb1->base && hb2->max < hb2->base) {
/* Easy case; both are obviously empty.
*/
- return true;
+ return;
}
/* First, walk along the section of the bitmaps that may be the same.
@@ -216,9 +209,6 @@
FLUSH_POINTERBUF(finalFinger);
assert(finalFinger > longHb->max);
}
-
- return true;
-
#undef FLUSH_POINTERBUF
#undef DECODE_BITS
}
@@ -227,11 +217,8 @@
* Similar to dvmHeapBitmapXorWalk(), but visit the set bits
* in a single bitmap.
*/
-bool
-dvmHeapBitmapWalk(const HeapBitmap *hb,
- bool (*callback)(size_t numPtrs, void **ptrs,
- const void *finger, void *arg),
- void *callbackArg)
+void dvmHeapBitmapWalk(const HeapBitmap *hb,
+ BitmapCallback *callback, void *callbackArg)
{
/* Create an empty bitmap with the same extent as <hb>.
* Don't actually allocate any memory.
@@ -239,6 +226,5 @@
HeapBitmap emptyHb = *hb;
emptyHb.max = emptyHb.base - 1; // empty
emptyHb.bits = (void *)1; // non-NULL but intentionally bad
-
- return dvmHeapBitmapXorWalk(hb, &emptyHb, callback, callbackArg);
+ dvmHeapBitmapXorWalk(hb, &emptyHb, callback, callbackArg);
}