OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_ALL_NODES_H_ | 5 #ifndef V8_COMPILER_ALL_NODES_H_ |
6 #define V8_COMPILER_ALL_NODES_H_ | 6 #define V8_COMPILER_ALL_NODES_H_ |
7 | 7 |
8 #include "src/compiler/graph.h" | |
9 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
10 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
11 | 10 |
12 namespace v8 { | 11 namespace v8 { |
13 namespace internal { | 12 namespace internal { |
14 namespace compiler { | 13 namespace compiler { |
15 | 14 |
16 // A helper utility that traverses the graph and gathers all nodes reachable | 15 // A helper utility that traverses the graph and gathers all nodes reachable |
17 // from end. | 16 // from end. |
18 class AllNodes { | 17 class AllNodes { |
19 public: | 18 public: |
20 // Constructor. Traverses the graph and builds the {live} and {gray} sets. | 19 // Constructor. Traverses the graph and builds the {live} sets. |
21 AllNodes(Zone* local_zone, const Graph* graph); | 20 AllNodes(Zone* local_zone, const Graph* graph); |
22 | 21 |
23 bool IsLive(Node* node) { | 22 bool IsLive(Node* node) { |
24 return node != nullptr && node->id() < static_cast<int>(state.size()) && | 23 if (!node) return false; |
25 state[node->id()] == kLive; | 24 size_t id = node->id(); |
| 25 return id < is_live.size() && is_live[id]; |
26 } | 26 } |
27 | 27 |
28 NodeVector live; // Nodes reachable from end. | 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 | 29 |
32 private: | 30 private: |
33 enum State { kDead, kGray, kLive }; | 31 BoolVector is_live; |
| 32 }; |
34 | 33 |
35 ZoneVector<State> state; | 34 } // namespace compiler |
36 }; | 35 } // namespace internal |
37 } | 36 } // namespace v8 |
38 } | |
39 } // namespace v8::internal::compiler | |
40 | 37 |
41 #endif // V8_COMPILER_ALL_NODES_H_ | 38 #endif // V8_COMPILER_ALL_NODES_H_ |
OLD | NEW |