Index: src/heap/spaces.cc |
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc |
index 8879d5e6021b64db80f1f27a8cbf567044f104fb..2625ecb1d0926596d517f8503248f5ca0812d78d 100644 |
--- a/src/heap/spaces.cc |
+++ b/src/heap/spaces.cc |
@@ -1003,6 +1003,42 @@ void PagedSpace::TearDown() { |
} |
+void PagedSpace::MergeCompactionSpace(CompactionSpace* other) { |
+ // Unmerged fields: |
+ // area_size_ |
+ // allocation_info_ |
+ // emergency_memory_ |
+ // end_of_unswept_pages_ |
+ // unswept_free_bytes_ |
+ // anchor_ |
+ |
+ // It only makes sense to merge compatible spaces. |
+ DCHECK(identity() == other->identity()); |
+ |
+ // Destroy the linear allocation space of {other}. This is needed to (a) not |
+ // waste the memory and (b) keep the rest of the chunk in an iterable state |
+ // (filler is needed). |
+ int linear_size = static_cast<int>(other->limit() - other->top()); |
+ other->Free(other->top(), linear_size); |
+ |
+ // Move over the free list. |
+ free_list_.Concatenate(other->free_list()); |
+ |
+ // Update and clear accounting statistics. |
+ accounting_stats_.Merge(other->accounting_stats_); |
+ other->accounting_stats_.Clear(); |
+ |
+ // Move over pages. |
+ PageIterator it(other); |
+ Page* p = nullptr; |
+ while (it.has_next()) { |
+ p = it.next(); |
+ p->set_owner(this); |
+ p->InsertAfter(anchor_.prev_page()); |
+ } |
+} |
+ |
+ |
size_t PagedSpace::CommittedPhysicalMemory() { |
if (!base::VirtualMemory::HasLazyCommits()) return CommittedMemory(); |
MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); |