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

Unified Diff: src/heap/spaces.cc

Issue 1314493007: [heap] Add compaction space. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor fixes Created 5 years, 4 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
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());

Powered by Google App Engine
This is Rietveld 408576698