Revision: 4484
Author: [email protected]
Date: Fri Apr 23 05:45:05 2010
Log: - 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
http://code.google.com/p/v8/source/detail?r=4484

Modified:
 /branches/bleeding_edge/src/mark-compact.cc
 /branches/bleeding_edge/src/spaces.cc
 /branches/bleeding_edge/src/spaces.h

=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Thu Apr 22 09:43:38 2010
+++ /branches/bleeding_edge/src/mark-compact.cc Fri Apr 23 05:45:05 2010
@@ -1282,9 +1282,15 @@
   // 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 @@
     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 @@
     } 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 @@
   // 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 @@
   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);
=======================================
--- /branches/bleeding_edge/src/spaces.cc       Thu Apr 22 09:43:38 2010
+++ /branches/bleeding_edge/src/spaces.cc       Fri Apr 23 05:45:05 2010
@@ -666,7 +666,7 @@

 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 @@
     }

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

=======================================
--- /branches/bleeding_edge/src/spaces.h        Thu Apr 22 09:43:38 2010
+++ /branches/bleeding_edge/src/spaces.h        Fri Apr 23 05:45:05 2010
@@ -641,7 +641,7 @@

   static Page* RelinkPagesInChunk(int chunk_id,
                                   Address chunk_start,
-                                  int chunk_size,
+                                  size_t chunk_size,
                                   Page* prev,
                                   Page** last_page_in_use);
 };

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to