Reviewers: ulan,
Description:
More robust when allocation fails during compaction
[email protected]
BUG=473307
LOG=yes
Please review this at https://codereview.chromium.org/1068833002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+10, -4 lines):
M src/heap/mark-compact.cc
M src/heap/spaces.cc
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index
be1825f40bf0a75bdeae1ab33c83995652681d1b..ada69add09e39998621abe3072ff7ec69b830dea
100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -3354,12 +3354,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
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index
d372083a4a63aee1e48dbc4a18950a9ffa79e39e..d60faa0a6678cf4279a2b2dab847c7ec4d46c899
100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -1164,6 +1164,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;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.