Reviewers: jarin,

Description:
Remove lazy sweeping of new space and corresponding complicated pointer updating
logic.

We can do that now since we have the invariant that the store buffer always has
valid slots after marking.

BUG=

Please review this at https://codereview.chromium.org/991853002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+18, -58 lines):
  M src/heap/mark-compact.cc
  M src/heap/store-buffer.h
  M src/heap/store-buffer.cc


Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 8539596a62e5cfbd8f4c8850f929ade5e31f1d96..f97f45bf81b1c51dd80150be477147bf84e5a0d2 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -3007,20 +3007,8 @@ void PointersUpdatingVisitor::CheckLayoutDescriptorAndDie(Heap* heap,


 static void UpdatePointer(HeapObject** address, HeapObject* object) {
-  Address new_addr = Memory::Address_at(object->address());
-
-  // The new space sweep will overwrite the map word of dead objects
-  // with NULL. In this case we do not need to transfer this entry to
-  // the store buffer which we are rebuilding.
-  // We perform the pointer update with a no barrier compare-and-swap. The
- // compare and swap may fail in the case where the pointer update tries to
-  // update garbage memory which was concurrently accessed by the sweeper.
-  if (new_addr != NULL) {
-    base::NoBarrier_CompareAndSwap(
-        reinterpret_cast<base::AtomicWord*>(address),
-        reinterpret_cast<base::AtomicWord>(object),
- reinterpret_cast<base::AtomicWord>(HeapObject::FromAddress(new_addr)));
-  }
+  // Update the slot to point to
+ *address = HeapObject::FromAddress(Memory::Address_at(object->address()));
 }


@@ -3649,8 +3637,7 @@ void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { GCTracer::Scope::MC_UPDATE_OLD_TO_NEW_POINTERS);
     StoreBufferRebuildScope scope(heap_, heap_->store_buffer(),
                                   &Heap::ScavengeStoreBufferCallback);
-    heap_->store_buffer()->IteratePointersToNewSpaceAndClearMaps(
-        &UpdatePointer);
+    heap_->store_buffer()->IteratePointersToNewSpace(&UpdatePointer);
   }

   {
Index: src/heap/store-buffer.cc
diff --git a/src/heap/store-buffer.cc b/src/heap/store-buffer.cc
index 62ace0f891acafa31cad031dddfab7ce229a2b1a..b07e6a7dbcd1247478b5c6abf1524bf3d7911cf7 100644
--- a/src/heap/store-buffer.cc
+++ b/src/heap/store-buffer.cc
@@ -379,8 +379,7 @@ void StoreBuffer::GCEpilogue() {


 void StoreBuffer::ProcessOldToNewSlot(Address slot_address,
-                                      ObjectSlotCallback slot_callback,
-                                      bool clear_maps) {
+                                      ObjectSlotCallback slot_callback) {
   Object** slot = reinterpret_cast<Object**>(slot_address);
   Object* object = reinterpret_cast<Object*>(
       base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot)));
@@ -390,9 +389,6 @@ void StoreBuffer::ProcessOldToNewSlot(Address slot_address,
   if (heap_->InFromSpace(object)) {
     HeapObject* heap_object = reinterpret_cast<HeapObject*>(object);
     DCHECK(heap_object->IsHeapObject());
-    // The new space object was not promoted if it still contains a map
-    // pointer. Clear the map field now lazily (during full GC).
-    if (clear_maps) ClearDeadObject(heap_object);
     slot_callback(reinterpret_cast<HeapObject**>(slot), heap_object);
     object = reinterpret_cast<Object*>(
         base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot)));
@@ -408,17 +404,16 @@ void StoreBuffer::ProcessOldToNewSlot(Address slot_address,


 void StoreBuffer::FindPointersToNewSpaceInRegion(
-    Address start, Address end, ObjectSlotCallback slot_callback,
-    bool clear_maps) {
+    Address start, Address end, ObjectSlotCallback slot_callback) {
   for (Address slot_address = start; slot_address < end;
        slot_address += kPointerSize) {
-    ProcessOldToNewSlot(slot_address, slot_callback, clear_maps);
+    ProcessOldToNewSlot(slot_address, slot_callback);
   }
 }


-void StoreBuffer::IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback,
-                                               bool clear_maps) {
+void StoreBuffer::IteratePointersInStoreBuffer(
+    ObjectSlotCallback slot_callback) {
   Address* limit = old_top_;
   old_top_ = old_start_;
   {
@@ -427,7 +422,7 @@ void StoreBuffer::IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback,
 #ifdef DEBUG
       Address* saved_top = old_top_;
 #endif
-      ProcessOldToNewSlot(*current, slot_callback, clear_maps);
+      ProcessOldToNewSlot(*current, slot_callback);
       DCHECK(old_top_ == saved_top + 1 || old_top_ == saved_top);
     }
   }
@@ -469,18 +464,6 @@ void StoreBuffer::VerifyValidStoreBufferEntries() {


void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback) {
-  IteratePointersToNewSpace(slot_callback, false);
-}
-
-
-void StoreBuffer::IteratePointersToNewSpaceAndClearMaps(
-    ObjectSlotCallback slot_callback) {
-  IteratePointersToNewSpace(slot_callback, true);
-}
-
-
-void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback,
-                                            bool clear_maps) {
// 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.
@@ -489,7 +472,7 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback,
   // TODO(gc): we want to skip slots on evacuation candidates
   // but we can't simply figure that out from slot address
   // because slot can belong to a large object.
-  IteratePointersInStoreBuffer(slot_callback, clear_maps);
+  IteratePointersInStoreBuffer(slot_callback);

// We are done scanning all the pointers that were in the store buffer, but // there may be some pages marked scan_on_scavenge that have pointers to new @@ -518,7 +501,7 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback,
           DCHECK(array->IsFixedArray());
           Address start = array->address();
           Address end = start + array->Size();
- FindPointersToNewSpaceInRegion(start, end, slot_callback, clear_maps);
+          FindPointersToNewSpaceInRegion(start, end, slot_callback);
         } else {
           Page* page = reinterpret_cast<Page*>(chunk);
           PagedSpace* owner = reinterpret_cast<PagedSpace*>(page->owner());
@@ -533,7 +516,7 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback,
                 FindPointersToNewSpaceInRegion(
heap_object->address() + Map::kPointerFieldsBeginOffset,
                     heap_object->address() + Map::kPointerFieldsEndOffset,
-                    slot_callback, clear_maps);
+                    slot_callback);
               }
             }
           } else {
@@ -568,8 +551,7 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback,
                                         &end_of_region_offset)) {
                       FindPointersToNewSpaceInRegion(
                           obj_address + offset,
- obj_address + end_of_region_offset, slot_callback,
-                          clear_maps);
+ obj_address + end_of_region_offset, slot_callback);
                     }
                     offset = end_of_region_offset;
                   }
