Enable card cleaning

Cards which do not map to image spaces are now cleared at the start of GC. Cards which map to image spaces are now processed when we go through all the dirty cards after recursive mark. Dirty cards are handled based on if they are either image space cards or cards invalidated by mutators during CMS.

Change-Id: I6c2dc177ebd3f7dc7bbbbd19ae67221371851ebe
diff --git a/src/mark_sweep.h b/src/mark_sweep.h
index 7fda6ea..43ed9b6 100644
--- a/src/mark_sweep.h
+++ b/src/mark_sweep.h
@@ -40,9 +40,12 @@
   // Marks the root set at the start of a garbage collection.
   void MarkRoots();
 
-  // Marks the roots in the image space on dirty cards
+  // Marks the roots in the image space on dirty cards.
   void ScanDirtyImageRoots();
 
+  // Verify that image roots point to only marked objects within the alloc space.
+  void VerifyImageRoots();
+
   bool IsMarkStackEmpty() const {
     return mark_stack_->IsEmpty();
   }
@@ -50,6 +53,10 @@
   // Builds a mark stack and recursively mark until it empties.
   void RecursiveMark();
 
+  // Builds a mark stack with objects on dirty cards and recursively mark
+  // until it empties.
+  void RecursiveMarkDirtyObjects();
+
   // Remarks the root set after completing the concurrent mark.
   void ReMarkRoots();
 
@@ -79,8 +86,12 @@
 
   static void MarkObjectVisitor(const Object* root, void* arg);
 
+  static void ReMarkObjectVisitor(const Object* root, void* arg);
+
   static void ScanImageRootVisitor(Object* root, void* arg);
 
+  static void ScanDirtyCardCallback(Object* obj, void* arg);
+
   // Marks an object.
   void MarkObject(const Object* obj);
 
@@ -130,7 +141,7 @@
   void CheckOther(const Object* obj);
 
   // Blackens objects grayed during a garbage collection.
-  void ScanDirtyObjects();
+  void ScanGrayObjects();
 
   // Schedules an unmarked object for reference processing.
   void DelayReferenceReferent(Object* reference);