Reviewers: Michael Starzinger,

Message:
PTAL

Description:
Fix counting of scanned bytes in incremental marking step for large object.

[email protected]
BUG=241815

Please review this at https://chromiumcodereview.appspot.com/15745004/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/incremental-marking.h
  M src/incremental-marking.cc
  M test/cctest/test-heap.cc


Index: src/incremental-marking.cc
diff --git a/src/incremental-marking.cc b/src/incremental-marking.cc
index bacbb93ad2e8cb6a335c577e8ccf69ade8c82d63..e19d6e28f69f9141b3d47756bcf2d3129a9a6eaf 100644
--- a/src/incremental-marking.cc
+++ b/src/incremental-marking.cc
@@ -54,7 +54,8 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
       should_hurry_(false),
       marking_speed_(0),
       allocated_(0),
-      no_marking_scope_depth_(0) {
+      no_marking_scope_depth_(0),
+      unscanned_bytes_of_large_object_(0) {
 }


@@ -241,6 +242,7 @@ class IncrementalMarkingMarkingVisitor
                              chunk->progress_bar());
       int end_offset = Min(object_size,
                            start_offset + kProgressBarScanningChunk);
+      int already_scanned_offset = start_offset;
       bool scan_until_end = false;
       do {
         VisitPointersWithAnchor(heap,
@@ -254,6 +256,8 @@ class IncrementalMarkingMarkingVisitor
       chunk->set_progress_bar(start_offset);
       if (start_offset < object_size) {
         heap->incremental_marking()->marking_deque()->UnshiftGrey(object);
+        heap->incremental_marking()->NotifyIncompleteScanOfObject(
+            object_size - (start_offset - already_scanned_offset));
       }
     } else {
       FixedArrayVisitor::Visit(map, object);
@@ -739,8 +743,9 @@ void IncrementalMarking::ProcessMarkingDeque(intptr_t bytes_to_process) {
     if (map == filler_map) continue;

     int size = obj->SizeFromMap(map);
-    bytes_to_process -= size;
+    unscanned_bytes_of_large_object_ = 0;
     VisitObject(map, obj, size);
+    bytes_to_process -= (size - unscanned_bytes_of_large_object_);
   }
 }

Index: src/incremental-marking.h
diff --git a/src/incremental-marking.h b/src/incremental-marking.h
index 47d5a518bf841076c805b27c5acc22719ab3f2b8..d47c300ef3f97893e3f018c0aab3a20c76856da9 100644
--- a/src/incremental-marking.h
+++ b/src/incremental-marking.h
@@ -220,6 +220,10 @@ class IncrementalMarking {

   void UncommitMarkingDeque();

+  void NotifyIncompleteScanOfObject(int unscanned_bytes) {
+    unscanned_bytes_of_large_object_ = unscanned_bytes;
+  }
+
  private:
   int64_t SpaceLeftInOldSpace();

@@ -274,6 +278,8 @@ class IncrementalMarking {

   int no_marking_scope_depth_;

+  int unscanned_bytes_of_large_object_;
+
   DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking);
 };

Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index ca173c25a56b131bb8c871e9ed40903562e77099..3dca2c163a9ce871a9878f1fd15cb950fb2a5e7e 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -3103,3 +3103,19 @@ TEST(DeferredHandles) {
   isolate->handle_scope_implementer()->Iterate(&visitor);
   deferred.Detach();
 }
+
+
+TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+  CompileRun("function f(n) {"
+             "    var a = new Array(n);"
+             "    for (var i = 0; i < n; i += 100) a[i] = i;"
+             "};"
+             "f(10 * 1024 * 1024);");
+  IncrementalMarking* marking = HEAP->incremental_marking();
+  if (marking->IsStopped()) marking->Start();
+  // This big step should be sufficient to mark the whole array.
+  marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
+  ASSERT(marking->IsComplete());
+}


--
--
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/groups/opt_out.


Reply via email to