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

Unified Diff: src/heap/spaces.cc

Issue 1957323003: [heap] Add page evacuation mode for new->new (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Switch threshold flag back to 70 Created 4 years, 6 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 | « src/heap/spaces.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index a0eae92d69f994b9d78be8d544b86beb6bd8eacd..4fe3886e46bb0e62e6e9f4c9d37cfe3458f0acda 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -1386,7 +1386,6 @@ void NewSpace::TearDown() {
from_space_.TearDown();
}
-
void NewSpace::Flip() { SemiSpace::Swap(&from_space_, &to_space_); }
@@ -1432,6 +1431,48 @@ void NewSpace::Shrink() {
DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
}
+bool NewSpace::Rebalance() {
+ CHECK(heap()->promotion_queue()->is_empty());
+ // Order here is important to make use of the page pool.
+ return to_space_.EnsureCurrentCapacity() &&
+ from_space_.EnsureCurrentCapacity();
+}
+
+bool SemiSpace::EnsureCurrentCapacity() {
+ if (is_committed()) {
+ const int expected_pages = current_capacity_ / Page::kPageSize;
+ int actual_pages = 0;
+ Page* current_page = anchor()->next_page();
+ while (current_page != anchor()) {
+ actual_pages++;
+ current_page = current_page->next_page();
+ if (actual_pages > expected_pages) {
+ Page* to_remove = current_page->prev_page();
+ // Make sure we don't overtake the actual top pointer.
+ DCHECK_NE(to_remove, current_page_);
+ to_remove->Unlink();
+ heap()->memory_allocator()->Free<MemoryAllocator::kPooledAndQueue>(
+ to_remove);
+ }
+ }
+ while (actual_pages < expected_pages) {
+ actual_pages++;
+ current_page =
+ heap()->memory_allocator()->AllocatePage<MemoryAllocator::kPooled>(
+ Page::kAllocatableMemory, this, executable());
+ if (current_page == nullptr) return false;
+ DCHECK_NOT_NULL(current_page);
+ current_page->InsertAfter(anchor());
+ Bitmap::Clear(current_page);
+ current_page->SetFlags(anchor()->prev_page()->GetFlags(),
+ Page::kCopyAllFlags);
+ heap()->CreateFillerObjectAt(current_page->area_start(),
+ current_page->area_size(),
+ ClearRecordedSlots::kNo);
+ }
+ }
+ return true;
+}
void LocalAllocationBuffer::Close() {
if (IsValid()) {
@@ -1874,21 +1915,17 @@ void SemiSpace::Reset() {
current_page_ = anchor_.next_page();
}
-bool SemiSpace::ReplaceWithEmptyPage(Page* old_page) {
- // TODO(mlippautz): We do not have to get a new page here when the semispace
- // is uncommitted later on.
- Page* new_page = heap()->memory_allocator()->AllocatePage(
- Page::kAllocatableMemory, this, executable());
- if (new_page == nullptr) return false;
- Bitmap::Clear(new_page);
- new_page->SetFlags(old_page->GetFlags(), Page::kCopyAllFlags);
- new_page->set_next_page(old_page->next_page());
- new_page->set_prev_page(old_page->prev_page());
- old_page->next_page()->set_prev_page(new_page);
- old_page->prev_page()->set_next_page(new_page);
- heap()->CreateFillerObjectAt(new_page->area_start(), new_page->area_size(),
- ClearRecordedSlots::kNo);
- return true;
+void SemiSpace::RemovePage(Page* page) {
+ if (current_page_ == page) {
+ current_page_ = page->prev_page();
+ }
+ page->Unlink();
+}
+
+void SemiSpace::PrependPage(Page* page) {
+ page->SetFlags(current_page()->GetFlags(), Page::kCopyAllFlags);
+ page->set_owner(this);
+ page->InsertAfter(anchor());
}
void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) {
« no previous file with comments | « src/heap/spaces.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698