Home | History | Annotate | Download | only in compiler
      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_ALL_NODES_H_
      6 #define V8_COMPILER_ALL_NODES_H_
      7 
      8 #include "src/compiler/node.h"
      9 #include "src/zone-containers.h"
     10 
     11 namespace v8 {
     12 namespace internal {
     13 namespace compiler {
     14 
     15 // A helper utility that traverses the graph and gathers all nodes reachable
     16 // from end.
     17 class AllNodes {
     18  public:
     19   // Constructor. Traverses the graph and builds the {live} sets.
     20   AllNodes(Zone* local_zone, const Graph* graph);
     21 
     22   bool IsLive(Node* node) {
     23     if (!node) return false;
     24     size_t id = node->id();
     25     return id < is_live.size() && is_live[id];
     26   }
     27 
     28   NodeVector live;  // Nodes reachable from end.
     29 
     30  private:
     31   BoolVector is_live;
     32 };
     33 
     34 }  // namespace compiler
     35 }  // namespace internal
     36 }  // namespace v8
     37 
     38 #endif  // V8_COMPILER_ALL_NODES_H_
     39