e6a83ef623761e57da41daa2a7dd65d46a2ad3ac
[platform/upstream/nodejs.git] / deps / v8 / src / compiler / all-nodes.h
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/graph.h"
9 #include "src/compiler/node.h"
10 #include "src/zone-containers.h"
11
12 namespace v8 {
13 namespace internal {
14 namespace compiler {
15
16 // A helper utility that traverses the graph and gathers all nodes reachable
17 // from end.
18 class AllNodes {
19  public:
20   // Constructor. Traverses the graph and builds the {live} and {gray} sets.
21   AllNodes(Zone* local_zone, const Graph* graph);
22
23   bool IsLive(Node* node) {
24     return node != nullptr && node->id() < static_cast<int>(state.size()) &&
25            state[node->id()] == kLive;
26   }
27
28   NodeVector live;  // Nodes reachable from end.
29   NodeVector gray;  // Nodes themselves not reachable from end, but that
30                     // appear in use lists of live nodes.
31
32  private:
33   enum State { kDead, kGray, kLive };
34
35   ZoneVector<State> state;
36 };
37 }
38 }
39 }  // namespace v8::internal::compiler
40
41 #endif  // V8_COMPILER_ALL_NODES_H_