Zygote space / partial collection support.

The zygote space is now created right before zygote fork. This space has new allocations into it disabled, this reduces memory usage since we have more shared pages.

Partial collection works by marking all the zygote space -> alloc space references by using a mod-union table and then recursively marking only over the alloc space.

Approximate improvements;

Deltablue time goes down ~0.5 seconds.

Caffeinemark score goes up ~300.

System memory usage goes down ~7MB.

Change-Id: I198389371d23deacd9b4534f39727eb641786b34
diff --git a/src/mark_sweep.h b/src/mark_sweep.h
index 5f275a4..108da87 100644
--- a/src/mark_sweep.h
+++ b/src/mark_sweep.h
@@ -57,7 +57,10 @@
   }
 
   // Builds a mark stack and recursively mark until it empties.
-  void RecursiveMark();
+  void RecursiveMark(bool partial);
+
+  // Copies mark bits from live bitmap of zygote space to mark bitmap for partial GCs.
+  void CopyMarkBits();
 
   // Builds a mark stack with objects on dirty cards and recursively mark
   // until it empties.
@@ -66,6 +69,10 @@
   // Remarks the root set after completing the concurrent mark.
   void ReMarkRoots();
 
+  Heap* GetHeap() {
+    return heap_;
+  }
+
   void ProcessReferences(bool clear_soft_references) {
     ProcessReferences(&soft_reference_list_, clear_soft_references,
                       &weak_reference_list_,
@@ -74,12 +81,15 @@
   }
 
   // Sweeps unmarked objects to complete the garbage collection.
-  void Sweep();
+  void Sweep(bool partial);
 
   Object* GetClearedReferences() {
     return cleared_reference_list_;
   }
 
+  // Blackens an object.
+  void ScanObject(const Object* obj);
+
  private:
   // Returns true if the object has its bit set in the mark bitmap.
   bool IsMarked(const Object* object) const {
@@ -97,8 +107,6 @@
 
   static void ReMarkObjectVisitor(const Object* root, void* arg);
 
-  static void ScanImageRootVisitor(Object* root, void* arg);
-
   static void VerifyImageRootVisitor(Object* root, void* arg);
 
   static void ScanDirtyCardCallback(Object* obj, void* arg);
@@ -111,16 +119,12 @@
 
   static void ScanBitmapCallback(Object* obj, void* finger, void* arg);
 
-  static void CheckBitmapCallback(Object* obj, void* finger, void* arg);
-
-  static void CheckBitmapNoFingerCallback(Object* obj, void* arg);
-
   static void SweepCallback(size_t num_ptrs, Object** ptrs, void* arg);
 
-  void CheckReference(const Object* obj, const Object* ref, MemberOffset offset, bool is_static);
+  // Special sweep for zygote that just marks objects / dirties cards.
+  static void ZygoteSweepCallback(size_t num_ptrs, Object** ptrs, void* arg);
 
-  // Blackens an object.
-  void ScanObject(const Object* obj);
+  void CheckReference(const Object* obj, const Object* ref, MemberOffset offset, bool is_static);
 
   void CheckObject(const Object* obj);
 
@@ -275,14 +279,20 @@
   size_t other_count_;
 
   friend class AddIfReachesAllocSpaceVisitor; // Used by mod-union table.
+  friend class CheckBitmapVisitor;
   friend class CheckObjectVisitor;
+  friend class CheckReferenceVisitor;
   friend class InternTableEntryIsUnmarked;
   friend class MarkIfReachesAllocspaceVisitor;
+  friend class ModUnionCheckReferences;
   friend class ModUnionClearCardVisitor;
   friend class ModUnionReferenceVisitor;
   friend class ModUnionVisitor;
   friend class ModUnionTableBitmap;
   friend class ModUnionTableReferenceCache;
+  friend class ModUnionScanImageRootVisitor;
+  friend class ScanBitmapVisitor;
+  friend class ScanImageRootVisitor;
 
   DISALLOW_COPY_AND_ASSIGN(MarkSweep);
 };