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

Unified Diff: vm/pages.cc

Issue 10057001: - Use the unused top of old-space pages when allocating. (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 6398)
+++ vm/pages.cc (working copy)
@@ -70,6 +70,7 @@
pages_(NULL),
pages_tail_(NULL),
large_pages_(NULL),
+ bump_page_(NULL),
max_capacity_(max_capacity),
capacity_(0),
in_use_(0),
@@ -99,6 +100,7 @@
pages_tail_->set_next(page);
}
pages_tail_ = page;
+ bump_page_ = NULL; // Reenable scanning of pages for bump allocation.
capacity_ += kPageSize;
}
@@ -136,17 +138,28 @@
uword PageSpace::TryBumpAllocate(intptr_t size) {
- HeapPage* page = pages_tail_;
- if (page == NULL) {
+ if (pages_tail_ == NULL) {
return 0;
}
- uword result = page->top();
- intptr_t remaining_space = page->end() - result;
- if (remaining_space < size) {
- return 0;
+ uword result = pages_tail_->TryBumpAllocate(size);
+ if (result != 0) {
+ return result;
}
- page->set_top(result + size);
- 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);
+ if (result != 0) {
+ return result;
+ }
+ bump_page_ = bump_page_->next();
+ }
+ // Ran through all of the pages trying to bump allocate: Give up.
+ return 0;
}
@@ -264,6 +277,8 @@
GCMarker marker(heap_);
marker.MarkObjects(isolate, this, invoke_api_callbacks);
+ // Reset the bump allocation page to unused.
+ bump_page_ = NULL;
// Reset the freelists and setup sweeping.
freelist_.Reset();
GCSweeper sweeper(heap_);
@@ -271,7 +286,8 @@
HeapPage* page = pages_;
while (page != NULL) {
- in_use += sweeper.SweepPage(page, &freelist_);
+ intptr_t page_in_use = sweeper.SweepPage(page, &freelist_);
+ in_use += page_in_use;
ricow1 2012/04/11 10:23:30 Why this change? (easier debugging?)
Ivan Posva 2012/04/11 11:56:52 Yes, and preparation for the next step. Freeing of
page = page->next();
}
« 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