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

Unified Diff: runtime/vm/pages.cc

Issue 10191014: Reland r6578 without changing the order of pages in the PageSpace::pages_ list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 | « runtime/vm/pages.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.cc
diff --git a/runtime/vm/pages.cc b/runtime/vm/pages.cc
index b0a36aa57c3dd8b3d081d3c24daac8f88dfd2819..9194db706929bba0878cf8cb99152001e32b1dba 100644
--- a/runtime/vm/pages.cc
+++ b/runtime/vm/pages.cc
@@ -115,6 +115,22 @@ HeapPage* PageSpace::AllocateLargePage(intptr_t size) {
}
+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();
+ }
+ if (page == pages_tail_) {
+ pages_tail_ = previous_page;
+ }
+ // 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.
@@ -284,14 +300,22 @@ void PageSpace::MarkSweep(bool invoke_api_callbacks) {
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 | « runtime/vm/pages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698