Enable concurrent sweeping for non-concurrent GC.
Refactored the GarbageCollector to let all of the phases be run by
the collector's RunPhases virtual method. This lets the GC decide
which phases should be concurrent and reduces how much baked in GC
logic resides in GarbageCollector.
Enabled concurrent sweeping in the semi space and non concurrent
mark sweep GCs. Changed the semi-space collector to have a swap semi
spaces boolean which can be changed with a setter.
Fixed tests to pass with GSS collector, there was an error related to
the large object space limit.
Before (EvaluateAndApplyChanges):
GSS paused GC time 7.81s/7.81s, score: 3920
After (EvaluateAndApplyChanges):
GSS paused GC time 6.94s/7.71s, score: 3900
Benchmark score doesn't go up since the GC happens in the allocating
thread. There is a slight reduction in pause times experienced by
other threads (0.8s total).
Added options for pre sweeping GC heap verification and pre sweeping
rosalloc verification.
Bug: 14226004
Bug: 14250892
Bug: 14386356
Change-Id: Ib557d0590c1ed82a639d0f0281ba67cf8cae938c
diff --git a/runtime/gc/collector/semi_space.h b/runtime/gc/collector/semi_space.h
index 51b0869..d468561 100644
--- a/runtime/gc/collector/semi_space.h
+++ b/runtime/gc/collector/semi_space.h
@@ -61,12 +61,13 @@
~SemiSpace() {}
- virtual void InitializePhase() OVERRIDE;
- virtual void MarkingPhase() OVERRIDE EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_)
+ virtual void RunPhases() OVERRIDE NO_THREAD_SAFETY_ANALYSIS;
+ virtual void InitializePhase();
+ virtual void MarkingPhase() EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_)
LOCKS_EXCLUDED(Locks::heap_bitmap_lock_);
- virtual void ReclaimPhase() OVERRIDE EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_)
+ virtual void ReclaimPhase() EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_)
LOCKS_EXCLUDED(Locks::heap_bitmap_lock_);
- virtual void FinishPhase() OVERRIDE EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_);
+ virtual void FinishPhase() EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_);
void MarkReachableObjects()
EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_);
virtual GcType GetGcType() const OVERRIDE {
@@ -82,6 +83,12 @@
// Set the space where we copy objects from.
void SetFromSpace(space::ContinuousMemMapAllocSpace* from_space);
+ // Set whether or not we swap the semi spaces in the heap. This needs to be done with mutators
+ // suspended.
+ void SetSwapSemiSpaces(bool swap_semi_spaces) {
+ swap_semi_spaces_ = swap_semi_spaces;
+ }
+
// Initializes internal structures.
void Init();
@@ -253,6 +260,9 @@
// collections.
static constexpr int kDefaultWholeHeapCollectionInterval = 5;
+ // Whether or not we swap the semi spaces in the heap during the marking phase.
+ bool swap_semi_spaces_;
+
private:
friend class BitmapSetSlowPathVisitor;
DISALLOW_COPY_AND_ASSIGN(SemiSpace);