Reviewers: Hannes Payer,

Description:
Explicitly track whether incremental marking was activated

In the gc-tracer, we check whether we're marking to figure out which
part of the mark compact we're in. If we aborted incremental marking for
whatever reason, the check fails and we might later run into trouble

BUG=none
[email protected]
LOG=n

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

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

Affected files (+28, -5 lines):
  M src/heap/gc-tracer.cc
  M src/heap/heap.h
  M src/heap/heap.cc
  M src/heap/incremental-marking.h
  M src/heap/incremental-marking.cc


Index: src/heap/gc-tracer.cc
diff --git a/src/heap/gc-tracer.cc b/src/heap/gc-tracer.cc
index 732bfe0d57860076eaf49ceb14e9bc49b40ebd68..ffe48d5d5fee6173e3fc38aefb3872277090b36c 100644
--- a/src/heap/gc-tracer.cc
+++ b/src/heap/gc-tracer.cc
@@ -121,7 +121,7 @@ void GCTracer::Start(GarbageCollector collector, const char* gc_reason,
   if (collector == SCAVENGER) {
     current_ = Event(Event::SCAVENGER, gc_reason, collector_reason);
   } else if (collector == MARK_COMPACTOR) {
-    if (heap_->incremental_marking()->IsMarking()) {
+    if (heap_->incremental_marking()->WasActivated()) {
       current_ =
Event(Event::INCREMENTAL_MARK_COMPACTOR, gc_reason, collector_reason);
     } else {
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index b73a63e8c12faa9fa27f83a4ffdb8546b84bb242..6502de3a9b43ff96f9c0cda1f9d7217222246331 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -1210,15 +1210,22 @@ void Heap::MarkCompact() {

   LOG(isolate_, ResourceEvent("markcompact", "end"));

+  MarkCompactEpilogue();
+
+  if (FLAG_allocation_site_pretenuring) {
+    EvaluateOldSpaceLocalPretenuring(size_of_objects_before_gc);
+  }
+}
+
+
+void Heap::MarkCompactEpilogue() {
   gc_state_ = NOT_IN_GC;

   isolate_->counters()->objs_since_last_full()->Set(0);

   flush_monomorphic_ics_ = false;

-  if (FLAG_allocation_site_pretenuring) {
-    EvaluateOldSpaceLocalPretenuring(size_of_objects_before_gc);
-  }
+  incremental_marking()->Epilogue();
 }


Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index b83f2ea1966157ed61a0f95e4eb1431fbed4d23a..69e232b043cbfe62957713ae059aadf9b6bbea2c 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1936,6 +1936,7 @@ class Heap {

   // Code to be run before and after mark-compact.
   void MarkCompactPrologue();
+  void MarkCompactEpilogue();

   void ProcessNativeContexts(WeakObjectRetainer* retainer);
   void ProcessArrayBuffers(WeakObjectRetainer* retainer);
Index: src/heap/incremental-marking.cc
diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc index 08f11c62799b314f687f55bad6aeac58c34ff843..33f9de0da4b977903103f5fbbaae1bb6b1340e82 100644
--- a/src/heap/incremental-marking.cc
+++ b/src/heap/incremental-marking.cc
@@ -27,7 +27,8 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
       allocated_(0),
       idle_marking_delay_counter_(0),
       no_marking_scope_depth_(0),
-      unscanned_bytes_of_large_object_(0) {}
+      unscanned_bytes_of_large_object_(0),
+      was_activated_(false) {}


 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot,
@@ -423,6 +424,9 @@ bool IncrementalMarking::ShouldActivate() {
 }


+bool IncrementalMarking::WasActivated() { return was_activated_; }
+
+
 bool IncrementalMarking::WorthActivating() {
 #ifndef DEBUG
   static const intptr_t kActivationThreshold = 8 * MB;
@@ -490,6 +494,8 @@ void IncrementalMarking::Start(CompactionFlag flag) {

   ResetStepCounters();

+  was_activated_ = true;
+
   if (!heap_->mark_compact_collector()->sweeping_in_progress()) {
     StartMarking(flag);
   } else {
@@ -785,6 +791,9 @@ void IncrementalMarking::MarkingComplete(CompletionAction action) {
 }


+void IncrementalMarking::Epilogue() { was_activated_ = false; }
+
+
 void IncrementalMarking::OldSpaceStep(intptr_t allocated) {
   if (IsStopped() && ShouldActivate()) {
     // TODO(hpayer): Let's play safe for now, but compaction should be
Index: src/heap/incremental-marking.h
diff --git a/src/heap/incremental-marking.h b/src/heap/incremental-marking.h
index 0a3ad615aacf9303c3d31f78412d9344687745c6..56c5a24c2ceb732ab90bc1865da5bf184e5f46f8 100644
--- a/src/heap/incremental-marking.h
+++ b/src/heap/incremental-marking.h
@@ -48,6 +48,8 @@ class IncrementalMarking {

   bool ShouldActivate();

+  bool WasActivated();
+
   enum CompactionFlag { ALLOW_COMPACTION, PREVENT_COMPACTION };

   void Start(CompactionFlag flag = ALLOW_COMPACTION);
@@ -66,6 +68,8 @@ class IncrementalMarking {

   void MarkingComplete(CompletionAction action);

+  void Epilogue();
+
// It's hard to know how much work the incremental marker should do to make // progress in the face of the mutator creating new work for it. We start
   // of at a moderate rate of work and gradually increase the speed of the
@@ -222,6 +226,8 @@ class IncrementalMarking {

   int unscanned_bytes_of_large_object_;

+  bool was_activated_;
+
   DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking);
 };
 }


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