When aliasing a bitmap, use smallest available limit.
dvmHeapSourceGetObjectBitmaps was using each Heap's allocation limit
to set the max for the bitmap. This causes the HeapBitmap iterators to
do unnecessary work, over parts of the HeapBitmap which could be known
to be all zeros.
Making the max for a HeapBitmap also take into account the liveBits's
max will inform the HeapBitmap iterators that these regions are all
zeros. This will only change the calculation for the active allocation
Heap; but when there are two Heaps, the Zygote Heap is expected to be
pretty well packed, with not a lot of extra words of zeroes in the
HeapBitmap.
Also fixes a defect in aliasBitmap's calculation of bitsLen.
See http://b/issue?id=2857152
Change-Id: Iacb6bc400318702d760a774c6ca5eab67b8bdfd3
diff --git a/vm/alloc/HeapBitmap.c b/vm/alloc/HeapBitmap.c
index 5ac28be..2f412dc 100644
--- a/vm/alloc/HeapBitmap.c
+++ b/vm/alloc/HeapBitmap.c
@@ -209,11 +209,13 @@
}
if (pb > pointerBuf) {
- /* Set the finger to the end of the heap (rather than longHb->max)
- * so that the callback doesn't expect to be called again
- * if it happens to change the current max.
+ /* Set the finger to the end of the heap (rather than
+ * longHb->max) so that the callback doesn't expect to be
+ * called again if it happens to change the current max.
*/
- FLUSH_POINTERBUF(longHb->base + HB_MAX_OFFSET(longHb));
+ uintptr_t finalFinger = longHb->base + HB_MAX_OFFSET(longHb);
+ FLUSH_POINTERBUF(finalFinger);
+ assert(finalFinger > longHb->max);
}
return true;