Reviewers: Hannes Payer,

Description:
Extract code to mark an object during incremental marking

Not only does this remove code duplication, I also plan to use this for
unifying reference group marking later

BUG=none
[email protected]
LOG=n

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

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

Affected files (+19, -18 lines):
  M src/heap/incremental-marking.h
  M src/heap/incremental-marking.cc


Index: src/heap/incremental-marking.cc
diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc index 76c05de6065be5da1c51e8a7f7f8894f1eed82fb..97135d76661d76fd1b556b8de566bb3765ccee57 100644
--- a/src/heap/incremental-marking.cc
+++ b/src/heap/incremental-marking.cc
@@ -251,13 +251,7 @@ class IncrementalMarkingMarkingVisitor

   // Marks the object grey and pushes it on the marking stack.
   INLINE(static void MarkObject(Heap* heap, Object* obj)) {
-    HeapObject* heap_object = HeapObject::cast(obj);
-    MarkBit mark_bit = Marking::MarkBitFrom(heap_object);
-    if (mark_bit.data_only()) {
-      MarkBlackOrKeepGrey(heap_object, mark_bit, heap_object->Size());
-    } else if (Marking::IsWhite(mark_bit)) {
- heap->incremental_marking()->WhiteToGreyAndPush(heap_object, mark_bit);
-    }
+    IncrementalMarking::MarkObject(heap, obj);
   }

   // Marks the object black without pushing it on the marking stack.
@@ -280,7 +274,7 @@ class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor {
  public:
   explicit IncrementalMarkingRootMarkingVisitor(
       IncrementalMarking* incremental_marking)
-      : incremental_marking_(incremental_marking) {}
+      : heap_(incremental_marking->heap()) {}

   void VisitPointer(Object** p) { MarkObjectByPointer(p); }

@@ -293,18 +287,10 @@ class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor {
     Object* obj = *p;
     if (!obj->IsHeapObject()) return;

-    HeapObject* heap_object = HeapObject::cast(obj);
-    MarkBit mark_bit = Marking::MarkBitFrom(heap_object);
-    if (mark_bit.data_only()) {
-      MarkBlackOrKeepGrey(heap_object, mark_bit, heap_object->Size());
-    } else {
-      if (Marking::IsWhite(mark_bit)) {
-        incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit);
-      }
-    }
+    IncrementalMarking::MarkObject(heap_, obj);
   }

-  IncrementalMarking* incremental_marking_;
+  Heap* heap_;
 };


@@ -639,6 +625,17 @@ void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) {
 }


+void IncrementalMarking::MarkObject(Heap* heap, Object* obj) {
+  HeapObject* heap_object = HeapObject::cast(obj);
+  MarkBit mark_bit = Marking::MarkBitFrom(heap_object);
+  if (mark_bit.data_only()) {
+    MarkBlackOrKeepGrey(heap_object, mark_bit, heap_object->Size());
+  } else if (Marking::IsWhite(mark_bit)) {
+    heap->incremental_marking()->WhiteToGreyAndPush(heap_object, mark_bit);
+  }
+}
+
+
intptr_t IncrementalMarking::ProcessMarkingDeque(intptr_t bytes_to_process) {
   intptr_t bytes_processed = 0;
   Map* filler_map = heap_->one_pointer_filler_map();
Index: src/heap/incremental-marking.h
diff --git a/src/heap/incremental-marking.h b/src/heap/incremental-marking.h
index d6dfe17c7f2472ebb9ce76bdab694e1cb5a00708..c728815b32a28fdce69087ff04e3a4f672d3f872 100644
--- a/src/heap/incremental-marking.h
+++ b/src/heap/incremental-marking.h
@@ -189,6 +189,10 @@ class IncrementalMarking {

   bool IsIdleMarkingDelayCounterLimitReached();

+  INLINE(static void MarkObject(Heap* heap, Object* object));
+
+  Heap* heap() const { return heap_; }
+
  private:
   int64_t SpaceLeftInOldSpace();



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