When shrinking semispace don't relink pages if semispace is not committed

R=mstarzinger@chromium.org

Review URL: http://codereview.chromium.org/9086005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10333 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
vegorov@chromium.org 2012-01-04 19:59:01 +00:00
parent 2335545108
commit e726c00ea6

View File

@ -1256,24 +1256,29 @@ bool SemiSpace::ShrinkTo(int new_capacity) {
ASSERT((new_capacity & Page::kPageAlignmentMask) == 0); ASSERT((new_capacity & Page::kPageAlignmentMask) == 0);
ASSERT(new_capacity >= initial_capacity_); ASSERT(new_capacity >= initial_capacity_);
ASSERT(new_capacity < capacity_); ASSERT(new_capacity < capacity_);
// Semispaces grow backwards from the end of their allocated capacity, if (is_committed()) {
// so we find the before and after start addresses relative to the // Semispaces grow backwards from the end of their allocated capacity,
// end of the space. // so we find the before and after start addresses relative to the
Address space_end = start_ + maximum_capacity_; // end of the space.
Address old_start = space_end - capacity_; Address space_end = start_ + maximum_capacity_;
size_t delta = capacity_ - new_capacity; Address old_start = space_end - capacity_;
ASSERT(IsAligned(delta, OS::AllocateAlignment())); size_t delta = capacity_ - new_capacity;
if (!heap()->isolate()->memory_allocator()->UncommitBlock(old_start, delta)) { ASSERT(IsAligned(delta, OS::AllocateAlignment()));
return false;
}
capacity_ = new_capacity;
int pages_after = capacity_ / Page::kPageSize; MemoryAllocator* allocator = heap()->isolate()->memory_allocator();
NewSpacePage* new_last_page = if (!allocator->UncommitBlock(old_start, delta)) {
NewSpacePage::FromAddress(space_end - pages_after * Page::kPageSize); return false;
new_last_page->set_next_page(anchor()); }
anchor()->set_prev_page(new_last_page);
ASSERT((current_page_ <= first_page()) && (current_page_ >= new_last_page)); int pages_after = new_capacity / Page::kPageSize;
NewSpacePage* new_last_page =
NewSpacePage::FromAddress(space_end - pages_after * Page::kPageSize);
new_last_page->set_next_page(anchor());
anchor()->set_prev_page(new_last_page);
ASSERT((current_page_ <= first_page()) && (current_page_ >= new_last_page));
}
capacity_ = new_capacity;
return true; return true;
} }