OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/compiler/graph-reducer.h" | 5 #include "src/compiler/graph-reducer.h" |
6 | 6 |
7 #include <functional> | 7 #include <functional> |
8 | 8 |
9 #include "src/compiler/graph-inl.h" | 9 #include "src/compiler/graph-inl.h" |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 break; | 65 break; |
66 } | 66 } |
67 } | 67 } |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 // A helper class to reuse the node traversal algorithm. | 72 // A helper class to reuse the node traversal algorithm. |
73 struct GraphReducerVisitor FINAL : public NullNodeVisitor { | 73 struct GraphReducerVisitor FINAL : public NullNodeVisitor { |
74 explicit GraphReducerVisitor(GraphReducer* reducer) : reducer_(reducer) {} | 74 explicit GraphReducerVisitor(GraphReducer* reducer) : reducer_(reducer) {} |
75 GenericGraphVisit::Control Post(Node* node) { | 75 void Post(Node* node) { reducer_->ReduceNode(node); } |
76 reducer_->ReduceNode(node); | |
77 return GenericGraphVisit::CONTINUE; | |
78 } | |
79 GraphReducer* reducer_; | 76 GraphReducer* reducer_; |
80 }; | 77 }; |
81 | 78 |
82 | 79 |
83 void GraphReducer::ReduceGraph() { | 80 void GraphReducer::ReduceGraph() { |
84 GraphReducerVisitor visitor(this); | 81 GraphReducerVisitor visitor(this); |
85 // Perform a post-order reduction of all nodes starting from the end. | 82 // Perform a post-order reduction of all nodes starting from the end. |
86 graph()->VisitNodeInputsFromEnd(&visitor); | 83 graph()->VisitNodeInputsFromEnd(&visitor); |
87 } | 84 } |
88 | 85 |
89 | 86 |
90 // TODO(titzer): partial graph reductions. | 87 // TODO(titzer): partial graph reductions. |
91 | 88 |
92 } // namespace compiler | 89 } // namespace compiler |
93 } // namespace internal | 90 } // namespace internal |
94 } // namespace v8 | 91 } // namespace v8 |
OLD | NEW |