Chromium Code Reviews| 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(); |
| } |