- Fix Win64 build.

- Style cleanup: use Page::is_valid() instead of NULL-check, use Heap::CreateFillerObjectAt() instead of dummy free list nodes
Review URL: http://codereview.chromium.org/1691009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4484 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
vegorov@chromium.org 2010-04-23 12:45:05 +00:00
parent 3ca99e722b
commit 1760038348
3 changed files with 32 additions and 25 deletions

View File

@ -1282,9 +1282,15 @@ static void SweepSpace(PagedSpace* space, DeallocateFunction dealloc) {
// During sweeping of paged space we are trying to find longest sequences
// of pages without live objects and free them (instead of putting them on
// the free list).
Page* prev = NULL; // Page preceding current.
Page* first_empty_page = NULL; // First empty page in a sequence.
Page* prec_first_empty_page = NULL; // Page preceding first empty page.
// Page preceding current.
Page* prev = Page::FromAddress(NULL);
// First empty page in a sequence.
Page* first_empty_page = Page::FromAddress(NULL);
// Page preceding first empty page.
Page* prec_first_empty_page = Page::FromAddress(NULL);
// If last used page of space ends with a sequence of dead objects
// we can adjust allocation top instead of puting this free area into
@ -1331,7 +1337,7 @@ static void SweepSpace(PagedSpace* space, DeallocateFunction dealloc) {
if (page_is_empty) {
// This page is empty. Check whether we are in the middle of
// sequence of empty pages and start one if not.
if (first_empty_page == NULL) {
if (!first_empty_page->is_valid()) {
first_empty_page = p;
prec_first_empty_page = prev;
}
@ -1347,9 +1353,9 @@ static void SweepSpace(PagedSpace* space, DeallocateFunction dealloc) {
} else {
// This page is not empty. Sequence of empty pages ended on the previous
// one.
if (first_empty_page != NULL) {
if (first_empty_page->is_valid()) {
space->FreePages(prec_first_empty_page, prev);
prec_first_empty_page = first_empty_page = NULL;
prec_first_empty_page = first_empty_page = Page::FromAddress(NULL);
}
// If there is a free ending area on one of the previous pages we have
@ -1374,7 +1380,7 @@ static void SweepSpace(PagedSpace* space, DeallocateFunction dealloc) {
// We reached end of space. See if we need to adjust allocation top.
Address new_allocation_top = NULL;
if (first_empty_page != NULL) {
if (first_empty_page->is_valid()) {
// Last used pages in space are empty. We can move allocation top backwards
// to the beginning of first empty page.
ASSERT(prev == space->AllocationTopPage());
@ -1393,12 +1399,13 @@ static void SweepSpace(PagedSpace* space, DeallocateFunction dealloc) {
if (new_allocation_top != NULL) {
#ifdef DEBUG
Page* new_allocation_top_page = Page::FromAllocationTop(new_allocation_top);
ASSERT(((first_empty_page == NULL) &&
(new_allocation_top_page == space->AllocationTopPage())) ||
((first_empty_page != NULL) && (last_free_size > 0) &&
(new_allocation_top_page == prec_first_empty_page)) ||
((first_empty_page != NULL) && (last_free_size == 0) &&
(new_allocation_top_page == first_empty_page)));
if (!first_empty_page->is_valid()) {
ASSERT(new_allocation_top_page == space->AllocationTopPage());
} else if (last_free_size > 0) {
ASSERT(new_allocation_top_page == prec_first_empty_page);
} else {
ASSERT(new_allocation_top_page == first_empty_page);
}
#endif
space->SetTop(new_allocation_top);

View File

@ -666,7 +666,7 @@ void MemoryAllocator::RelinkPageListInChunkOrder(PagedSpace* space,
Page* MemoryAllocator::RelinkPagesInChunk(int chunk_id,
Address chunk_start,
int chunk_size,
size_t chunk_size,
Page* prev,
Page** last_page_in_use) {
Address page_addr = RoundUp(chunk_start, Page::kPageSize);
@ -1992,20 +1992,20 @@ void PagedSpace::PrepareForMarkCompact(bool will_compact) {
}
if (!page_list_is_chunk_ordered_) {
Page* new_last_in_use = NULL;
Page* new_last_in_use = Page::FromAddress(NULL);
MemoryAllocator::RelinkPageListInChunkOrder(this,
&first_page_,
&last_page_,
&new_last_in_use);
ASSERT(new_last_in_use != NULL);
ASSERT(new_last_in_use->is_valid());
if (new_last_in_use != last_in_use) {
// Current allocation top points to a page which is now in the middle
// of page list. We should move allocation top forward to the new last
// used page so various object iterators will continue to work properly.
int size_in_bytes =
PageAllocationLimit(last_in_use) - last_in_use->AllocationTop();
int size_in_bytes = static_cast<int>(PageAllocationLimit(last_in_use) -
last_in_use->AllocationTop());
if (size_in_bytes > 0) {
// There is still some space left on this page. Create a fake
@ -2013,9 +2013,8 @@ void PagedSpace::PrepareForMarkCompact(bool will_compact) {
// Otherwise iterators would not be able to scan this page
// correctly.
FreeListNode* node =
FreeListNode::FromAddress(last_in_use->AllocationTop());
node->set_size(size_in_bytes);
Heap::CreateFillerObjectAt(last_in_use->AllocationTop(),
size_in_bytes);
}
// New last in use page was in the middle of the list before
@ -2033,9 +2032,10 @@ void PagedSpace::PrepareForMarkCompact(bool will_compact) {
// Empty page is in the middle of a sequence of used pages.
// Create a fake object which will occupy all free space on this page.
// Otherwise iterators would not be able to scan this page correctly.
FreeListNode* node =
FreeListNode::FromAddress(p->ObjectAreaStart());
node->set_size(PageAllocationLimit(p) - p->ObjectAreaStart());
int size_in_bytes = static_cast<int>(PageAllocationLimit(p) -
p->ObjectAreaStart());
Heap::CreateFillerObjectAt(p->ObjectAreaStart(), size_in_bytes);
}
}

View File

@ -641,7 +641,7 @@ class MemoryAllocator : public AllStatic {
static Page* RelinkPagesInChunk(int chunk_id,
Address chunk_start,
int chunk_size,
size_t chunk_size,
Page* prev,
Page** last_page_in_use);
};