LCOV - code coverage report
Current view: top level - src/compiler - dead-code-elimination.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2019-04-17 Functions: 1 3 33.3 %

          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_DEAD_CODE_ELIMINATION_H_
       6             : #define V8_COMPILER_DEAD_CODE_ELIMINATION_H_
       7             : 
       8             : #include "src/base/compiler-specific.h"
       9             : #include "src/compiler/graph-reducer.h"
      10             : #include "src/globals.h"
      11             : #include "src/machine-type.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : namespace compiler {
      16             : 
      17             : // Forward declarations.
      18             : class CommonOperatorBuilder;
      19             : 
      20             : // Propagates {Dead} control and {DeadValue} values through the graph and
      21             : // thereby removes dead code.
      22             : // We detect dead values based on types, replacing uses of nodes with
      23             : // {Type::None()} with {DeadValue}. A pure node (other than a phi) using
      24             : // {DeadValue} is replaced by {DeadValue}. When {DeadValue} hits the effect
      25             : // chain, a crashing {Unreachable} node is inserted and the rest of the effect
      26             : // chain is collapsed. We wait for the {EffectControlLinearizer} to connect
      27             : // {Unreachable} nodes to the graph end, since this is much easier if there is
      28             : // no floating control.
      29             : // {DeadValue} has an input, which has to have {Type::None()}. This input is
      30             : // important to maintain the dependency on the cause of the unreachable code.
      31             : // {Unreachable} has a value output and {Type::None()} so it can be used by
      32             : // {DeadValue}.
      33             : // {DeadValue} nodes track a {MachineRepresentation} so they can be lowered to a
      34             : // value-producing node. {DeadValue} has the runtime semantics of crashing and
      35             : // behaves like a constant of its representation so it can be used in gap moves.
      36             : // Since phi nodes are the only remaining use of {DeadValue}, this
      37             : // representation is only adjusted for uses by phi nodes.
      38             : // In contrast to {DeadValue}, {Dead} can never remain in the graph.
      39             : class V8_EXPORT_PRIVATE DeadCodeElimination final
      40             :     : public NON_EXPORTED_BASE(AdvancedReducer) {
      41             :  public:
      42             :   DeadCodeElimination(Editor* editor, Graph* graph,
      43             :                       CommonOperatorBuilder* common, Zone* temp_zone);
      44     5721204 :   ~DeadCodeElimination() final = default;
      45             : 
      46         193 :   const char* reducer_name() const override { return "DeadCodeElimination"; }
      47             : 
      48             :   Reduction Reduce(Node* node) final;
      49             : 
      50             :  private:
      51             :   Reduction ReduceEnd(Node* node);
      52             :   Reduction ReduceLoopOrMerge(Node* node);
      53             :   Reduction ReduceLoopExit(Node* node);
      54             :   Reduction ReduceNode(Node* node);
      55             :   Reduction ReducePhi(Node* node);
      56             :   Reduction ReducePureNode(Node* node);
      57             :   Reduction ReduceUnreachableOrIfException(Node* node);
      58             :   Reduction ReduceEffectNode(Node* node);
      59             :   Reduction ReduceDeoptimizeOrReturnOrTerminateOrTailCall(Node* node);
      60             :   Reduction ReduceBranchOrSwitch(Node* node);
      61             : 
      62             :   Reduction RemoveLoopExit(Node* node);
      63             :   Reduction PropagateDeadControl(Node* node);
      64             : 
      65             :   void TrimMergeOrPhi(Node* node, int size);
      66             : 
      67             :   Node* DeadValue(Node* none_node,
      68             :                   MachineRepresentation rep = MachineRepresentation::kNone);
      69             : 
      70             :   Graph* graph() const { return graph_; }
      71             :   CommonOperatorBuilder* common() const { return common_; }
      72             :   Node* dead() const { return dead_; }
      73             : 
      74             :   Graph* const graph_;
      75             :   CommonOperatorBuilder* const common_;
      76             :   Node* const dead_;
      77             :   Zone* zone_;
      78             : 
      79             :   DISALLOW_COPY_AND_ASSIGN(DeadCodeElimination);
      80             : };
      81             : 
      82             : }  // namespace compiler
      83             : }  // namespace internal
      84             : }  // namespace v8
      85             : 
      86             : #endif  // V8_COMPILER_DEAD_CODE_ELIMINATION_H_

Generated by: LCOV version 1.10