v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
all-nodes.h
Go to the documentation of this file.
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"
10
11namespace v8 {
12namespace internal {
13namespace compiler {
14
15// A helper utility that traverses the graph and gathers all nodes reachable
16// from end.
17class AllNodes {
18 public:
19 // Constructor. Traverses the graph and builds the {reachable} set of nodes
20 // reachable from {end}. When {only_inputs} is true, find the nodes
21 // reachable through input edges; these are all live nodes.
22 AllNodes(Zone* local_zone, Node* end, const TFGraph* graph,
23 bool only_inputs = true);
24 // Constructor. Traverses the graph and builds the {reachable} set of nodes
25 // reachable from the End node.
26 AllNodes(Zone* local_zone, const TFGraph* graph, bool only_inputs = true);
27
28 bool IsLive(const Node* node) const {
30 return IsReachable(node);
31 }
32
33 bool IsReachable(const Node* node) const {
34 if (!node) return false;
35 int id = node->id();
36 return id < is_reachable_.length() && is_reachable_.Contains(id);
37 }
38
39 NodeVector reachable; // Nodes reachable from end.
40
41 private:
42 void Mark(Zone* local_zone, Node* end, const TFGraph* graph);
43
45 const bool only_inputs_;
46};
47
48} // namespace compiler
49} // namespace internal
50} // namespace v8
51
52#endif // V8_COMPILER_ALL_NODES_H_
bool Contains(int i) const
Definition bit-vector.h:180
AllNodes(Zone *local_zone, Node *end, const TFGraph *graph, bool only_inputs=true)
Definition all-nodes.cc:20
bool IsLive(const Node *node) const
Definition all-nodes.h:28
bool IsReachable(const Node *node) const
Definition all-nodes.h:33
int end
#define CHECK(condition)
Definition logging.h:124