// 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
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;
}
} 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
// 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());
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);
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);
}
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
// 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
// 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);
}
}