Additional heap verification for the Gc

There are now two verification booleans which can be enabled. When these get enabled, it verifies that each live object only references other live objects.

Changed SetClass to use SetFieldPtr to avoid having an extra card mark. This is safe since all classes are held live by the class linker.

Change-Id: I005bb59e5cc8153a79d3ccb3d7b5cabd29fb4051
diff --git a/src/mark_sweep.cc b/src/mark_sweep.cc
index c378234..0b09f90 100644
--- a/src/mark_sweep.cc
+++ b/src/mark_sweep.cc
@@ -224,7 +224,6 @@
   CardTable* card_table = heap_->GetCardTable();
   ScanImageRootVisitor image_root_visitor(this);
   SetFingerVisitor finger_visitor(this);
-
   for (Spaces::const_iterator it = spaces.begin(); it != spaces.end(); ++it) {
     Space* space = *it;
     byte* begin = space->Begin();
@@ -358,14 +357,12 @@
 bool MarkSweep::IsMarkedCallback(const Object* object, void* arg) {
   return
       reinterpret_cast<MarkSweep*>(arg)->IsMarked(object) ||
-      //false;
       !reinterpret_cast<MarkSweep*>(arg)->GetHeap()->GetLiveBitmap()->Test(object);
 }
 
 bool MarkSweep::IsLiveCallback(const Object* object, void* arg) {
   return
       reinterpret_cast<MarkSweep*>(arg)->GetHeap()->GetLiveBitmap()->Test(object) ||
-      //false;
       !reinterpret_cast<MarkSweep*>(arg)->IsMarked(object);
 }
 
@@ -542,11 +539,11 @@
       scc.space = space->AsAllocSpace();
       SpaceBitmap* live_bitmap = space->GetLiveBitmap();
       SpaceBitmap* mark_bitmap = space->GetMarkBitmap();
+      if (swap_bitmaps) {
+        std::swap(live_bitmap, mark_bitmap);
+      }
       if (space->GetGcRetentionPolicy() == GCRP_ALWAYS_COLLECT) {
         // Bitmaps are pre-swapped for optimization which enables sweeping with the heap unlocked.
-        if (swap_bitmaps) {
-          std::swap(live_bitmap, mark_bitmap);
-        }
         SpaceBitmap::SweepWalk(*live_bitmap, *mark_bitmap, begin, end,
                                &SweepCallback, reinterpret_cast<void*>(&scc));
       } else {