LCOV - code coverage report
Current view: top level - src/heap - incremental-marking-job.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 26 26 100.0 %
Date: 2017-04-26 Functions: 4 5 80.0 %

          Line data    Source code
       1             : // Copyright 2012 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 "src/heap/incremental-marking-job.h"
       6             : 
       7             : #include "src/base/platform/time.h"
       8             : #include "src/heap/heap-inl.h"
       9             : #include "src/heap/heap.h"
      10             : #include "src/heap/incremental-marking.h"
      11             : #include "src/isolate.h"
      12             : #include "src/v8.h"
      13             : 
      14             : namespace v8 {
      15             : namespace internal {
      16             : 
      17        1229 : void IncrementalMarkingJob::Start(Heap* heap) {
      18             :   DCHECK(!heap->incremental_marking()->IsStopped());
      19        1229 :   ScheduleTask(heap);
      20        1229 : }
      21             : 
      22        6069 : void IncrementalMarkingJob::NotifyTask() { task_pending_ = false; }
      23             : 
      24        9952 : void IncrementalMarkingJob::ScheduleTask(Heap* heap) {
      25        9952 :   if (!task_pending_) {
      26             :     v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap->isolate());
      27        6107 :     task_pending_ = true;
      28        6107 :     auto task = new Task(heap->isolate(), this);
      29        6107 :     V8::GetCurrentPlatform()->CallOnForegroundThread(isolate, task);
      30             :   }
      31        9952 : }
      32             : 
      33       11304 : void IncrementalMarkingJob::Task::Step(Heap* heap) {
      34             :   const int kIncrementalMarkingDelayMs = 1;
      35             :   double deadline =
      36        5652 :       heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs;
      37             :   heap->incremental_marking()->AdvanceIncrementalMarking(
      38             :       deadline, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
      39        5652 :       i::IncrementalMarking::FORCE_COMPLETION, i::StepOrigin::kTask);
      40             :   heap->FinalizeIncrementalMarkingIfComplete(
      41        5652 :       GarbageCollectionReason::kFinalizeMarkingViaTask);
      42        5652 : }
      43             : 
      44        6069 : void IncrementalMarkingJob::Task::RunInternal() {
      45       12138 :   Heap* heap = isolate()->heap();
      46        6069 :   job_->NotifyTask();
      47             :   IncrementalMarking* incremental_marking = heap->incremental_marking();
      48        6069 :   if (incremental_marking->IsStopped()) {
      49         475 :     if (heap->IncrementalMarkingLimitReached() !=
      50             :         Heap::IncrementalMarkingLimit::kNoLimit) {
      51             :       heap->StartIncrementalMarking(Heap::kNoGCFlags,
      52             :                                     GarbageCollectionReason::kIdleTask,
      53          58 :                                     kNoGCCallbackFlags);
      54             :     }
      55             :   }
      56        6069 :   if (!incremental_marking->IsStopped()) {
      57        5652 :     Step(heap);
      58        5652 :     if (!incremental_marking->IsStopped()) {
      59        5148 :       job_->ScheduleTask(heap);
      60             :     }
      61             :   }
      62        6069 : }
      63             : 
      64             : }  // namespace internal
      65             : }  // namespace v8

Generated by: LCOV version 1.10