LCOV - code coverage report
Current view: top level - test/cctest/heap - test-concurrent-marking.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 55 55 100.0 %
Date: 2017-10-20 Functions: 6 6 100.0 %

          Line data    Source code
       1             : // Copyright 2017 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include <stdlib.h>
       6             : 
       7             : #include "src/v8.h"
       8             : 
       9             : #include "src/heap/concurrent-marking.h"
      10             : #include "src/heap/heap-inl.h"
      11             : #include "src/heap/heap.h"
      12             : #include "src/heap/mark-compact.h"
      13             : #include "src/heap/worklist.h"
      14             : #include "test/cctest/cctest.h"
      15             : #include "test/cctest/heap/heap-utils.h"
      16             : 
      17             : namespace v8 {
      18             : namespace internal {
      19             : namespace heap {
      20             : 
      21          18 : void PublishSegment(ConcurrentMarking::MarkingWorklist* worklist,
      22             :                     HeapObject* object) {
      23        1188 :   for (size_t i = 0; i <= ConcurrentMarking::MarkingWorklist::kSegmentCapacity;
      24             :        i++) {
      25        1170 :     worklist->Push(0, object);
      26             :   }
      27          18 :   CHECK(worklist->Pop(0, &object));
      28          18 : }
      29             : 
      30       23724 : TEST(ConcurrentMarking) {
      31           6 :   if (!i::FLAG_concurrent_marking) return;
      32           6 :   CcTest::InitializeVM();
      33          18 :   Heap* heap = CcTest::heap();
      34           6 :   CcTest::CollectAllGarbage();
      35           6 :   if (!heap->incremental_marking()->IsStopped()) return;
      36           6 :   MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
      37           6 :   if (collector->sweeping_in_progress()) {
      38           6 :     collector->EnsureSweepingCompleted();
      39             :   }
      40             : 
      41           6 :   ConcurrentMarking::MarkingWorklist shared, bailout, on_hold;
      42           6 :   WeakObjects weak_objects;
      43             :   ConcurrentMarking* concurrent_marking =
      44           6 :       new ConcurrentMarking(heap, &shared, &bailout, &on_hold, &weak_objects);
      45           6 :   PublishSegment(&shared, heap->undefined_value());
      46           6 :   concurrent_marking->ScheduleTasks();
      47           6 :   concurrent_marking->WaitForTasks();
      48           6 :   concurrent_marking->EnsureCompleted();
      49          12 :   delete concurrent_marking;
      50             : }
      51             : 
      52       23724 : TEST(ConcurrentMarkingReschedule) {
      53           6 :   if (!i::FLAG_concurrent_marking) return;
      54           6 :   CcTest::InitializeVM();
      55          24 :   Heap* heap = CcTest::heap();
      56           6 :   CcTest::CollectAllGarbage();
      57           6 :   if (!heap->incremental_marking()->IsStopped()) return;
      58           6 :   MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
      59           6 :   if (collector->sweeping_in_progress()) {
      60           6 :     collector->EnsureSweepingCompleted();
      61             :   }
      62             : 
      63           6 :   ConcurrentMarking::MarkingWorklist shared, bailout, on_hold;
      64           6 :   WeakObjects weak_objects;
      65             :   ConcurrentMarking* concurrent_marking =
      66           6 :       new ConcurrentMarking(heap, &shared, &bailout, &on_hold, &weak_objects);
      67           6 :   PublishSegment(&shared, heap->undefined_value());
      68           6 :   concurrent_marking->ScheduleTasks();
      69           6 :   concurrent_marking->WaitForTasks();
      70           6 :   concurrent_marking->EnsureCompleted();
      71           6 :   PublishSegment(&shared, heap->undefined_value());
      72           6 :   concurrent_marking->RescheduleTasksIfNeeded();
      73           6 :   concurrent_marking->WaitForTasks();
      74           6 :   concurrent_marking->EnsureCompleted();
      75          12 :   delete concurrent_marking;
      76             : }
      77             : 
      78       23724 : TEST(ConcurrentMarkingMarkedBytes) {
      79           6 :   if (!i::FLAG_concurrent_marking) return;
      80           6 :   CcTest::InitializeVM();
      81             :   Isolate* isolate = CcTest::i_isolate();
      82          30 :   Heap* heap = CcTest::heap();
      83             :   HandleScope sc(isolate);
      84           6 :   Handle<FixedArray> root = isolate->factory()->NewFixedArray(1000000);
      85           6 :   CcTest::CollectAllGarbage();
      86           6 :   if (!heap->incremental_marking()->IsStopped()) return;
      87           6 :   heap::SimulateIncrementalMarking(heap, false);
      88           6 :   heap->concurrent_marking()->WaitForTasks();
      89           6 :   heap->concurrent_marking()->EnsureCompleted();
      90          18 :   CHECK_GE(heap->concurrent_marking()->TotalMarkedBytes(), root->Size());
      91             : }
      92             : 
      93             : }  // namespace heap
      94             : }  // namespace internal
      95       71154 : }  // namespace v8

Generated by: LCOV version 1.10