Reviewers: Erik Corry,

Description:
Do not SortUniq store buffer before a regular iteration.

Iteration callback will rebuild store buffer effectively removing all
duplicates.

Please review this at http://codereview.chromium.org/6713069/

SVN Base: https://v8.googlecode.com/svn/branches/experimental/gc

Affected files:
  M src/store-buffer.h
  M src/store-buffer.cc


Index: src/store-buffer.cc
diff --git a/src/store-buffer.cc b/src/store-buffer.cc
index 598b96cea0b398225759e67f31c84baa17ade3ac..8172d2bae1e5a40e557514bf57fff4f2b6e73590 100644
--- a/src/store-buffer.cc
+++ b/src/store-buffer.cc
@@ -96,7 +96,6 @@ void StoreBuffer::TearDown() {
 }


-
 #if V8_TARGET_ARCH_X64
 static int CompareAddresses(const void* void_a, const void* void_b) {
   intptr_t a =
@@ -161,6 +160,16 @@ void StoreBuffer::SortUniq() {
 }


+void StoreBuffer::PrepareForIteration() {
+  Compact();
+  if (store_buffer_mode() == kStoreBufferDisabled) {
+    old_top_ = old_start_;
+    return;
+  }
+  ZapHashTables();
+}
+
+
 #ifdef DEBUG
 void StoreBuffer::Clean() {
   if (store_buffer_mode() == kStoreBufferDisabled) {
@@ -256,7 +265,10 @@ void StoreBuffer::GCEpilogue(GCType type, GCCallbackFlags flags) {

 void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback callback) {
   if (store_buffer_mode() == kStoreBufferFunctional) {
-    SortUniq();
+ // We do not sort or remove duplicated entries from the store buffer because
+    // we expect that callback will rebuild the store buffer thus removing
+    // all duplicates and pointers to old space.
+    PrepareForIteration();
   }
   if (store_buffer_mode() != kStoreBufferFunctional) {
     old_top_ = old_start_;
@@ -287,14 +299,10 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback callback) {
         Object* object = *cell;
         // May be invalid if object is not in new space.
         HeapObject* heap_object = reinterpret_cast<HeapObject*>(object);
-        if (Heap::InNewSpace(object)) {
+        if (Heap::InFromSpace(object)) {
           callback(reinterpret_cast<HeapObject**>(cell), heap_object);
         }
         ASSERT(old_top_ == saved_top + 1 || old_top_ == saved_top);
-        ASSERT((old_top_ == saved_top + 1) ==
-               (Heap::InNewSpace(*cell) &&
-                   !Heap::InNewSpace(reinterpret_cast<Address>(cell)) &&
-                   Memory::Address_at(heap_object->address()) != NULL));
       }
     }
   }
Index: src/store-buffer.h
diff --git a/src/store-buffer.h b/src/store-buffer.h
index b41b438260e7a575e0fb2b8e456c0a7d7820fb79..e09882341fbaee005cdd2c3ea6be88a2db63647e 100644
--- a/src/store-buffer.h
+++ b/src/store-buffer.h
@@ -98,6 +98,8 @@ class StoreBuffer : public AllStatic {
   static void SortUniq();
   static void Verify();

+  static void PrepareForIteration();
+
 #ifdef DEBUG
   static void Clean();
   // Slow, for asserts only.


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

Reply via email to