Revision: 7393
Author:   [email protected]
Date:     Mon Mar 28 08:16:03 2011
Log:      Exponentially increase incremental marking factor each 512 steps.

Track inlined new space allocations and do steps based on the amount of
allocated data.

Review URL: http://codereview.chromium.org/6756006
http://code.google.com/p/v8/source/detail?r=7393

Modified:
 /branches/experimental/gc/src/incremental-marking.cc
 /branches/experimental/gc/src/incremental-marking.h
 /branches/experimental/gc/src/spaces-inl.h
 /branches/experimental/gc/src/spaces.cc
 /branches/experimental/gc/src/spaces.h

=======================================
--- /branches/experimental/gc/src/incremental-marking.cc Fri Mar 25 06:32:23 2011 +++ /branches/experimental/gc/src/incremental-marking.cc Mon Mar 28 08:16:03 2011
@@ -39,6 +39,7 @@

 double IncrementalMarking::steps_took_ = 0;
 int IncrementalMarking::steps_count_ = 0;
+intptr_t IncrementalMarking::allocation_marking_factor_ = 0;

 static intptr_t allocated = 0;

@@ -221,6 +222,8 @@
   VerifyMarkbitsAreClean();
 #endif

+  Heap::new_space()->LowerInlineAllocationLimit(kAllocatedThreshold);
+
   // Mark strong roots grey.
   IncrementalMarkingRootMarkingVisitor visitor;
   Heap::IterateStrongRoots(&visitor, VISIT_ONLY_STRONG);
@@ -332,7 +335,7 @@
         start = OS::TimeCurrentMillis();
       }

-      intptr_t bytes_to_process = allocated * kAllocationMarkingFactor;
+      intptr_t bytes_to_process = allocated * allocation_marking_factor_;
       int count = 0;

       Map* filler_map = Heap::one_pointer_filler_map();
@@ -360,7 +363,12 @@
       if (FLAG_trace_incremental_marking || FLAG_trace_gc) {
         double end = OS::TimeCurrentMillis();
         steps_took_ += (end - start);
-        steps_count_++;
+      }
+
+      steps_count_++;
+
+      if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0) {
+        allocation_marking_factor_ *= kAllocationMarkingFactorSpeedup;
       }
     }
   }
=======================================
--- /branches/experimental/gc/src/incremental-marking.h Fri Mar 25 06:32:23 2011 +++ /branches/experimental/gc/src/incremental-marking.h Mon Mar 28 08:16:03 2011
@@ -69,7 +69,9 @@
   static void MarkingComplete();

   static const intptr_t kAllocatedThreshold = 1024;
-  static const intptr_t kAllocationMarkingFactor = 8;
+  static const intptr_t kInitialAllocationMarkingFactor = 8;
+  static const intptr_t kAllocationMarkingFactorSpeedupInterval = 512;
+  static const intptr_t kAllocationMarkingFactorSpeedup = 2;

   static void Step(intptr_t allocated);

@@ -218,6 +220,7 @@
   static void ResetStepCounters() {
     steps_count_ = 0;
     steps_took_ = 0;
+    allocation_marking_factor_ = kInitialAllocationMarkingFactor;
   }


@@ -227,6 +230,7 @@
   static int steps_count_;
   static double steps_took_;

+  static intptr_t allocation_marking_factor_;
 };

 } }  // namespace v8::internal
=======================================
--- /branches/experimental/gc/src/spaces-inl.h  Thu Mar 17 10:41:44 2011
+++ /branches/experimental/gc/src/spaces-inl.h  Mon Mar 28 08:16:03 2011
@@ -203,22 +203,26 @@
// -----------------------------------------------------------------------------
 // NewSpace

-MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes,
-                                           AllocationInfo* alloc_info) {
-  Address new_top = alloc_info->top + size_in_bytes;
-  if (new_top > alloc_info->limit) return Failure::RetryAfterGC();
-
-  Object* obj = HeapObject::FromAddress(alloc_info->top);
-  alloc_info->top = new_top;
-#ifdef DEBUG
-  SemiSpace* space =
-      (alloc_info == &allocation_info_) ? &to_space_ : &from_space_;
-  ASSERT(space->low() <= alloc_info->top
-         && alloc_info->top <= space->high()
-         && alloc_info->limit == space->high());
-#endif
-
-  IncrementalMarking::Step(size_in_bytes);
+MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes) {
+  Address new_top = allocation_info_.top + size_in_bytes;
+  if (new_top > allocation_info_.limit) {
+    Address high = to_space_.high();
+    if (allocation_info_.limit < high) {
+      allocation_info_.limit = Min(
+          allocation_info_.limit + inline_alloction_limit_step_,
+          high);
+      return AllocateRawInternal(size_in_bytes);
+    }
+    return Failure::RetryAfterGC();
+  }
+
+  Object* obj = HeapObject::FromAddress(allocation_info_.top);
+  allocation_info_.top = new_top;
+  ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
+
+  int bytes_allocated = new_top - top_on_previous_step_;
+  IncrementalMarking::Step(bytes_allocated);
+  top_on_previous_step_ = new_top;

   return obj;
 }
