Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: src/mark-compact.cc

Issue 7870003: Guard against rare case of allocation failure during evacuation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/spaces.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index 176c9d906c5a3a937d19db67be61975e91b3efdb..a19df8eb3ba3a10c13df44492d905e44a82e8b15 100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -2576,10 +2576,16 @@ void MarkCompactCollector::EvacuateLiveObjectsFromPage(Page* p) {
int size = object->Size();
- // This should never fail as we are in always allocate scope.
- Object* target = space->AllocateRaw(size)->ToObjectUnchecked();
+ MaybeObject* target = space->AllocateRaw(size);
+ if (target->IsFailure()) {
+ // OS refused to give us memory.
+ V8::FatalProcessOutOfMemory("Evacuation");
+ return;
+ }
- MigrateObject(HeapObject::cast(target)->address(),
+ Object* target_object = target->ToObjectUnchecked();
+
+ MigrateObject(HeapObject::cast(target_object)->address(),
object_addr,
size,
space->identity());
@@ -2599,7 +2605,19 @@ void MarkCompactCollector::EvacuatePages() {
ASSERT(p->IsEvacuationCandidate() ||
p->IsFlagSet(Page::RESCAN_ON_EVACUATION));
if (p->IsEvacuationCandidate()) {
- EvacuateLiveObjectsFromPage(p);
+ // During compaction we might have to request a new page.
+ // Check that space still have room for that.
+ if (static_cast<PagedSpace*>(p->owner())->CanExpand()) {
+ EvacuateLiveObjectsFromPage(p);
+ } else {
+ // Without room for expansion evacuation is not guaranteed to succeed.
+ // Pessimistically abandon unevacuated pages.
+ for (int j = i; j < npages; j++) {
+ evacuation_candidates_[j]->ClearEvacuationCandidate();
+ evacuation_candidates_[j]->SetFlag(Page::RESCAN_ON_EVACUATION);
+ }
+ return;
+ }
}
}
}
@@ -2807,10 +2825,14 @@ void MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
PagedSpace* space = static_cast<PagedSpace*>(p->owner());
p->ClearFlag(MemoryChunk::RESCAN_ON_EVACUATION);
- SweepPrecisely(space,
- p,
- SWEEP_AND_VISIT_LIVE_OBJECTS,
- &updating_visitor);
+ if (space->identity() == OLD_DATA_SPACE) {
+ SweepConservatively(space, p);
+ } else {
+ SweepPrecisely(space,
+ p,
+ SWEEP_AND_VISIT_LIVE_OBJECTS,
+ &updating_visitor);
+ }
}
}
« no previous file with comments | « no previous file | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698