[GC] Check for incremental marking when a GC is triggered on reaching the external...
authormlippautz <mlippautz@chromium.org>
Thu, 6 Aug 2015 11:49:47 +0000 (04:49 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 6 Aug 2015 11:49:58 +0000 (11:49 +0000)
We missed a check whether we can actually do incremental marking when starting
it on reaching the external allocation limit.

BUG=chromium:517195
LOG=N

Review URL: https://codereview.chromium.org/1274983002

Cr-Commit-Position: refs/heads/master@{#30043}

src/api.cc
test/cctest/test-api.cc

index ef08b03..e11f366 100644 (file)
@@ -6887,18 +6887,26 @@ Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) {
 void Isolate::CollectAllGarbage(const char* gc_reason) {
   i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
   if (heap->incremental_marking()->IsStopped()) {
-    heap->StartIncrementalMarking(i::Heap::kNoGCFlags, kGCCallbackFlagForced,
-                                  gc_reason);
-  }
-  // TODO(mlippautz): Compute the time slice for incremental marking based on
-  // memory pressure.
-  double deadline = heap->MonotonicallyIncreasingTimeInMs() +
-                    i::FLAG_external_allocation_limit_incremental_time;
-  heap->AdvanceIncrementalMarking(0, deadline,
-                                  i::IncrementalMarking::StepActions(
-                                      i::IncrementalMarking::GC_VIA_STACK_GUARD,
-                                      i::IncrementalMarking::FORCE_MARKING,
-                                      i::IncrementalMarking::FORCE_COMPLETION));
+    if (heap->incremental_marking()->CanBeActivated()) {
+      heap->StartIncrementalMarking(i::Heap::kNoGCFlags, kGCCallbackFlagForced,
+                                    gc_reason);
+    } else {
+      heap->CollectAllGarbage(i::Heap::kNoGCFlags, gc_reason,
+                              kGCCallbackFlagForced);
+    }
+  } else {
+    // Incremental marking is turned on an has already been started.
+
+    // TODO(mlippautz): Compute the time slice for incremental marking based on
+    // memory pressure.
+    double deadline = heap->MonotonicallyIncreasingTimeInMs() +
+                      i::FLAG_external_allocation_limit_incremental_time;
+    heap->AdvanceIncrementalMarking(
+        0, deadline, i::IncrementalMarking::StepActions(
+                         i::IncrementalMarking::GC_VIA_STACK_GUARD,
+                         i::IncrementalMarking::FORCE_MARKING,
+                         i::IncrementalMarking::FORCE_COMPLETION));
+  }
 }
 
 
index 9df749b..bbd4aa1 100644 (file)
@@ -12574,6 +12574,17 @@ THREADED_TEST(ExternalAllocatedMemory) {
 }
 
 
+TEST(Regress51719) {
+  i::FLAG_incremental_marking = false;
+  CcTest::InitializeVM();
+
+  const int64_t kTriggerGCSize =
+      v8::internal::Internals::kExternalAllocationLimit + 1;
+  v8::Isolate* isolate = CcTest::isolate();
+  isolate->AdjustAmountOfExternalAllocatedMemory(kTriggerGCSize);
+}
+
+
 // Regression test for issue 54, object templates with internal fields
 // but no accessors or interceptors did not get their internal field
 // count set on instances.