Commit 4c880dec authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Bail out to regular evacuation if new->old fails to allocate a page

BUG=chromium:607226, chromium:581412
LOG=N

Review-Url: https://codereview.chromium.org/1928883002
Cr-Commit-Position: refs/heads/master@{#35844}
parent 2f1df8a3
......@@ -1801,10 +1801,11 @@ class MarkCompactCollector::EvacuateNewSpacePageVisitor final
public:
EvacuateNewSpacePageVisitor() : promoted_size_(0) {}
static void MoveToOldSpace(Page* page, PagedSpace* owner) {
page->heap()->new_space()->ReplaceWithEmptyPage(page);
Page* new_page = Page::ConvertNewToOld(page, owner);
new_page->SetFlag(Page::PAGE_NEW_OLD_PROMOTION);
static void TryMoveToOldSpace(Page* page, PagedSpace* owner) {
if (page->heap()->new_space()->ReplaceWithEmptyPage(page)) {
Page* new_page = Page::ConvertNewToOld(page, owner);
new_page->SetFlag(Page::PAGE_NEW_OLD_PROMOTION);
}
}
inline bool Visit(HeapObject* object) {
......@@ -3293,7 +3294,7 @@ void MarkCompactCollector::EvacuatePagesInParallel() {
(page->LiveBytes() > Evacuator::PageEvacuationThreshold()) &&
page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) &&
!page->Contains(age_mark)) {
EvacuateNewSpacePageVisitor::MoveToOldSpace(page, heap()->old_space());
EvacuateNewSpacePageVisitor::TryMoveToOldSpace(page, heap()->old_space());
}
job.AddPage(page, &abandoned_pages);
}
......
......@@ -1826,9 +1826,12 @@ void SemiSpace::Reset() {
current_page_ = anchor_.next_page();
}
void SemiSpace::ReplaceWithEmptyPage(Page* old_page) {
bool SemiSpace::ReplaceWithEmptyPage(Page* old_page) {
// TODO(mlippautz): We do not have to get a new page here when the semispace
// is uncommitted later on.
Page* new_page = heap()->memory_allocator()->AllocatePage(
Page::kAllocatableMemory, this, executable());
if (new_page == nullptr) return false;
Bitmap::Clear(new_page);
new_page->SetFlags(old_page->GetFlags(), Page::kCopyAllFlags);
new_page->set_next_page(old_page->next_page());
......@@ -1837,6 +1840,7 @@ void SemiSpace::ReplaceWithEmptyPage(Page* old_page) {
old_page->prev_page()->set_next_page(new_page);
heap()->CreateFillerObjectAt(new_page->area_start(), new_page->area_size(),
ClearRecordedSlots::kNo);
return true;
}
void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) {
......
......@@ -2381,7 +2381,7 @@ class SemiSpace : public Space {
// Resets the space to using the first page.
void Reset();
void ReplaceWithEmptyPage(Page* page);
bool ReplaceWithEmptyPage(Page* page);
// Age mark accessors.
Address age_mark() { return age_mark_; }
......@@ -2603,10 +2603,10 @@ class NewSpace : public Space {
inline size_t AllocatedSinceLastGC();
void ReplaceWithEmptyPage(Page* page) {
bool ReplaceWithEmptyPage(Page* page) {
// This method is called after flipping the semispace.
DCHECK(page->InFromSpace());
from_space_.ReplaceWithEmptyPage(page);
return from_space_.ReplaceWithEmptyPage(page);
}
// Return the maximum capacity of a semispace.
......
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