summaryrefslogtreecommitdiffstats
path: root/runtime/gc/collector/mark_sweep.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2014-04-09 14:51:05 -0700
committerMathieu Chartier <mathieuc@google.com>2014-04-14 10:07:47 -0700
commita8e8f9c0a8e259a807d7b99a148d14104c24209d (patch)
treed8ed041dd3cf490163f6b405102ea36d3b4b0828 /runtime/gc/collector/mark_sweep.cc
parent043a7a6182870964021476484b1534106ff20600 (diff)
downloadart-a8e8f9c0a8e259a807d7b99a148d14104c24209d.zip
art-a8e8f9c0a8e259a807d7b99a148d14104c24209d.tar.gz
art-a8e8f9c0a8e259a807d7b99a148d14104c24209d.tar.bz2
Refactor space bitmap to support different alignments.
Required for: Using space bitmaps instead of std::set in mod union table + remembered set. Using a bitmap instead of set for large object marking. Bug: 13571028 Change-Id: Id024e9563d4ca4278f79607cdb2f81895121b113
Diffstat (limited to 'runtime/gc/collector/mark_sweep.cc')
-rw-r--r--runtime/gc/collector/mark_sweep.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc
index bb41b57..f07e6f1 100644
--- a/runtime/gc/collector/mark_sweep.cc
+++ b/runtime/gc/collector/mark_sweep.cc
@@ -123,7 +123,6 @@ void MarkSweep::InitializePhase() {
mark_immune_count_ = 0;
mark_fastpath_count_ = 0;
mark_slowpath_count_ = 0;
- FindDefaultSpaceBitmap();
{
// TODO: I don't think we should need heap bitmap lock to get the mark bitmap.
ReaderMutexLock mu(Thread::Current(), *Locks::heap_bitmap_lock_);
@@ -293,7 +292,7 @@ void MarkSweep::ReclaimPhase() {
void MarkSweep::FindDefaultSpaceBitmap() {
TimingLogger::ScopedSplit split("FindDefaultMarkBitmap", &timings_);
for (const auto& space : GetHeap()->GetContinuousSpaces()) {
- accounting::SpaceBitmap* bitmap = space->GetMarkBitmap();
+ accounting::ContinuousSpaceBitmap* bitmap = space->GetMarkBitmap();
if (bitmap != nullptr &&
space->GetGcRetentionPolicy() == space::kGcRetentionPolicyAlwaysCollect) {
current_space_bitmap_ = bitmap;
@@ -359,7 +358,7 @@ inline void MarkSweep::MarkObjectNonNull(Object* obj) {
}
// Try to take advantage of locality of references within a space, failing this find the space
// the hard way.
- accounting::SpaceBitmap* object_bitmap = current_space_bitmap_;
+ accounting::ContinuousSpaceBitmap* object_bitmap = current_space_bitmap_;
if (UNLIKELY(!object_bitmap->HasAddress(obj))) {
object_bitmap = mark_bitmap_->GetContinuousSpaceBitmap(obj);
if (kCountMarkedObjects) {
@@ -428,9 +427,9 @@ inline bool MarkSweep::MarkObjectParallel(const Object* obj) {
}
// Try to take advantage of locality of references within a space, failing this find the space
// the hard way.
- accounting::SpaceBitmap* object_bitmap = current_space_bitmap_;
+ accounting::ContinuousSpaceBitmap* object_bitmap = current_space_bitmap_;
if (UNLIKELY(!object_bitmap->HasAddress(obj))) {
- accounting::SpaceBitmap* new_bitmap = mark_bitmap_->GetContinuousSpaceBitmap(obj);
+ accounting::ContinuousSpaceBitmap* new_bitmap = mark_bitmap_->GetContinuousSpaceBitmap(obj);
if (new_bitmap != NULL) {
object_bitmap = new_bitmap;
} else {
@@ -476,7 +475,7 @@ void MarkSweep::VerifyRootCallback(const Object* root, void* arg, size_t vreg,
void MarkSweep::VerifyRoot(const Object* root, size_t vreg, const StackVisitor* visitor,
RootType root_type) {
// See if the root is on any space bitmap.
- if (GetHeap()->GetLiveBitmap()->GetContinuousSpaceBitmap(root) == nullptr) {
+ if (heap_->GetLiveBitmap()->GetContinuousSpaceBitmap(root) == nullptr) {
space::LargeObjectSpace* large_object_space = GetHeap()->GetLargeObjectsSpace();
if (!large_object_space->Contains(root)) {
LOG(ERROR) << "Found invalid root: " << root << " with type " << root_type;
@@ -686,7 +685,8 @@ class MarkStackTask : public Task {
class CardScanTask : public MarkStackTask<false> {
public:
- CardScanTask(ThreadPool* thread_pool, MarkSweep* mark_sweep, accounting::SpaceBitmap* bitmap,
+ CardScanTask(ThreadPool* thread_pool, MarkSweep* mark_sweep,
+ accounting::ContinuousSpaceBitmap* bitmap,
byte* begin, byte* end, byte minimum_age, size_t mark_stack_size,
Object** mark_stack_obj)
: MarkStackTask<false>(thread_pool, mark_sweep, mark_stack_size, mark_stack_obj),
@@ -697,7 +697,7 @@ class CardScanTask : public MarkStackTask<false> {
}
protected:
- accounting::SpaceBitmap* const bitmap_;
+ accounting::ContinuousSpaceBitmap* const bitmap_;
byte* const begin_;
byte* const end_;
const byte minimum_age_;
@@ -820,7 +820,7 @@ void MarkSweep::ScanGrayObjects(bool paused, byte minimum_age) {
class RecursiveMarkTask : public MarkStackTask<false> {
public:
RecursiveMarkTask(ThreadPool* thread_pool, MarkSweep* mark_sweep,
- accounting::SpaceBitmap* bitmap, uintptr_t begin, uintptr_t end)
+ accounting::ContinuousSpaceBitmap* bitmap, uintptr_t begin, uintptr_t end)
: MarkStackTask<false>(thread_pool, mark_sweep, 0, NULL),
bitmap_(bitmap),
begin_(begin),
@@ -828,7 +828,7 @@ class RecursiveMarkTask : public MarkStackTask<false> {
}
protected:
- accounting::SpaceBitmap* const bitmap_;
+ accounting::ContinuousSpaceBitmap* const bitmap_;
const uintptr_t begin_;
const uintptr_t end_;
@@ -1045,8 +1045,8 @@ void MarkSweep::SweepArray(accounting::ObjectStack* allocations, bool swap_bitma
// Start by sweeping the continuous spaces.
for (space::ContinuousSpace* space : sweep_spaces) {
space::AllocSpace* alloc_space = space->AsAllocSpace();
- accounting::SpaceBitmap* live_bitmap = space->GetLiveBitmap();
- accounting::SpaceBitmap* mark_bitmap = space->GetMarkBitmap();
+ accounting::ContinuousSpaceBitmap* live_bitmap = space->GetLiveBitmap();
+ accounting::ContinuousSpaceBitmap* mark_bitmap = space->GetMarkBitmap();
if (swap_bitmaps) {
std::swap(live_bitmap, mark_bitmap);
}