Revision: 10961
Author:   [email protected]
Date:     Wed Mar  7 09:52:16 2012
Log:      Add kAbortIncrementalMarkingMask flag for GC.

This adds an additional flag to control whether incremental marking
should be aborted when requesting a GC, providing a finer granularity
between kNoGCFlags and kMakeHeapIterableMask.

[email protected]
BUG=v8:1608

Review URL: https://chromiumcodereview.appspot.com/9608006
http://code.google.com/p/v8/source/detail?r=10961

Modified:
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/heap.h
 /branches/bleeding_edge/src/mark-compact-inl.h
 /branches/bleeding_edge/src/mark-compact.cc
 /branches/bleeding_edge/src/mark-compact.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/test/cctest/test-api.cc
 /branches/bleeding_edge/test/cctest/test-deoptimization.cc
 /branches/bleeding_edge/test/cctest/test-heap.cc

=======================================
--- /branches/bleeding_edge/src/heap.cc Wed Mar  7 08:24:11 2012
+++ /branches/bleeding_edge/src/heap.cc Wed Mar  7 09:52:16 2012
@@ -499,7 +499,7 @@
   }

   if (collector == MARK_COMPACTOR &&
-      !mark_compact_collector()->PreciseSweepingRequired() &&
+      !mark_compact_collector()->abort_incremental_marking_ &&
       !incremental_marking()->IsStopped() &&
       !incremental_marking()->should_hurry() &&
       FLAG_incremental_marking_steps) {
@@ -582,7 +582,7 @@
     Heap* heap,
     AllocationSpace space,
     const char* gc_reason = NULL) {
-  heap->mark_compact_collector()->SetFlags(Heap::kMakeHeapIterableMask);
+ heap->mark_compact_collector()->SetFlags(Heap::kAbortIncrementalMarkingMask);
   bool result = heap->CollectGarbage(space, gc_reason);
   heap->mark_compact_collector()->SetFlags(Heap::kNoGCFlags);
   return result;
=======================================
--- /branches/bleeding_edge/src/heap.h  Wed Mar  7 08:24:11 2012
+++ /branches/bleeding_edge/src/heap.h  Wed Mar  7 09:52:16 2012
@@ -1041,8 +1041,14 @@
                              const char* gc_reason = NULL);

   static const int kNoGCFlags = 0;
-  static const int kMakeHeapIterableMask = 1;
+  static const int kSweepPreciselyMask = 1;
   static const int kReduceMemoryFootprintMask = 2;
+  static const int kAbortIncrementalMarkingMask = 4;
+
+  // Making the heap iterable requires us to sweep precisely and abort any
+  // incremental marking as well.
+  static const int kMakeHeapIterableMask =
+      kSweepPreciselyMask | kAbortIncrementalMarkingMask;

// Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is // non-zero, then the slower precise sweeper is used, which leaves the heap
=======================================
--- /branches/bleeding_edge/src/mark-compact-inl.h      Fri Feb  3 06:16:40 2012
+++ /branches/bleeding_edge/src/mark-compact-inl.h      Wed Mar  7 09:52:16 2012
@@ -45,8 +45,10 @@


 void MarkCompactCollector::SetFlags(int flags) {
-  sweep_precisely_ = ((flags & Heap::kMakeHeapIterableMask) != 0);
+  sweep_precisely_ = ((flags & Heap::kSweepPreciselyMask) != 0);
reduce_memory_footprint_ = ((flags & Heap::kReduceMemoryFootprintMask) != 0);
+  abort_incremental_marking_ =
+      ((flags & Heap::kAbortIncrementalMarkingMask) != 0);
 }


=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Thu Feb 23 04:11:24 2012
+++ /branches/bleeding_edge/src/mark-compact.cc Wed Mar  7 09:52:16 2012
@@ -686,8 +686,8 @@
   }
 #endif

