diff options
| author | 2022-12-06 00:54:59 +0000 | |
|---|---|---|
| committer | 2022-12-06 00:54:59 +0000 | |
| commit | 40bdbf9f2e94ac81ef64da19c5f84a5037f3fd2a (patch) | |
| tree | 5c8b2452886cae5313aa8f8004dae954cbf7de9f | |
| parent | c16f5044ccb319443961c381d73c1e55e4e46208 (diff) | |
| parent | d4c19c9f9f3c931f46985518cdf092e9370305f4 (diff) | |
Update non-moving space references in reverse am: d4c19c9f9f
Original change: https://android-review.googlesource.com/c/platform/art/+/2325972
Change-Id: Ic7505aaf8d4518e94b6f1c635ed1642c25f50d05
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | runtime/gc/collector/mark_compact.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/runtime/gc/collector/mark_compact.cc b/runtime/gc/collector/mark_compact.cc index 25be59f2c1..e7ca948489 100644 --- a/runtime/gc/collector/mark_compact.cc +++ b/runtime/gc/collector/mark_compact.cc @@ -1894,14 +1894,22 @@ void MarkCompact::UpdateNonMovingPage(mirror::Object* first, uint8_t* page) { void MarkCompact::UpdateNonMovingSpace() { TimingLogger::ScopedTiming t(__FUNCTION__, GetTimings()); - uint8_t* page = non_moving_space_->Begin(); - for (size_t i = 0; i < non_moving_first_objs_count_; i++) { - mirror::Object* obj = first_objs_non_moving_space_[i].AsMirrorPtr(); - // null means there are no objects on the page to update references. - if (obj != nullptr) { - UpdateNonMovingPage(obj, page); - } - page += kPageSize; + // Iterating in reverse ensures that the class pointer in objects which span + // across more than one page gets updated in the end. This is necessary for + // VisitRefsForCompaction() to work correctly. + // TODO: If and when we make non-moving space update concurrent, implement a + // mechanism to remember class pointers for such objects off-heap and pass it + // to VisitRefsForCompaction(). + if (non_moving_first_objs_count_ > 0) { + uint8_t* page = non_moving_space_->Begin() + non_moving_first_objs_count_ * kPageSize; + for (size_t i = non_moving_first_objs_count_ - 1; i >= 0; i--) { + mirror::Object* obj = first_objs_non_moving_space_[i].AsMirrorPtr(); + page -= kPageSize; + // null means there are no objects on the page to update references. + if (obj != nullptr) { + UpdateNonMovingPage(obj, page); + } + } } } |