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

Unified Diff: vm/pages.cc

Issue 11186013: - Do not bump allocate in old-space pages. Always use (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 2 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
« vm/pages.h ('K') | « 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 13711)
+++ vm/pages.cc (working copy)
@@ -31,7 +31,6 @@
result->memory_ = memory;
result->next_ = NULL;
result->used_ = 0;
- result->top_ = result->first_object_start();
return result;
}
@@ -51,7 +50,7 @@
void HeapPage::VisitObjects(ObjectVisitor* visitor) const {
uword obj_addr = first_object_start();
- uword end_addr = top();
+ uword end_addr = end();
while (obj_addr < end_addr) {
RawObject* raw_obj = RawObject::FromAddr(obj_addr);
visitor->VisitObject(raw_obj);
@@ -63,7 +62,7 @@
void HeapPage::VisitObjectPointers(ObjectPointerVisitor* visitor) const {
uword obj_addr = first_object_start();
- uword end_addr = top();
+ uword end_addr = end();
while (obj_addr < end_addr) {
RawObject* raw_obj = RawObject::FromAddr(obj_addr);
obj_addr += raw_obj->VisitPointers(visitor);
@@ -74,7 +73,7 @@
RawObject* HeapPage::FindObject(FindObjectVisitor* visitor) const {
uword obj_addr = first_object_start();
- uword end_addr = top();
+ uword end_addr = end();
while (obj_addr < end_addr) {
RawObject* raw_obj = RawObject::FromAddr(obj_addr);
if (raw_obj->FindObject(visitor)) {
@@ -99,7 +98,6 @@
pages_(NULL),
pages_tail_(NULL),
large_pages_(NULL),
- bump_page_(NULL),
max_capacity_(max_capacity),
capacity_(0),
in_use_(0),
@@ -125,7 +123,7 @@
}
-void PageSpace::AllocatePage() {
+HeapPage* PageSpace::AllocatePage() {
HeapPage* page = HeapPage::Allocate(kPageSize, is_executable_);
if (pages_ == NULL) {
pages_ = page;
@@ -133,8 +131,8 @@
pages_tail_->set_next(page);
}
pages_tail_ = page;
- bump_page_ = NULL; // Reenable scanning of pages for bump allocation.
capacity_ += kPageSize;
+ return page;
}
@@ -186,32 +184,6 @@
}
-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);
- if (result != 0) {
- return result;
- }
- bump_page_ = bump_page_->next();
- }
- // Ran through all of the pages trying to bump allocate: Give up.
- return 0;
-}
-
-
uword PageSpace::TryAllocate(intptr_t size) {
return TryAllocate(size, kControlGrowth);
}
@@ -223,16 +195,19 @@
uword result = 0;
if (size < kAllocatablePageSize) {
result = freelist_.TryAllocate(size);
- if (result == 0) {
- result = TryBumpAllocate(size);
- if ((result == 0) &&
- (page_space_controller_.CanGrowPageSpace(size) ||
- growth_policy == kForceGrowth) &&
- CanIncreaseCapacity(kPageSize)) {
- AllocatePage();
- result = TryBumpAllocate(size);
- ASSERT(result != 0);
- }
+ if ((result == 0) &&
+ (page_space_controller_.CanGrowPageSpace(size) ||
+ growth_policy == kForceGrowth) &&
+ CanIncreaseCapacity(kPageSize)) {
+ HeapPage* page = AllocatePage();
+ ASSERT(page != NULL);
+ // Start of the newly allocated page is the allocated object.
+ result = page->first_object_start();
+ // Enqueue the remainder in the free list.
+ uword free_start = result + size;
+ freelist_.Free(
+ free_start,
+ Utils::RoundDown(page->end() - free_start, kObjectAlignment));
}
} else {
// Large page allocation.
@@ -244,14 +219,14 @@
if (CanIncreaseCapacity(page_size)) {
HeapPage* page = AllocateLargePage(size);
if (page != NULL) {
- result = page->top();
- page->set_top(result + size);
+ result = page->first_object_start();
}
}
}
if (result != 0) {
in_use_ += size;
}
+ ASSERT((result & kObjectAlignmentMask) == kOldObjectAlignmentOffset);
return result;
}
@@ -302,7 +277,9 @@
page = large_pages_;
while (page != NULL) {
- page->VisitObjects(visitor);
+ uword obj_addr = page->first_object_start();
cshapiro 2012/10/17 02:53:22 Why did this code have to change? This was done i
Ivan Posva 2012/10/18 17:34:21 I did not like the expansion either. Now that I ha
+ RawObject* raw_obj = RawObject::FromAddr(obj_addr);
+ visitor->VisitObject(raw_obj);
page = page->next();
}
}
@@ -337,7 +314,9 @@
page = large_pages_;
while (page != NULL) {
- page->VisitObjectPointers(visitor);
+ uword obj_addr = page->first_object_start();
cshapiro 2012/10/17 02:53:22 ditto
+ RawObject* raw_obj = RawObject::FromAddr(obj_addr);
+ raw_obj->VisitPointers(visitor);
page = page->next();
}
}
@@ -356,9 +335,10 @@
page = large_pages_;
while (page != NULL) {
- RawObject* obj = page->FindObject(visitor);
- if (obj != Object::null()) {
- return obj;
+ uword obj_addr = page->first_object_start();
cshapiro 2012/10/17 02:53:22 ditto
+ RawObject* raw_obj = RawObject::FromAddr(obj_addr);
+ if (raw_obj->FindObject(visitor)) {
+ return raw_obj;
}
page = page->next();
}
@@ -409,7 +389,6 @@
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_);
« vm/pages.h ('K') | « vm/pages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698