Some formatting and commenting clean-up.

Change-Id: Icc166d98fe9c0fb03a51f9fbfa2e5765b75af8f5
diff --git a/vm/alloc/CardTable.c b/vm/alloc/CardTable.c
index 9455955..49562a7 100644
--- a/vm/alloc/CardTable.c
+++ b/vm/alloc/CardTable.c
@@ -28,10 +28,10 @@
  * non-NULL values to heap addresses should go through an entry in
  * WriteBarrier, and from there to here.
  *
- * The heap is divided into "cards" of 512 bytes, as determined by
- * GC_CARD_SHIFT. The card table contains one byte of data per card,
- * to be used by the GC. The value of the byte will be one of
- * GC_CARD_CLEAN or GC_CARD_DIRTY.
+ * The heap is divided into "cards" of GC_CARD_SIZE bytes, as
+ * determined by GC_CARD_SHIFT. The card table contains one byte of
+ * data per card, to be used by the GC. The value of the byte will be
+ * one of GC_CARD_CLEAN or GC_CARD_DIRTY.
  *
  * After any store of a non-NULL object pointer into a heap object,
  * code is obliged to mark the card dirty. The setters in
@@ -105,25 +105,28 @@
 }
 
 /*
- * Returns The address of the relevent byte in the card table, given
+ * Returns the address of the relevent byte in the card table, given
  * an address on the heap.
  */
 u1 *dvmCardFromAddr(const void *addr)
 {
-    u1 *cardAddr = gDvm.gcHeap->biasedCardTableBase +
-        ((uintptr_t)addr >> GC_CARD_SHIFT);
-    assert(cardAddr >= gDvm.gcHeap->cardTableBase);
-    assert(cardAddr <
-           &gDvm.gcHeap->cardTableBase[gDvm.gcHeap->cardTableLength]);
+    GcHeap *h = gDvm.gcHeap;
+    u1 *cardAddr = h->biasedCardTableBase + ((uintptr_t)addr >> GC_CARD_SHIFT);
+    assert(cardAddr >= h->cardTableBase);
+    assert(cardAddr < &h->cardTableBase[h->cardTableLength]);
     return cardAddr;
 }
 
-void *dvmAddrFromCard(const u1 *cardAddr) {
-    assert(cardAddr >= gDvm.gcHeap->cardTableBase);
-    assert(cardAddr <
-           &gDvm.gcHeap->cardTableBase[gDvm.gcHeap->cardTableLength]);
-    void *addr = (void *)((cardAddr - gDvm.gcHeap->biasedCardTableBase) << GC_CARD_SHIFT);
-    return addr;
+/*
+ * Returns the first address in the heap which maps to this card.
+ */
+void *dvmAddrFromCard(const u1 *cardAddr)
+{
+    GcHeap *h = gDvm.gcHeap;
+    assert(cardAddr >= h->cardTableBase);
+    assert(cardAddr < &h->cardTableBase[h->cardTableLength]);
+    uintptr_t offset = cardAddr - h->biasedCardTableBase;
+    return (void *)(offset << GC_CARD_SHIFT);
 }
 
 /*
@@ -158,8 +161,7 @@
  * A Visitor callback in support of checkCleanObjects. "arg" is
  * expected to be the immuneLimit.
  */
-static void
-crossGenCheckVisitor(void *ptr, void *arg)
+static void crossGenCheckVisitor(void *ptr, void *arg)
 {
     Object *ref = *(Object **)ptr;
     Object *immuneLimit = (Object *)arg;
@@ -173,8 +175,7 @@
 /*
  * A HeapBitmap callback in support of checkCleanObjects.
  */
-static bool
-crossGenCheckCallback(size_t numPtrs, void **ptrs,
+static bool crossGenCheckCallback(size_t numPtrs, void **ptrs,
                       const void *finger, void *arg)
 {
     size_t i;
diff --git a/vm/alloc/CardTable.h b/vm/alloc/CardTable.h
index c142702..b960ec5 100644
--- a/vm/alloc/CardTable.h
+++ b/vm/alloc/CardTable.h
@@ -29,7 +29,6 @@
  */
 #define GC_CARD_SHIFT 7
 #define GC_CARD_SIZE (1 << GC_CARD_SHIFT)
-#define GC_OBJ_PER_CARD (GC_CARD_SIZE >> 3)
 #define GC_CARD_CLEAN 0
 #define GC_CARD_DIRTY 0x70
 
@@ -48,11 +47,14 @@
 void dvmCardTableShutdown(void);
 
 /*
- * Returns The address of the relevent byte in the card table, given
+ * Returns the address of the relevent byte in the card table, given
  * an address on the heap.
  */
 u1 *dvmCardFromAddr(const void *addr);
 
+/*
+ * Returns the first address in the heap which maps to this card.
+ */
 void *dvmAddrFromCard(const u1 *card);
 
 /*
diff --git a/vm/alloc/MarkSweep.c b/vm/alloc/MarkSweep.c
index cdab034..f0eaa6c 100644
--- a/vm/alloc/MarkSweep.c
+++ b/vm/alloc/MarkSweep.c
@@ -720,7 +720,9 @@
                 u1 *maxCard = dvmCardFromAddr((void *)maxAddr);
 
                 u1 *card;
-                /* TODO: This double-loop should be made faster.
+                /* TODO: This double-loop should be made faster. In
+                 * particular the inner loop could get in bed with the
+                 * bitmap scanning routines.
                  */
                 for (card = minCard; card <= maxCard; card++) {
                     if (*card == GC_CARD_DIRTY) {