Revert "Revert "Avoid adding region space bitmap to heap bitmap""
The issue was that hprof dumping could run in the middle of non CC
GC. This meant the allocation stack and live bitmap could both visit
the same object. The solution is to use a GC critical section.
Bug: 34967844
Test: test-art-host
This reverts commit 215835daf496f44b94b37eb89dd659f84e3ae44d.
Change-Id: I99e65ff31ece74aa94fc55cc7480e27c1e39661b
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 0a45fce..a78de37 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -987,7 +987,9 @@
// Continuous spaces don't necessarily have bitmaps.
accounting::ContinuousSpaceBitmap* live_bitmap = continuous_space->GetLiveBitmap();
accounting::ContinuousSpaceBitmap* mark_bitmap = continuous_space->GetMarkBitmap();
- if (live_bitmap != nullptr) {
+ // The region space bitmap is not added since VisitObjects visits the region space objects with
+ // special handling.
+ if (live_bitmap != nullptr && !space->IsRegionSpace()) {
CHECK(mark_bitmap != nullptr);
live_bitmap_->AddContinuousSpaceBitmap(live_bitmap);
mark_bitmap_->AddContinuousSpaceBitmap(mark_bitmap);
@@ -1028,7 +1030,7 @@
// Continuous spaces don't necessarily have bitmaps.
accounting::ContinuousSpaceBitmap* live_bitmap = continuous_space->GetLiveBitmap();
accounting::ContinuousSpaceBitmap* mark_bitmap = continuous_space->GetMarkBitmap();
- if (live_bitmap != nullptr) {
+ if (live_bitmap != nullptr && !space->IsRegionSpace()) {
DCHECK(mark_bitmap != nullptr);
live_bitmap_->RemoveContinuousSpaceBitmap(live_bitmap);
mark_bitmap_->RemoveContinuousSpaceBitmap(mark_bitmap);