LCOV - code coverage report
Current view: top level - src/compiler - checkpoint-elimination.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 14 14 100.0 %
Date: 2017-10-20 Functions: 4 4 100.0 %

          Line data    Source code
       1             : // Copyright 2016 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/compiler/checkpoint-elimination.h"
       6             : 
       7             : #include "src/compiler/node-properties.h"
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : namespace compiler {
      12             : 
      13     1330107 : CheckpointElimination::CheckpointElimination(Editor* editor)
      14     1330107 :     : AdvancedReducer(editor) {}
      15             : 
      16             : namespace {
      17             : 
      18             : // The given checkpoint is redundant if it is effect-wise dominated by another
      19             : // checkpoint and there is no observable write in between. For now we consider
      20             : // a linear effect chain only instead of true effect-wise dominance.
      21     8841682 : bool IsRedundantCheckpoint(Node* node) {
      22    22623928 :   Node* effect = NodeProperties::GetEffectInput(node);
      23    30458908 :   while (effect->op()->HasProperty(Operator::kNoWrite) &&
      24     7834977 :          effect->op()->EffectInputCount() == 1) {
      25     5865761 :     if (effect->opcode() == IrOpcode::kCheckpoint) return true;
      26     4940563 :     effect = NodeProperties::GetEffectInput(effect);
      27             :   }
      28             :   return false;
      29             : }
      30             : 
      31             : }  // namespace
      32             : 
      33     8841682 : Reduction CheckpointElimination::ReduceCheckpoint(Node* node) {
      34             :   DCHECK_EQ(IrOpcode::kCheckpoint, node->opcode());
      35     8841682 :   if (IsRedundantCheckpoint(node)) {
      36      925198 :     return Replace(NodeProperties::GetEffectInput(node));
      37             :   }
      38             :   return NoChange();
      39             : }
      40             : 
      41    96578310 : Reduction CheckpointElimination::Reduce(Node* node) {
      42    96578310 :   switch (node->opcode()) {
      43             :     case IrOpcode::kCheckpoint:
      44     8841681 :       return ReduceCheckpoint(node);
      45             :     default:
      46             :       break;
      47             :   }
      48             :   return NoChange();
      49             : }
      50             : 
      51             : }  // namespace compiler
      52             : }  // namespace internal
      53             : }  // namespace v8

Generated by: LCOV version 1.10