Fix and re-enable CMS

Fix for CardTable::Scan double length scan which caused occasional assert failures.
Fix for the case where CMS request JNI code caused a GC which freed newest allocated object.
Fix error with is_gc_running_ never being set and deadlock due to CV wait without thread state change.
Fix error where we were Unlocking the heap before doing ResumeAll in CollectGarbageInternal which resulted in a rare race condition.
Fix error where GC could be in progress when the runtime terminated.

Change-Id: I8d243d4dca63170433a63429442788ecb09e55fe
diff --git a/src/card_table.h b/src/card_table.h
index 0d5178e..0a031b8 100644
--- a/src/card_table.h
+++ b/src/card_table.h
@@ -86,7 +86,10 @@
 
   // Returns the first address in the heap which maps to this card.
   void* AddrFromCard(const byte *cardAddr) const {
-    DCHECK(IsValidCard(cardAddr));
+    DCHECK(IsValidCard(cardAddr))
+      << " cardAddr: " << reinterpret_cast<const void*>(cardAddr)
+      << " begin: " << reinterpret_cast<void*>(mem_map_->Begin() + offset_)
+      << " end: " << reinterpret_cast<void*>(mem_map_->End());
     uintptr_t offset = cardAddr - biased_begin_;
     return reinterpret_cast<void*>(offset << GC_CARD_SHIFT);
   }