Refactor immune region logic into its own file.
Added immune_region.cc/.h in the collector directory. Changed the
functionality to no longer assume spaces are added to immune region
in ascending order.
Change-Id: Id1d643b3849ad2695e8a151dbbb74a5035644472
diff --git a/runtime/gc/collector/mark_sweep.h b/runtime/gc/collector/mark_sweep.h
index 8d40c34..df19f88 100644
--- a/runtime/gc/collector/mark_sweep.h
+++ b/runtime/gc/collector/mark_sweep.h
@@ -22,6 +22,7 @@
#include "base/macros.h"
#include "base/mutex.h"
#include "garbage_collector.h"
+#include "immune_region.h"
#include "object_callbacks.h"
#include "offsets.h"
#include "UniquePtr.h"
@@ -108,15 +109,6 @@
EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- // Make a space immune, immune spaces have all live objects marked - that is the mark and
- // live bitmaps are bound together.
- void ImmuneSpace(space::ContinuousSpace* space)
- EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
- bool IsImmuneSpace(const space::ContinuousSpace* space) const
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
// Bind the live bits to the mark bits of bitmaps for spaces that are never collected, ie
// the image. Mark that portion of the heap as immune.
virtual void BindBitmaps() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -165,9 +157,6 @@
void ScanObjectVisit(mirror::Object* obj, const MarkVisitor& visitor)
NO_THREAD_SAFETY_ANALYSIS;
- // Everything inside the immune range is assumed to be marked.
- void SetImmuneRange(mirror::Object* begin, mirror::Object* end);
-
void SweepSystemWeaks()
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_);
@@ -266,11 +255,6 @@
// whether or not we care about pauses.
size_t GetThreadCount(bool paused) const;
- // Returns true if an object is inside of the immune region (assumed to be marked).
- bool IsImmune(const mirror::Object* obj) const ALWAYS_INLINE {
- return obj >= immune_begin_ && obj < immune_end_;
- }
-
static void VerifyRootCallback(const mirror::Object* root, void* arg, size_t vreg,
const StackVisitor *visitor);
@@ -354,8 +338,7 @@
accounting::ObjectStack* mark_stack_;
// Immune range, every object inside the immune range is assumed to be marked.
- mirror::Object* immune_begin_;
- mirror::Object* immune_end_;
+ ImmuneRegion immune_region_;
// Parallel finger.
AtomicInteger atomic_finger_;