Reviewers: Hannes Payer,

Message:
PTAL


https://codereview.chromium.org/1314853002/diff/1/src/heap/heap.h
File src/heap/heap.h (right):

https://codereview.chromium.org/1314853002/diff/1/src/heap/heap.h#newcode1399
src/heap/heap.h:1399: void StartIncrementalMarking(int gc_flags,
On 2015/08/25 08:35:27, Hannes Payer wrote:
Can we make change the int gc_flags to an enum, you can do that in a
separate
cl.

The flags could also have a default parameter.

Acknowledged and Done.

https://codereview.chromium.org/1314853002/diff/1/src/heap/heap.h#newcode2347
src/heap/heap.h:2347: GCCallbackFlags current_gc_callback_flags_;
On 2015/08/25 08:35:27, Hannes Payer wrote:
Describe what these flags are doing.

Done.

Description:
[heap] Make the current GCCallbackFlags are part of {Heap}.

Moves the GCCallbackflags where they belong, i.e., {Heap}, and gets rid of
IncrementalMarking::Start() callsites.

BUG=

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

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

Affected files (+39, -29 lines):
  M src/heap/heap.h
  M src/heap/heap.cc
  M src/heap/incremental-marking.h
  M src/heap/incremental-marking.cc
  M test/cctest/cctest.h
  M test/cctest/test-heap.cc


Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index f19e52156d83ab8538bf7283ae5b01f2a00acabe..a68f2f302f2ddddba0f40f34821b0edfdded1462 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -133,6 +133,7 @@ Heap::Heap()
       promotion_queue_(this),
       configured_(false),
       current_gc_flags_(Heap::kNoGCFlags),
+      current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags),
       external_string_table_(this),
       chunks_queued_for_free_(NULL),
       pending_unmap_job_semaphore_(0),
@@ -742,7 +743,7 @@ void Heap::HandleGCRequest() {
   if (incremental_marking()->request_type() ==
       IncrementalMarking::COMPLETE_MARKING) {
     CollectAllGarbage(current_gc_flags(), "GC interrupt",
-                      incremental_marking()->CallbackFlags());
+                      current_gc_callback_flags());
     return;
   }
   DCHECK(FLAG_overapproximate_weak_closure);
@@ -951,7 +952,7 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason,
   // generator needs incremental marking to stay off after it aborted.
if (!ShouldAbortIncrementalMarking() && incremental_marking()->IsStopped() &&
       incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) {
- incremental_marking()->Start(kNoGCFlags, kNoGCCallbackFlags, "GC epilogue");
+    StartIncrementalMarking(kNoGCFlags, kNoGCCallbackFlags, "GC epilogue");
   }

   return next_gc_likely_to_collect_more;
