Commit 1e022278 authored by erikcorry's avatar erikcorry Committed by Commit bot

More robust when allocation fails during compaction

R=ulan@chromium.org
BUG=chromium:473307
LOG=yes

Review URL: https://codereview.chromium.org/1068833002

Cr-Commit-Position: refs/heads/master@{#27637}
parent 77e6efd8
......@@ -3322,12 +3322,13 @@ void MarkCompactCollector::EvacuatePages() {
// Allocate emergency memory for the case when compaction fails due to out
// of memory.
if (!space->HasEmergencyMemory()) {
space->CreateEmergencyMemory();
space->CreateEmergencyMemory(); // If the OS lets us.
}
if (p->IsEvacuationCandidate()) {
// During compaction we might have to request a new page. Check that we
// have an emergency page and the space still has room for that.
if (space->HasEmergencyMemory() || space->CanExpand()) {
// During compaction we might have to request a new page in order to free
// up a page. Check that we actually got an emergency page above so we
// can guarantee that this succeeds.
if (space->HasEmergencyMemory()) {
EvacuateLiveObjectsFromPage(p);
// Unlink the page from the list of pages here. We must not iterate
// over that page later (e.g. when scan on scavenge pages are
......
......@@ -1152,6 +1152,11 @@ void PagedSpace::FreeEmergencyMemory() {
void PagedSpace::UseEmergencyMemory() {
// Page::Initialize makes the chunk into a real page and adds it to the
// accounting for this space. Unlike PagedSpace::Expand, we don't check
// CanExpand first, so we can go over the limits a little here. That's OK,
// because we are in the process of compacting which will free up at least as
// much memory as it allocates.
Page* page = Page::Initialize(heap(), emergency_memory_, executable(), this);
page->InsertAfter(anchor_.prev_page());
emergency_memory_ = NULL;
......
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