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/heap.h b/src/heap.h
index a6fb4d4..e205f7a 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -43,6 +43,7 @@
class Thread;
class Heap {
+ friend class ScopedHeapLock;
public:
static const size_t kInitialSize = 2 * MB;
@@ -123,8 +124,6 @@
void WaitForConcurrentGcToComplete();
pid_t GetLockOwner(); // For SignalCatcher.
- void Lock();
- void Unlock();
void AssertLockHeld() {
lock_->AssertHeld();
}
@@ -242,6 +241,9 @@
Object* AllocateLocked(size_t num_bytes);
Object* AllocateLocked(AllocSpace* space, size_t num_bytes);
+ void Lock();
+ void Unlock();
+
// Pushes a list of cleared references out to the managed heap.
void EnqueueClearedReferences(Object** cleared_references);
@@ -289,7 +291,7 @@
bool card_marking_disabled_;
// True while the garbage collector is running.
- bool is_gc_running_;
+ volatile bool is_gc_running_;
// Bytes until concurrent GC
size_t concurrent_start_bytes_;