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/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 namespace compiler { | 13 namespace compiler { |
14 | 14 |
15 // 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 |
16 // from end. | 16 // from end. |
17 class AllNodes { | 17 class AllNodes { |
18 public: | 18 public: |
19 // Constructor. Traverses the graph and builds the {live} sets. | 19 // Constructor. Traverses the graph and builds the {live} sets. |
20 AllNodes(Zone* local_zone, const Graph* graph); | 20 AllNodes(Zone* local_zone, const Graph* graph); |
| 21 // Constructor. Traverses the graph and builds the {live} set reachable from |
| 22 // a node in the graph. |
| 23 AllNodes(Zone* local_zone, Node* end, const Graph* graph); |
21 | 24 |
22 bool IsLive(Node* node) { | 25 bool IsLive(Node* node) { |
23 if (!node) return false; | 26 if (!node) return false; |
24 size_t id = node->id(); | 27 size_t id = node->id(); |
25 return id < is_live.size() && is_live[id]; | 28 return id < is_live.size() && is_live[id]; |
26 } | 29 } |
27 | 30 |
28 NodeVector live; // Nodes reachable from end. | 31 NodeVector live; // Nodes reachable from end. |
29 | 32 |
30 private: | 33 private: |
| 34 void Mark(Zone* local_zone, Node* end, const Graph* graph); |
| 35 |
31 BoolVector is_live; | 36 BoolVector is_live; |
32 }; | 37 }; |
33 | 38 |
34 } // namespace compiler | 39 } // namespace compiler |
35 } // namespace internal | 40 } // namespace internal |
36 } // namespace v8 | 41 } // namespace v8 |
37 | 42 |
38 #endif // V8_COMPILER_ALL_NODES_H_ | 43 #endif // V8_COMPILER_ALL_NODES_H_ |
OLD | NEW |