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 node = replacement; | 65 node = replacement; |
66 reduce = true; | 66 reduce = true; |
67 break; | 67 break; |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 // A helper class to reuse the node traversal algorithm. | 74 // A helper class to reuse the node traversal algorithm. |
75 struct GraphReducerVisitor V8_FINAL : public NullNodeVisitor { | 75 struct GraphReducerVisitor FINAL : public NullNodeVisitor { |
76 explicit GraphReducerVisitor(GraphReducer* reducer) : reducer_(reducer) {} | 76 explicit GraphReducerVisitor(GraphReducer* reducer) : reducer_(reducer) {} |
77 GenericGraphVisit::Control Post(Node* node) { | 77 GenericGraphVisit::Control Post(Node* node) { |
78 reducer_->ReduceNode(node); | 78 reducer_->ReduceNode(node); |
79 return GenericGraphVisit::CONTINUE; | 79 return GenericGraphVisit::CONTINUE; |
80 } | 80 } |
81 GraphReducer* reducer_; | 81 GraphReducer* reducer_; |
82 }; | 82 }; |
83 | 83 |
84 | 84 |
85 void GraphReducer::ReduceGraph() { | 85 void GraphReducer::ReduceGraph() { |
86 GraphReducerVisitor visitor(this); | 86 GraphReducerVisitor visitor(this); |
87 // Perform a post-order reduction of all nodes starting from the end. | 87 // Perform a post-order reduction of all nodes starting from the end. |
88 graph()->VisitNodeInputsFromEnd(&visitor); | 88 graph()->VisitNodeInputsFromEnd(&visitor); |
89 } | 89 } |
90 | 90 |
91 | 91 |
92 // TODO(titzer): partial graph reductions. | 92 // TODO(titzer): partial graph reductions. |
93 } | 93 } |
94 } | 94 } |
95 } // namespace v8::internal::compiler | 95 } // namespace v8::internal::compiler |
OLD | NEW |