=======================================
--- /branches/experimental/gc/src/spaces.cc     Fri Mar 25 06:32:23 2011
+++ /branches/experimental/gc/src/spaces.cc     Mon Mar 28 08:16:03 2011
@@ -35,13 +35,6 @@
 namespace v8 {
 namespace internal {

-// For contiguous spaces, top should be in the space (or at the end) and limit
-// should be the end of the space.
-#define ASSERT_SEMISPACE_ALLOCATION_INFO(info, space) \
-  ASSERT((space).low() <= (info).top                  \
-         && (info).top <= (space).high()              \
-         && (info).limit == (space).high())
-
// ----------------------------------------------------------------------------
 // HeapObjectIterator

@@ -848,10 +841,8 @@
   object_mask_ = address_mask_ | kHeapObjectTagMask;
   object_expected_ = reinterpret_cast<uintptr_t>(start_) | kHeapObjectTag;

-  allocation_info_.top = to_space_.low();
-  allocation_info_.limit = to_space_.high();
-
-  ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
+  ResetAllocationInfo();
+
   return true;
 }

=======================================
--- /branches/experimental/gc/src/spaces.h      Wed Mar 23 07:01:20 2011
+++ /branches/experimental/gc/src/spaces.h      Mon Mar 28 08:16:03 2011
@@ -1631,12 +1631,20 @@
   Address* allocation_limit_address() { return &allocation_info_.limit; }

   MUST_USE_RESULT MaybeObject* AllocateRaw(int size_in_bytes) {
-    return AllocateRawInternal(size_in_bytes, &allocation_info_);
+    return AllocateRawInternal(size_in_bytes);
   }

   // Reset the allocation pointer to the beginning of the active semispace.
   void ResetAllocationInfo();

+  void LowerInlineAllocationLimit(intptr_t step) {
+    inline_alloction_limit_step_ = step;
+    allocation_info_.limit = Min(
+        allocation_info_.top + inline_alloction_limit_step_,
+        allocation_info_.limit);
+    top_on_previous_step_ = allocation_info_.top;
+  }
+
   // Get the extent of the inactive semispace (for use as a marking stack).
   Address FromSpaceLow() { return from_space_.low(); }
   Address FromSpaceHigh() { return from_space_.high(); }
@@ -1727,15 +1735,21 @@
   // mark-compact collection.
   AllocationInfo allocation_info_;

+  // When incremental marking is active we will set allocation_info_.limit
+  // to be lower than actual limit and then will gradually increase it
+  // in steps to guarantee that we do incremental marking steps even
+  // when all allocation is performed from inlined generated code.
+  intptr_t inline_alloction_limit_step_;
+
+  Address top_on_previous_step_;
+
 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
   HistogramInfo* allocated_histogram_;
   HistogramInfo* promoted_histogram_;
 #endif

-  // Implementation of AllocateRaw and MCAllocateRaw.
-  MUST_USE_RESULT inline MaybeObject* AllocateRawInternal(
-      int size_in_bytes,
-      AllocationInfo* alloc_info);
+  // Implementation of AllocateRaw.
+ MUST_USE_RESULT inline MaybeObject* AllocateRawInternal(int size_in_bytes);

   friend class SemiSpaceIterator;

@@ -1772,6 +1786,14 @@
 };


+// For contiguous spaces, top should be in the space (or at the end) and limit
+// should be the end of the space.
+#define ASSERT_SEMISPACE_ALLOCATION_INFO(info, space) \
+  ASSERT((space).low() <= (info).top                  \
+         && (info).top <= (space).high()              \
+         && (info).limit <= (space).high())
+
+
// -----------------------------------------------------------------------------
 // Old space for objects of a fixed size

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

Reply via email to