Index: src/heap/spaces.cc |
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc |
index 827f3abb607a9ec7e8a82d58de548bd3e83c37e8..6c2b58b17e5795995911aa6a992226ce8050ef18 100644 |
--- a/src/heap/spaces.cc |
+++ b/src/heap/spaces.cc |
@@ -1019,7 +1019,8 @@ bool PagedSpace::CanExpand() { |
DCHECK(max_capacity_ % AreaSize() == 0); |
DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); |
DCHECK(heap()->CommittedOldGenerationMemory() <= |
- heap()->MaxOldGenerationSize()); |
+ heap()->MaxOldGenerationSize() + |
+ PagedSpace::MaxEmergencyMemoryAllocated()); |
// Are we going to exceed capacity for this space? |
if (!heap()->CanExpandOldGeneration(Page::kPageSize)) return false; |
@@ -1046,7 +1047,8 @@ bool PagedSpace::Expand() { |
DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); |
DCHECK(heap()->CommittedOldGenerationMemory() <= |
- heap()->MaxOldGenerationSize()); |
+ heap()->MaxOldGenerationSize() + |
+ PagedSpace::MaxEmergencyMemoryAllocated()); |
p->InsertAfter(anchor_.prev_page()); |
@@ -1128,6 +1130,15 @@ void PagedSpace::ReleasePage(Page* page) { |
} |
+intptr_t PagedSpace::MaxEmergencyMemoryAllocated() { |
+ // New space and large object space. |
+ static const int spaces_without_emergency_memory = 2; |
+ static const int spaces_with_emergency_memory = |
+ LAST_SPACE - FIRST_SPACE + 1 - spaces_without_emergency_memory; |
+ return Page::kPageSize * spaces_with_emergency_memory; |
+} |
+ |
+ |
void PagedSpace::CreateEmergencyMemory() { |
if (identity() == CODE_SPACE) { |
// Make the emergency block available to the allocator. |