From: Hiroshi Yamauchi Date: Wed, 27 Jul 2016 21:08:19 +0000 (-0700) Subject: Scan immune spaces using mod union tables. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8256da35feac0ba7589fcd4b692a4b9a936679a4;p=android-x86%2Fart.git Scan immune spaces using mod union tables. It's faster to scan the immune spaces using the mod union tables (gray objects on dirty pages) than the live bitmaps (gray objects). The immune space scan time goes from ~13ms down to ~10ms in the testWidgetsContainerFling test on angler at 1 GHz. Change-Id: I0914d7bdb50cbf8a49c859070a3501b48eb79f3e Test: N9 boot, art tests, Ritz EAAC. Bug: 29516968 Bug: 29517059 Bug: 12687968 --- diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc index d413a5053..4a8008920 100644 --- a/runtime/gc/collector/concurrent_copying.cc +++ b/runtime/gc/collector/concurrent_copying.cc @@ -520,7 +520,7 @@ class ConcurrentCopying::ImmuneSpaceScanObjVisitor { explicit ImmuneSpaceScanObjVisitor(ConcurrentCopying* cc) : collector_(cc) {} - void operator()(mirror::Object* obj) const SHARED_REQUIRES(Locks::mutator_lock_) { + ALWAYS_INLINE void operator()(mirror::Object* obj) const SHARED_REQUIRES(Locks::mutator_lock_) { if (kUseBakerReadBarrier && kGrayDirtyImmuneObjects) { if (obj->GetReadBarrierPointer() == ReadBarrier::GrayPtr()) { collector_->ScanImmuneObject(obj); @@ -534,6 +534,10 @@ class ConcurrentCopying::ImmuneSpaceScanObjVisitor { } } + static void Callback(mirror::Object* obj, void* arg) SHARED_REQUIRES(Locks::mutator_lock_) { + reinterpret_cast(arg)->operator()(obj); + } + private: ConcurrentCopying* const collector_; }; @@ -558,10 +562,15 @@ void ConcurrentCopying::MarkingPhase() { for (auto& space : immune_spaces_.GetSpaces()) { DCHECK(space->IsImageSpace() || space->IsZygoteSpace()); accounting::ContinuousSpaceBitmap* live_bitmap = space->GetLiveBitmap(); + accounting::ModUnionTable* table = heap_->FindModUnionTableFromSpace(space); ImmuneSpaceScanObjVisitor visitor(this); - live_bitmap->VisitMarkedRange(reinterpret_cast(space->Begin()), - reinterpret_cast(space->Limit()), - visitor); + if (table != nullptr) { + table->VisitObjects(ImmuneSpaceScanObjVisitor::Callback, &visitor); + } else { + live_bitmap->VisitMarkedRange(reinterpret_cast(space->Begin()), + reinterpret_cast(space->Limit()), + visitor); + } } } if (kUseBakerReadBarrier) {