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.cc b/src/card_table.cc
index d4c391a..24c616a 100644
--- a/src/card_table.cc
+++ b/src/card_table.cc
@@ -125,13 +125,13 @@
card_cur++;
}
byte* run_start = card_cur;
- size_t run = 0;
+
while (card_cur < card_end && *card_cur == GC_CARD_DIRTY) {
- run++;
card_cur++;
}
- if (run > 0) {
- byte* run_end = &card_cur[run];
+ byte* run_end = card_cur;
+
+ if (run_start != run_end) {
bitmap->VisitRange(reinterpret_cast<uintptr_t>(AddrFromCard(run_start)),
reinterpret_cast<uintptr_t>(AddrFromCard(run_end)),
visitor, arg);