LCOV - code coverage report
Current view: top level - src/compiler - all-nodes.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 23 23 100.0 %
Date: 2019-01-20 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // Copyright 2014 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/all-nodes.h"
       6             : 
       7             : #include "src/compiler/graph.h"
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : namespace compiler {
      12             : 
      13     1570219 : AllNodes::AllNodes(Zone* local_zone, const Graph* graph, bool only_inputs)
      14             :     : reachable(local_zone),
      15             :       is_reachable_(graph->NodeCount(), false, local_zone),
      16      523419 :       only_inputs_(only_inputs) {
      17      523419 :   Mark(local_zone, graph->end(), graph);
      18      523433 : }
      19             : 
      20        7422 : AllNodes::AllNodes(Zone* local_zone, Node* end, const Graph* graph,
      21             :                    bool only_inputs)
      22             :     : reachable(local_zone),
      23             :       is_reachable_(graph->NodeCount(), false, local_zone),
      24        3711 :       only_inputs_(only_inputs) {
      25        3711 :   Mark(local_zone, end, graph);
      26        3711 : }
      27             : 
      28      529734 : void AllNodes::Mark(Zone* local_zone, Node* end, const Graph* graph) {
      29             :   DCHECK_LT(end->id(), graph->NodeCount());
      30   123240828 :   is_reachable_[end->id()] = true;
      31    49542193 :   reachable.push_back(end);
      32             :   // Find all nodes reachable from {end}.
      33    98027094 :   for (size_t i = 0; i < reachable.size(); i++) {
      34   389827296 :     for (Node* const input : reachable[i]->inputs()) {
      35   122184101 :       if (input == nullptr) {
      36             :         // TODO(titzer): print a warning.
      37             :         continue;
      38             :       }
      39   244367940 :       if (!is_reachable_[input->id()]) {
      40             :         is_reachable_[input->id()] = true;
      41    47958792 :         reachable.push_back(input);
      42             :       }
      43             :     }
      44    48486286 :     if (!only_inputs_) {
      45        9786 :       for (Node* use : reachable[i]->uses()) {
      46        5220 :         if (use == nullptr || use->id() >= graph->NodeCount()) {
      47             :           continue;
      48             :         }
      49        5220 :         if (!is_reachable_[use->id()]) {
      50             :           is_reachable_[use->id()] = true;
      51         322 :           reachable.push_back(use);
      52             :         }
      53             :       }
      54             :     }
      55             :   }
      56      527143 : }
      57             : 
      58             : }  // namespace compiler
      59             : }  // namespace internal
      60      183867 : }  // namespace v8

Generated by: LCOV version 1.10