From 95bbf62b59ab7fc86f06339c9b3963aa20cb2d09 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Wed, 16 Dec 2015 15:56:15 -0800 Subject: [PATCH] Fix multiple image space handing for SS collector We need to visit objets that don't have a mod-union table even if collect_from_space_only_ is false. Bug: 22858531 Change-Id: I3144ccb84d7f7bcdf0560f6425c5e5292d3a2082 --- runtime/gc/collector/semi_space.cc | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc index e9497a222..99e98bb56 100644 --- a/runtime/gc/collector/semi_space.cc +++ b/runtime/gc/collector/semi_space.cc @@ -367,37 +367,26 @@ void SemiSpace::MarkReachableObjects() { GetTimings()); table->UpdateAndMarkReferences(this); DCHECK(GetHeap()->FindRememberedSetFromSpace(space) == nullptr); - } else if (collect_from_space_only_ && space->GetLiveBitmap() != nullptr) { - // If the space has no mod union table (the non-moving space and main spaces when the bump - // pointer space only collection is enabled,) then we need to scan its live bitmap or dirty - // cards as roots (including the objects on the live stack which have just marked in the live - // bitmap above in MarkAllocStackAsLive().) - DCHECK(space == heap_->GetNonMovingSpace() || space == heap_->GetPrimaryFreeListSpace()) - << "Space " << space->GetName() << " " - << "generational_=" << generational_ << " " - << "collect_from_space_only_=" << collect_from_space_only_; + } else if ((space->IsImageSpace() || collect_from_space_only_) && + space->GetLiveBitmap() != nullptr) { + // If the space has no mod union table (the non-moving space, app image spaces, main spaces + // when the bump pointer space only collection is enabled,) then we need to scan its live + // bitmap or dirty cards as roots (including the objects on the live stack which have just + // marked in the live bitmap above in MarkAllocStackAsLive().) accounting::RememberedSet* rem_set = GetHeap()->FindRememberedSetFromSpace(space); - if (kUseRememberedSet) { + if (!space->IsImageSpace()) { + DCHECK(space == heap_->GetNonMovingSpace() || space == heap_->GetPrimaryFreeListSpace()) + << "Space " << space->GetName() << " " + << "generational_=" << generational_ << " " + << "collect_from_space_only_=" << collect_from_space_only_; // App images currently do not have remembered sets. - DCHECK((space->IsImageSpace() && space != heap_->GetBootImageSpace()) || - rem_set != nullptr); + DCHECK_EQ(kUseRememberedSet, rem_set != nullptr); } else { DCHECK(rem_set == nullptr); } if (rem_set != nullptr) { TimingLogger::ScopedTiming t2("UpdateAndMarkRememberedSet", GetTimings()); rem_set->UpdateAndMarkReferences(from_space_, this); - if (kIsDebugBuild) { - // Verify that there are no from-space references that - // remain in the space, that is, the remembered set (and the - // card table) didn't miss any from-space references in the - // space. - accounting::ContinuousSpaceBitmap* live_bitmap = space->GetLiveBitmap(); - SemiSpaceVerifyNoFromSpaceReferencesObjectVisitor visitor(this); - live_bitmap->VisitMarkedRange(reinterpret_cast(space->Begin()), - reinterpret_cast(space->End()), - visitor); - } } else { TimingLogger::ScopedTiming t2("VisitLiveBits", GetTimings()); accounting::ContinuousSpaceBitmap* live_bitmap = space->GetLiveBitmap(); @@ -406,6 +395,17 @@ void SemiSpace::MarkReachableObjects() { reinterpret_cast(space->End()), visitor); } + if (kIsDebugBuild) { + // Verify that there are no from-space references that + // remain in the space, that is, the remembered set (and the + // card table) didn't miss any from-space references in the + // space. + accounting::ContinuousSpaceBitmap* live_bitmap = space->GetLiveBitmap(); + SemiSpaceVerifyNoFromSpaceReferencesObjectVisitor visitor(this); + live_bitmap->VisitMarkedRange(reinterpret_cast(space->Begin()), + reinterpret_cast(space->End()), + visitor); + } } } -- 2.11.0