Reviewers: Mads Ager,

Description:
Reverse order in which free blocks in fixed spaces are used for the allocation.

This CL is against r4715 (revision with WBs).

We were using blocks in descending order of addresses. Such order might possibly lead to violation of the allocation watermark invariant (holes of non-allocated
and non-swept space appear below watermark).

Please review this at http://codereview.chromium.org/2276002/show

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/spaces.h
  M     src/spaces.cc


Index: src/spaces.h
===================================================================
--- src/spaces.h        (revision 4715)
+++ src/spaces.h        (working copy)
@@ -1747,6 +1747,9 @@
   // The head of the free list.
   Address head_;

+  // The tail of the free list.
+  Address tail_;
+
   // The identity of the owning space, for building allocation Failure
   // objects.
   AllocationSpace owner_;
Index: src/spaces.cc
===================================================================
--- src/spaces.cc       (revision 4715)
+++ src/spaces.cc       (working copy)
@@ -1825,7 +1825,7 @@

 void FixedSizeFreeList::Reset() {
   available_ = 0;
-  head_ = NULL;
+  head_ = tail_ = NULL;
 }


@@ -1837,8 +1837,13 @@
   ASSERT(!MarkCompactCollector::IsCompacting());
   FreeListNode* node = FreeListNode::FromAddress(start);
   node->set_size(object_size_);
-  node->set_next(head_);
-  head_ = node->address();
+  node->set_next(NULL);
+  if (head_ == NULL) {
+    tail_ = head_ = node->address();
+  } else {
+    FreeListNode::FromAddress(tail_)->set_next(node->address());
+    tail_ = node->address();
+  }
   available_ += object_size_;
 }

@@ -2104,6 +2109,11 @@
       Page* p = Page::FromAddress(obj->address());

       if (obj->address() >= p->AllocationWatermark()) {
+        // The should be no hole between allocation watermark
+        // and allocated object address.
+        // Memory above allocation watermark was not swept and
+        // might contain garbage pointers to new space.
+        ASSERT(obj->address() == p->AllocationWatermark());
         p->SetAllocationWatermark(obj->address() + size_in_bytes);
       }

@@ -2395,6 +2405,11 @@
       Page* p = Page::FromAddress(obj->address());

       if (obj->address() >= p->AllocationWatermark()) {
+        // The should be no hole between allocation watermark
+        // and allocated object address.
+        // Memory above allocation watermark was not swept and
+        // might contain garbage pointers to new space.
+        ASSERT(obj->address() == p->AllocationWatermark());
         p->SetAllocationWatermark(obj->address() + size_in_bytes);
       }



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

Reply via email to