@@ -982,7 +983,9 @@ void Heap::StartIncrementalMarking(int gc_flags,
                                    const GCCallbackFlags gc_callback_flags,
                                    const char* reason) {
   DCHECK(incremental_marking()->IsStopped());
-  incremental_marking()->Start(gc_flags, gc_callback_flags, reason);
+  set_current_gc_flags(gc_flags);
+  set_current_gc_callback_flags(gc_callback_flags);
+  incremental_marking()->Start(reason);
 }


Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index 5c825e77804ad06cd30b1f3ae3ae6b4d562bcd86..7417267ed16f2c11832a60748a7f55e09900ac8a 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1362,8 +1362,9 @@ class Heap {

   // Starts incremental marking assuming incremental marking is currently
   // stopped.
-  void StartIncrementalMarking(int gc_flags,
-                               const GCCallbackFlags gc_callback_flags,
+  void StartIncrementalMarking(int gc_flags = kNoGCFlags,
+                               const GCCallbackFlags gc_callback_flags =
+                                   GCCallbackFlags::kNoGCCallbackFlags,
                                const char* reason = nullptr);

   // Performs incremental marking steps of step_size_in_bytes as long as
@@ -1678,6 +1679,14 @@ class Heap {
            !ShouldAbortIncrementalMarking());
   }

+  GCCallbackFlags current_gc_callback_flags() {
+    return current_gc_callback_flags_;
+  }
+
+  void set_current_gc_callback_flags(GCCallbackFlags callback_flags) {
+    current_gc_callback_flags_ = callback_flags;
+  }
+
   inline bool ShouldReduceMemory() const {
     return current_gc_flags_ & kReduceMemoryFootprintMask;
   }
@@ -2346,6 +2355,10 @@ class Heap {
   // Currently set GC flags that are respected by all GC components.
   int current_gc_flags_;

+ // Currently set GC callback flags that are used to pass information between
+  // the embedder and V8's GC.
+  GCCallbackFlags current_gc_callback_flags_;
+
   ExternalStringTable external_string_table_;

   VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_;
Index: src/heap/incremental-marking.cc
diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc index 51b652acef90570879f49db0d89780a750a7a969..009f4ca284236aa990106552e159f0d151007dde 100644
--- a/src/heap/incremental-marking.cc
+++ b/src/heap/incremental-marking.cc
@@ -42,8 +42,7 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
       was_activated_(false),
       weak_closure_was_overapproximated_(false),
       weak_closure_approximation_rounds_(0),
-      request_type_(COMPLETE_MARKING),
-      gc_callback_flags_(kNoGCCallbackFlags) {}
+      request_type_(COMPLETE_MARKING) {}


 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot,
@@ -463,9 +462,7 @@ static void PatchIncrementalMarkingRecordWriteStubs(
 }


-void IncrementalMarking::Start(int flags,
-                               const GCCallbackFlags gc_callback_flags,
-                               const char* reason) {
+void IncrementalMarking::Start(const char* reason) {
   if (FLAG_trace_incremental_marking) {
     PrintF("[IncrementalMarking] Start (%s)\n",
            (reason == nullptr) ? "unknown reason" : reason);
@@ -477,11 +474,9 @@ void IncrementalMarking::Start(int flags,

   ResetStepCounters();

-  gc_callback_flags_ = gc_callback_flags;
   was_activated_ = true;

   if (!heap_->mark_compact_collector()->sweeping_in_progress()) {
-    heap_->set_current_gc_flags(flags);
     StartMarking();
   } else {
     if (FLAG_trace_incremental_marking) {
@@ -819,7 +814,8 @@ void IncrementalMarking::Epilogue() {

 void IncrementalMarking::OldSpaceStep(intptr_t allocated) {
   if (IsStopped() && ShouldActivateEvenWithoutIdleNotification()) {
-    Start(Heap::kNoGCFlags, kNoGCCallbackFlags, "old space step");
+    heap()->StartIncrementalMarking(Heap::kNoGCFlags, kNoGCCallbackFlags,
+                                    "old space step");
   } else {
Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD);
   }
Index: src/heap/incremental-marking.h
diff --git a/src/heap/incremental-marking.h b/src/heap/incremental-marking.h
index fcada78f0b225f9cff609ea2134e45ec2eb49104..18c8c0dbb20011e3d427da1e827cfdb6089e397c 100644
--- a/src/heap/incremental-marking.h
+++ b/src/heap/incremental-marking.h
@@ -81,9 +81,7 @@ class IncrementalMarking {

   bool WasActivated();

-  void Start(int flags,
-             const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags,
-             const char* reason = nullptr);
+  void Start(const char* reason = nullptr);

   void MarkObjectGroups();

@@ -199,8 +197,6 @@ class IncrementalMarking {

   Heap* heap() const { return heap_; }

-  GCCallbackFlags CallbackFlags() const { return gc_callback_flags_; }
-
  private:
   int64_t SpaceLeftInOldSpace();

@@ -259,8 +255,6 @@ class IncrementalMarking {

   GCRequestType request_type_;

-  GCCallbackFlags gc_callback_flags_;
-
   DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking);
 };
 }
Index: test/cctest/cctest.h
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h
index 40fb2390cd61bd56c35844f6e86abc9d699b4856..b012686e07498ccc64af9662b1658641d8bd6bea 100644
--- a/test/cctest/cctest.h
+++ b/test/cctest/cctest.h
@@ -546,7 +546,7 @@ static inline void SimulateIncrementalMarking(i::Heap* heap,
   }
   CHECK(marking->IsMarking() || marking->IsStopped());
   if (marking->IsStopped()) {
-    marking->Start(i::Heap::kNoGCFlags);
+    heap->StartIncrementalMarking();
   }
   CHECK(marking->IsMarking());
   if (!force_completion) return;
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 811c4cfa53723c2859a8efd29b9697c8a91e31cc..fc009675ca45912dfd6b0f0023b70447bc527f65 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -2590,7 +2590,7 @@ TEST(InstanceOfStubWriteBarrier) {

   IncrementalMarking* marking = CcTest::heap()->incremental_marking();
   marking->Stop();
-  marking->Start(Heap::kNoGCFlags);
+  CcTest::heap()->StartIncrementalMarking();

   Handle<JSFunction> f =
       v8::Utils::OpenHandle(
@@ -2718,7 +2718,7 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {

   IncrementalMarking* marking = CcTest::heap()->incremental_marking();
   marking->Stop();
-  marking->Start(Heap::kNoGCFlags);
+  CcTest::heap()->StartIncrementalMarking();
   // The following calls will increment CcTest::heap()->global_ic_age().
   CcTest::isolate()->ContextDisposedNotification();
   SimulateIncrementalMarking(CcTest::heap());
@@ -2789,7 +2789,7 @@ HEAP_TEST(GCFlags) {

   IncrementalMarking* marking = heap->incremental_marking();
   marking->Stop();
-  marking->Start(Heap::kReduceMemoryFootprintMask);
+  heap->StartIncrementalMarking(Heap::kReduceMemoryFootprintMask);
   CHECK_NE(0, heap->current_gc_flags() & Heap::kReduceMemoryFootprintMask);

   heap->CollectGarbage(NEW_SPACE);
@@ -2807,7 +2807,7 @@ TEST(IdleNotificationFinishMarking) {
   SimulateFullSpace(CcTest::heap()->old_space());
   IncrementalMarking* marking = CcTest::heap()->incremental_marking();
   marking->Stop();
-  marking->Start(Heap::kNoGCFlags);
+  CcTest::heap()->StartIncrementalMarking();

   CHECK_EQ(CcTest::heap()->gc_count(), 0);

@@ -4760,7 +4760,9 @@ TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) {
              "};"
              "f(10 * 1024 * 1024);");
   IncrementalMarking* marking = CcTest::heap()->incremental_marking();
-  if (marking->IsStopped()) marking->Start(Heap::kNoGCFlags);
+  if (marking->IsStopped()) {
+    CcTest::heap()->StartIncrementalMarking();
+  }
   // This big step should be sufficient to mark the whole array.
   marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
   DCHECK(marking->IsComplete() ||
@@ -5488,7 +5490,9 @@ TEST(WeakCellsWithIncrementalMarking) {
     Handle<WeakCell> weak_cell = factory->NewWeakCell(value);
     CHECK(weak_cell->value()->IsFixedArray());
     IncrementalMarking* marking = heap->incremental_marking();
-    if (marking->IsStopped()) marking->Start(Heap::kNoGCFlags);
+    if (marking->IsStopped()) {
+      heap->StartIncrementalMarking();
+    }
     marking->Step(128, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
     heap->CollectGarbage(NEW_SPACE);
     CHECK(weak_cell->value()->IsFixedArray());
@@ -5781,7 +5785,7 @@ TEST(Regress388880) {
   // that would cause crash.
   IncrementalMarking* marking = CcTest::heap()->incremental_marking();
   marking->Stop();
-  marking->Start(Heap::kNoGCFlags);
+  CcTest::heap()->StartIncrementalMarking();
   CHECK(marking->IsMarking());

   // Now everything is set up for crashing in JSObject::MigrateFastToFast()
@@ -5807,7 +5811,7 @@ TEST(Regress3631) {
       "}"
       "weak_map");
   if (marking->IsStopped()) {
-    marking->Start(Heap::kNoGCFlags);
+    CcTest::heap()->StartIncrementalMarking();
   }
   // Incrementally mark the backing store.
   Handle<JSObject> obj =


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