-  // Clear marking bits for precise sweeping to collect all garbage.
-  if (was_marked_incrementally_ && PreciseSweepingRequired()) {
+  // Clear marking bits if incremental marking is aborted.
+  if (was_marked_incrementally_ && abort_incremental_marking_) {
     heap()->incremental_marking()->Abort();
     ClearMarkbits();
     AbortCompaction();
=======================================
--- /branches/bleeding_edge/src/mark-compact.h  Tue Feb  7 00:51:47 2012
+++ /branches/bleeding_edge/src/mark-compact.h  Wed Mar  7 09:52:16 2012
@@ -420,14 +420,9 @@
   // Pointer to member function, used in IterateLiveObjects.
   typedef int (MarkCompactCollector::*LiveObjectCallback)(HeapObject* obj);

-  // Set the global force_compaction flag, it must be called before Prepare
-  // to take effect.
+  // Set the global flags, it must be called before Prepare to take effect.
   inline void SetFlags(int flags);

-  inline bool PreciseSweepingRequired() {
-    return sweep_precisely_;
-  }
-
   static void Initialize();

   void CollectEvacuationCandidates(PagedSpace* space);
@@ -579,6 +574,8 @@

   bool reduce_memory_footprint_;

+  bool abort_incremental_marking_;
+
   // True if we are collecting slots to perform evacuation from evacuation
   // candidates.
   bool compacting_;
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Wed Mar  7 05:24:44 2012
+++ /branches/bleeding_edge/src/runtime.cc      Wed Mar  7 09:52:16 2012
@@ -12925,7 +12925,7 @@
 // Performs a GC.
 // Presently, it only does a full GC.
 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) {
-  isolate->heap()->CollectAllGarbage(true, "%CollectGarbage");
+  isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage");
   return isolate->heap()->undefined_value();
 }

=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc     Wed Feb 29 04:49:44 2012
+++ /branches/bleeding_edge/test/cctest/test-api.cc     Wed Mar  7 09:52:16 2012
@@ -450,8 +450,7 @@
     CHECK_EQ(0, dispose_count);
   }
   i::Isolate::Current()->compilation_cache()->Clear();
-  // TODO(1608): This should use kAbortIncrementalMarking.
-  HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+  HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
   CHECK_EQ(1, dispose_count);
 }

@@ -477,8 +476,7 @@
     CHECK_EQ(0, dispose_count);
   }
   i::Isolate::Current()->compilation_cache()->Clear();
-  // TODO(1608): This should use kAbortIncrementalMarking.
-  HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+  HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
   CHECK_EQ(1, dispose_count);
 }

@@ -2253,9 +2251,8 @@
     V8::AddObjectGroup(g2_objects, 2);
     V8::AddImplicitReferences(g2s2, g2_children, 1);
   }
-  // Do a single full GC. Use kMakeHeapIterableMask to ensure that
-  // incremental garbage collection is stopped.
-  HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+  // Do a single full GC, ensure incremental marking is stopped.
+  HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);

   // All object should be alive.
   CHECK_EQ(0, counter.NumberOfWeakCalls());
@@ -2279,7 +2276,7 @@
     V8::AddImplicitReferences(g2s2, g2_children, 1);
   }

-  HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+  HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);

   // All objects should be gone. 5 global handles in total.
   CHECK_EQ(5, counter.NumberOfWeakCalls());
@@ -2288,7 +2285,7 @@
   g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
   g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);

-  HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+  HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
   CHECK_EQ(7, counter.NumberOfWeakCalls());
 }

@@ -2344,7 +2341,7 @@
     V8::AddImplicitReferences(g3s1, g3_children, 1);
   }
   // Do a single full GC
-  HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+  HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);

   // All object should be alive.
   CHECK_EQ(0, counter.NumberOfWeakCalls());
@@ -2368,7 +2365,7 @@
     V8::AddImplicitReferences(g3s1, g3_children, 1);
   }

-  HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+  HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);

   // All objects should be gone. 7 global handles in total.
   CHECK_EQ(7, counter.NumberOfWeakCalls());
=======================================
--- /branches/bleeding_edge/test/cctest/test-deoptimization.cc Mon Feb 13 02:13:52 2012 +++ /branches/bleeding_edge/test/cctest/test-deoptimization.cc Wed Mar 7 09:52:16 2012
@@ -100,8 +100,7 @@
 // Abort any ongoing incremental marking to make sure that all weak global
 // handle callbacks are processed.
 static void NonIncrementalGC() {
-  // TODO(1608): This should use kAbortIncrementalMarking.
-  HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+  HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
 }


=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Thu Feb 23 04:11:24 2012 +++ /branches/bleeding_edge/test/cctest/test-heap.cc Wed Mar 7 09:52:16 2012
@@ -959,17 +959,17 @@
   CHECK(function->shared()->is_compiled());

// TODO(1609) Currently incremental marker does not support code flushing.
-  HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
-  HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
+  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);

   CHECK(function->shared()->is_compiled());

-  HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
-  HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
-  HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
-  HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
-  HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
-  HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
+  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);

   // foo should no longer be in the compilation cache
   CHECK(!function->shared()->is_compiled() || function->IsOptimized());

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

Reply via email to