Reviewers: Benedikt Meurer,

Message:
Committed patchset #1 manually as r22270 (presubmit successful).

Description:
Reland "Precisely sweep scan on scavenge pages and use heap iterator to iterate
over them."

BUG=
[email protected]

Committed: https://code.google.com/p/v8/source/detail?r=22270

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

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

Affected files (+58, -27 lines):
  M src/mark-compact.cc
  M src/objects.h
  M src/objects-inl.h
  M src/spaces.cc
  M src/store-buffer.cc


Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index fafc9e1faebf192641e04bea34529d28f8ca786d..9192c5882036c3a2fe3eed8cd9c24f7023d05228 100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -4146,12 +4146,23 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
           pages_swept++;
           parallel_sweeping_active = true;
         } else {
-          if (FLAG_gc_verbose) {
- PrintF("Sweeping 0x%" V8PRIxPTR " conservatively in parallel.\n",
-                   reinterpret_cast<intptr_t>(p));
+          if (p->scan_on_scavenge()) {
+ SweepPrecisely<SWEEP_ONLY, IGNORE_SKIP_LIST, IGNORE_FREE_SPACE>(
+                space, p, NULL);
+            pages_swept++;
+            if (FLAG_gc_verbose) {
+              PrintF("Sweeping 0x%" V8PRIxPTR
+                  " scan on scavenge page precisely.\n",
+                  reinterpret_cast<intptr_t>(p));
+            }
+          } else {
+            if (FLAG_gc_verbose) {
+ PrintF("Sweeping 0x%" V8PRIxPTR " conservatively in parallel.\n",
+                  reinterpret_cast<intptr_t>(p));
+            }
+ p->set_parallel_sweeping(MemoryChunk::PARALLEL_SWEEPING_PENDING);
+            space->IncreaseUnsweptFreeBytes(p);
           }
-          p->set_parallel_sweeping(MemoryChunk::PARALLEL_SWEEPING_PENDING);
-          space->IncreaseUnsweptFreeBytes(p);
         }
         space->set_end_of_unswept_pages(p);
         break;
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 0b500089c4a9879a04bb33b0a61aed7ecdf7e225..434ae95ac65e47f92f3af6c1973a66c4d6fa9c95 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1480,6 +1480,22 @@ int HeapObject::Size() {
 }


+bool HeapObject::ContainsPointers() {
+  InstanceType type = map()->instance_type();
+  if (type <= LAST_NAME_TYPE) {
+    if (type == SYMBOL_TYPE) {
+      return true;
+    }
+    ASSERT(type < FIRST_NONSTRING_TYPE);
+    // There are four string representations: sequential strings, external
+    // strings, cons strings, and sliced strings.
+    // Only the latter two contain non-map-word pointers to heap objects.
+    return ((type & kIsIndirectStringMask) == kIsIndirectStringTag);
+  }
+  return (type > LAST_DATA_TYPE);
+}
+
+
 void HeapObject::IteratePointers(ObjectVisitor* v, int start, int end) {
   v->VisitPointers(reinterpret_cast<Object**>(FIELD_ADDR(this, start)),
                    reinterpret_cast<Object**>(FIELD_ADDR(this, end)));
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index d49e365e59e51823655a71dee8046452551c8040..3cdd70bf9d86222e7fbd5d726a457e62260bb44c 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -714,6 +714,7 @@ enum InstanceType {
   FIXED_UINT8_CLAMPED_ARRAY_TYPE,  // LAST_FIXED_TYPED_ARRAY_TYPE

   FIXED_DOUBLE_ARRAY_TYPE,
+  CONSTANT_POOL_ARRAY_TYPE,
   FILLER_TYPE,  // LAST_DATA_TYPE

   // Structs.
@@ -740,7 +741,6 @@ enum InstanceType {
   BREAK_POINT_INFO_TYPE,

   FIXED_ARRAY_TYPE,
-  CONSTANT_POOL_ARRAY_TYPE,
   SHARED_FUNCTION_INFO_TYPE,

// All the following types are subtypes of JSReceiver, which corresponds to
@@ -1716,6 +1716,10 @@ class HeapObject: public Object {
   // Returns the heap object's size in bytes
   inline int Size();

+  // Returns true if this heap object contains only references to other
+  // heap objects.
+  inline bool ContainsPointers();
+
   // Given a heap object's map pointer, returns the heap size in bytes
   // Useful when the map pointer field is used for other purposes.
   // GC internal.
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index 560c7d87188e052ec5941f56cceb8a78cee7d7b9..12613c7cb0fc4898d9a5ca172deda517d56a2922 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -18,6 +18,9 @@ namespace internal {
 // HeapObjectIterator

 HeapObjectIterator::HeapObjectIterator(PagedSpace* space) {
+  // Check that we actually can iterate this space.
+  ASSERT(space->is_iterable());
+
// You can't actually iterate over the anchor page. It is not a real page, // just an anchor for the double linked page list. Initialize as if we have // reached the end of the anchor page, then the first iteration will move on @@ -32,6 +35,9 @@ HeapObjectIterator::HeapObjectIterator(PagedSpace* space) {

 HeapObjectIterator::HeapObjectIterator(PagedSpace* space,
                                        HeapObjectCallback size_func) {
+  // Check that we actually can iterate this space.
+  ASSERT(space->is_iterable());
+
// You can't actually iterate over the anchor page. It is not a real page, // just an anchor for the double linked page list. Initialize the current
   // address and end as NULL, then the first iteration will move on
@@ -66,9 +72,6 @@ void HeapObjectIterator::Initialize(PagedSpace* space,
                                     Address cur, Address end,
                                     HeapObjectIterator::PageMode mode,
                                     HeapObjectCallback size_f) {
-  // Check that we actually can iterate this space.
-  ASSERT(space->is_iterable());
-
   space_ = space;
   cur_addr_ = cur;
   cur_end_ = end;
Index: src/store-buffer.cc
diff --git a/src/store-buffer.cc b/src/store-buffer.cc
index 7ee4fa2d4000ed4529476a427505194d579e443a..a7575ae32822344c7c626e81daa9a122a4e614f4 100644
--- a/src/store-buffer.cc
+++ b/src/store-buffer.cc
@@ -519,25 +519,22 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback, FindPointersToNewSpaceInRegion(start, end, slot_callback, clear_maps);
         } else {
           Page* page = reinterpret_cast<Page*>(chunk);
-          PagedSpace* owner = reinterpret_cast<PagedSpace*>(page->owner());
-          Address start = page->area_start();
-          Address end = page->area_end();
-          if (owner == heap_->map_space()) {
-            ASSERT(page->WasSweptPrecisely());
-            HeapObjectIterator iterator(page, NULL);
- for (HeapObject* heap_object = iterator.Next(); heap_object != NULL;
-                 heap_object = iterator.Next()) {
-              // We skip free space objects.
-              if (!heap_object->IsFiller()) {
-                FindPointersToNewSpaceInRegion(
-                    heap_object->address() + HeapObject::kHeaderSize,
- heap_object->address() + heap_object->Size(), slot_callback,
-                    clear_maps);
-              }
+          ASSERT(page->owner() == heap_->map_space() ||
+                 page->owner() == heap_->old_pointer_space());
+          CHECK(page->WasSweptPrecisely());
+
+          HeapObjectIterator iterator(page, NULL);
+          for (HeapObject* heap_object = iterator.Next();
+               heap_object != NULL;
+               heap_object = iterator.Next()) {
+            // We iterate over objects that contain pointers only.
+            if (heap_object->ContainsPointers()) {
+              FindPointersToNewSpaceInRegion(
+                  heap_object->address() + HeapObject::kHeaderSize,
+                  heap_object->address() + heap_object->Size(),
+                  slot_callback,
+                  clear_maps);
             }
-          } else {
-            FindPointersToNewSpaceInRegion(
-                start, end, slot_callback, clear_maps);
           }
         }
       }


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