@@ -579,7 +561,7 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback,
                   Address end_address = obj_address + end_offset;
                   // Object has only tagged fields.
FindPointersToNewSpaceInRegion(start_address, end_address, - slot_callback, clear_maps);
+                                                 slot_callback);
 #if V8_DOUBLE_FIELDS_UNBOXING
                 }
 #endif
Index: src/heap/store-buffer.h
diff --git a/src/heap/store-buffer.h b/src/heap/store-buffer.h
index f353b1df2c95d9258fbe230f26ba647c1f1100c1..a8b713db3bb29f9eef06c6adf54d405913d67017 100644
--- a/src/heap/store-buffer.h
+++ b/src/heap/store-buffer.h
@@ -20,8 +20,7 @@ class StoreBuffer;
 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to);

 typedef void (StoreBuffer::*RegionCallback)(Address start, Address end,
- ObjectSlotCallback slot_callback,
-                                            bool clear_maps);
+ ObjectSlotCallback slot_callback);

 // Used to implement the write barrier by collecting addresses of pointers
 // between spaces.
@@ -60,10 +59,6 @@ class StoreBuffer {
   // surviving old-to-new pointers into the store buffer to rebuild it.
   void IteratePointersToNewSpace(ObjectSlotCallback callback);

- // Same as IteratePointersToNewSpace but additonally clears maps in objects - // referenced from the store buffer that do not contain a forwarding pointer.
-  void IteratePointersToNewSpaceAndClearMaps(ObjectSlotCallback callback);
-
   static const int kStoreBufferOverflowBit = 1 << (14 + kPointerSizeLog2);
   static const int kStoreBufferSize = kStoreBufferOverflowBit;
   static const int kStoreBufferLength = kStoreBufferSize / sizeof(Address);
@@ -156,13 +151,10 @@ class StoreBuffer {
   inline void ClearDeadObject(HeapObject* object);

   void ProcessOldToNewSlot(Address slot_address,
- ObjectSlotCallback slot_callback, bool clear_maps);
-
- void IteratePointersToNewSpace(ObjectSlotCallback callback, bool clear_maps);
+                           ObjectSlotCallback slot_callback);

   void FindPointersToNewSpaceInRegion(Address start, Address end,
-                                      ObjectSlotCallback slot_callback,
-                                      bool clear_maps);
+                                      ObjectSlotCallback slot_callback);

   // For each region of pointers on a page in use from an old space call
   // visit_pointer_region callback.
@@ -173,8 +165,7 @@ class StoreBuffer {
                              RegionCallback region_callback,
                              ObjectSlotCallback slot_callback);

-  void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback,
-                                    bool clear_maps);
+  void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback);

 #ifdef VERIFY_HEAP
   void VerifyPointers(LargeObjectSpace* space);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to