LCOV - code coverage report
Current view: top level - src/compiler - graph-trimmer.h (source / functions) Hit Total Coverage
Test: app.info Lines: 8 8 100.0 %
Date: 2017-04-26 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright 2015 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             : #ifndef V8_COMPILER_GRAPH_TRIMMER_H_
       6             : #define V8_COMPILER_GRAPH_TRIMMER_H_
       7             : 
       8             : #include "src/compiler/node-marker.h"
       9             : #include "src/globals.h"
      10             : 
      11             : namespace v8 {
      12             : namespace internal {
      13             : namespace compiler {
      14             : 
      15             : // Forward declarations.
      16             : class Graph;
      17             : 
      18             : 
      19             : // Trims dead nodes from the node graph.
      20             : class V8_EXPORT_PRIVATE GraphTrimmer final {
      21             :  public:
      22             :   GraphTrimmer(Zone* zone, Graph* graph);
      23             :   ~GraphTrimmer();
      24             : 
      25             :   // Trim nodes in the {graph} that are not reachable from {graph->end()}.
      26             :   void TrimGraph();
      27             : 
      28             :   // Trim nodes in the {graph} that are not reachable from either {graph->end()}
      29             :   // or any of the roots in the sequence [{begin},{end}[.
      30             :   template <typename ForwardIterator>
      31     2447086 :   void TrimGraph(ForwardIterator begin, ForwardIterator end) {
      32    78181138 :     while (begin != end) {
      33    73286984 :       Node* const node = *begin++;
      34    73286984 :       if (!node->IsDead()) MarkAsLive(node);
      35             :     }
      36     2447068 :     TrimGraph();
      37     2447053 :   }
      38             : 
      39             :  private:
      40             :   V8_INLINE bool IsLive(Node* const node) { return is_live_.Get(node); }
      41             :   V8_INLINE void MarkAsLive(Node* const node) {
      42             :     DCHECK(!node->IsDead());
      43   611358661 :     if (!IsLive(node)) {
      44             :       is_live_.Set(node, true);
      45   229198344 :       live_.push_back(node);
      46             :     }
      47             :   }
      48             : 
      49             :   Graph* graph() const { return graph_; }
      50             : 
      51             :   Graph* const graph_;
      52             :   NodeMarker<bool> is_live_;
      53             :   NodeVector live_;
      54             : 
      55             :   DISALLOW_COPY_AND_ASSIGN(GraphTrimmer);
      56             : };
      57             : 
      58             : }  // namespace compiler
      59             : }  // namespace internal
      60             : }  // namespace v8
      61             : 
      62             : #endif  // V8_COMPILER_GRAPH_TRIMMER_H_

Generated by: LCOV version 1.10