Commit 1cd9adcc authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

heap: Allow aborting compaction on a page based on Address

This CL allows aborting of compaction on a page based on an Address
instead of a HeapObject.

Bug: v8:12251
Change-Id: Ib928ace9aa24a0ff1ab5f44026d5b287f7cdcdb3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3199881
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77216}
parent f78429b8
...@@ -3355,7 +3355,8 @@ void FullEvacuator::RawEvacuatePage(MemoryChunk* chunk, intptr_t* live_bytes) { ...@@ -3355,7 +3355,8 @@ void FullEvacuator::RawEvacuatePage(MemoryChunk* chunk, intptr_t* live_bytes) {
} else { } else {
// Aborted compaction page. Actual processing happens on the main // Aborted compaction page. Actual processing happens on the main
// thread for simplicity reasons. // thread for simplicity reasons.
collector_->ReportAbortedEvacuationCandidate(failed_object, chunk); collector_->ReportAbortedEvacuationCandidate(failed_object.address(),
chunk);
} }
} }
break; break;
...@@ -4248,39 +4249,37 @@ void MarkCompactCollector::UpdatePointersAfterEvacuation() { ...@@ -4248,39 +4249,37 @@ void MarkCompactCollector::UpdatePointersAfterEvacuation() {
} }
void MarkCompactCollector::ReportAbortedEvacuationCandidate( void MarkCompactCollector::ReportAbortedEvacuationCandidate(
HeapObject failed_object, MemoryChunk* chunk) { Address failed_start, MemoryChunk* chunk) {
base::MutexGuard guard(&mutex_); base::MutexGuard guard(&mutex_);
aborted_evacuation_candidates_.push_back( aborted_evacuation_candidates_.push_back(
std::make_pair(failed_object, static_cast<Page*>(chunk))); std::make_pair(failed_start, static_cast<Page*>(chunk)));
} }
size_t MarkCompactCollector::PostProcessEvacuationCandidates() { size_t MarkCompactCollector::PostProcessEvacuationCandidates() {
CHECK_IMPLIES(FLAG_crash_on_aborted_evacuation, CHECK_IMPLIES(FLAG_crash_on_aborted_evacuation,
aborted_evacuation_candidates_.empty()); aborted_evacuation_candidates_.empty());
for (auto object_and_page : aborted_evacuation_candidates_) { for (auto start_and_page : aborted_evacuation_candidates_) {
HeapObject failed_object = object_and_page.first; Address failed_start = start_and_page.first;
Page* page = object_and_page.second; Page* page = start_and_page.second;
page->SetFlag(Page::COMPACTION_WAS_ABORTED); page->SetFlag(Page::COMPACTION_WAS_ABORTED);
// Aborted compaction page. We have to record slots here, since we // Aborted compaction page. We have to record slots here, since we
// might not have recorded them in first place. // might not have recorded them in first place.
// Remove outdated slots. // Remove outdated slots.
RememberedSetSweeping::RemoveRange(page, page->address(), RememberedSetSweeping::RemoveRange(page, page->address(), failed_start,
failed_object.address(),
SlotSet::FREE_EMPTY_BUCKETS); SlotSet::FREE_EMPTY_BUCKETS);
RememberedSet<OLD_TO_NEW>::RemoveRange(page, page->address(), RememberedSet<OLD_TO_NEW>::RemoveRange(page, page->address(), failed_start,
failed_object.address(),
SlotSet::FREE_EMPTY_BUCKETS); SlotSet::FREE_EMPTY_BUCKETS);
RememberedSet<OLD_TO_NEW>::RemoveRangeTyped(page, page->address(), RememberedSet<OLD_TO_NEW>::RemoveRangeTyped(page, page->address(),
failed_object.address()); failed_start);
// Remove invalidated slots. // Remove invalidated slots.
if (failed_object.address() > page->area_start()) { if (failed_start > page->area_start()) {
InvalidatedSlotsCleanup old_to_new_cleanup = InvalidatedSlotsCleanup old_to_new_cleanup =
InvalidatedSlotsCleanup::OldToNew(page); InvalidatedSlotsCleanup::OldToNew(page);
old_to_new_cleanup.Free(page->area_start(), failed_object.address()); old_to_new_cleanup.Free(page->area_start(), failed_start);
} }
// Recompute live bytes. // Recompute live bytes.
......
...@@ -720,7 +720,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -720,7 +720,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
void ReleaseEvacuationCandidates(); void ReleaseEvacuationCandidates();
// Returns number of aborted pages. // Returns number of aborted pages.
size_t PostProcessEvacuationCandidates(); size_t PostProcessEvacuationCandidates();
void ReportAbortedEvacuationCandidate(HeapObject failed_object, void ReportAbortedEvacuationCandidate(Address failed_start,
MemoryChunk* chunk); MemoryChunk* chunk);
static const int kEphemeronChunkSize = 8 * KB; static const int kEphemeronChunkSize = 8 * KB;
...@@ -774,7 +774,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -774,7 +774,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
// Pages that are actually processed during evacuation. // Pages that are actually processed during evacuation.
std::vector<Page*> old_space_evacuation_pages_; std::vector<Page*> old_space_evacuation_pages_;
std::vector<Page*> new_space_evacuation_pages_; std::vector<Page*> new_space_evacuation_pages_;
std::vector<std::pair<HeapObject, Page*>> aborted_evacuation_candidates_; std::vector<std::pair<Address, Page*>> aborted_evacuation_candidates_;
Sweeper* sweeper_; Sweeper* sweeper_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment