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

Unified Diff: vm/pages.cc

Issue 10093010: - Free completely empty pages as part of sweep. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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 | « vm/pages.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/pages.cc
===================================================================
--- vm/pages.cc (revision 6528)
+++ vm/pages.cc (working copy)
@@ -68,7 +68,6 @@
: freelist_(),
heap_(heap),
pages_(NULL),
- pages_tail_(NULL),
large_pages_(NULL),
bump_page_(NULL),
max_capacity_(max_capacity),
@@ -94,12 +93,8 @@
void PageSpace::AllocatePage() {
HeapPage* page = HeapPage::Allocate(kPageSize, is_executable_);
- if (pages_ == NULL) {
- pages_ = page;
- } else {
- pages_tail_->set_next(page);
- }
- pages_tail_ = page;
+ page->set_next(pages_);
+ pages_ = page;
bump_page_ = NULL; // Reenable scanning of pages for bump allocation.
capacity_ += kPageSize;
}
@@ -115,6 +110,19 @@
}
+void PageSpace::FreePage(HeapPage* page, HeapPage* previous_page) {
+ capacity_ -= page->memory_->size();
+ // Remove the page from the list.
+ if (previous_page != NULL) {
+ previous_page->set_next(page->next());
+ } else {
+ pages_ = page->next();
+ }
+ // TODO(iposva): Consider adding to a pool of empty pages.
+ page->Deallocate();
+}
+
+
void PageSpace::FreeLargePage(HeapPage* page, HeapPage* previous_page) {
capacity_ -= page->memory_->size();
// Remove the page from the list.
@@ -138,21 +146,12 @@
uword PageSpace::TryBumpAllocate(intptr_t size) {
- if (pages_tail_ == NULL) {
- return 0;
- }
- uword result = pages_tail_->TryBumpAllocate(size);
- if (result != 0) {
- return result;
- }
if (bump_page_ == NULL) {
// The bump page has not yet been used: Start at the beginning of the list.
bump_page_ = pages_;
}
- // The last page has already been attempted above.
- while (bump_page_ != pages_tail_) {
- ASSERT(bump_page_->next() != NULL);
- result = bump_page_->TryBumpAllocate(size);
+ while (bump_page_ != NULL) {
+ uword result = bump_page_->TryBumpAllocate(size);
if (result != 0) {
return result;
}
@@ -284,14 +283,22 @@
GCSweeper sweeper(heap_);
intptr_t in_use = 0;
+ HeapPage* prev_page = NULL;
HeapPage* page = pages_;
while (page != NULL) {
intptr_t page_in_use = sweeper.SweepPage(page, &freelist_);
- in_use += page_in_use;
- page = page->next();
+ HeapPage* next_page = page->next();
+ if (page_in_use == 0) {
+ FreePage(page, prev_page);
+ } else {
+ in_use += page_in_use;
+ prev_page = page;
+ }
+ // Advance to the next page.
+ page = next_page;
}
- HeapPage* prev_page = NULL;
+ prev_page = NULL;
page = large_pages_;
while (page != NULL) {
intptr_t page_in_use = sweeper.SweepLargePage(page);
« no previous file with comments | « vm/pages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698