| 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 #ifndef V8_COMPILER_GRAPH_REDUCER_H_ | 5 #ifndef V8_COMPILER_GRAPH_REDUCER_H_ |
| 6 #define V8_COMPILER_GRAPH_REDUCER_H_ | 6 #define V8_COMPILER_GRAPH_REDUCER_H_ |
| 7 | 7 |
| 8 #include "src/compiler/node-marker.h" | 8 #include "src/compiler/node-marker.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // language-specific reductions (e.g. reduction based on types or constant | 40 // language-specific reductions (e.g. reduction based on types or constant |
| 41 // folding of low-level operators) can be integrated into the graph reduction | 41 // folding of low-level operators) can be integrated into the graph reduction |
| 42 // phase. | 42 // phase. |
| 43 class Reducer { | 43 class Reducer { |
| 44 public: | 44 public: |
| 45 virtual ~Reducer() {} | 45 virtual ~Reducer() {} |
| 46 | 46 |
| 47 // Try to reduce a node if possible. | 47 // Try to reduce a node if possible. |
| 48 virtual Reduction Reduce(Node* node) = 0; | 48 virtual Reduction Reduce(Node* node) = 0; |
| 49 | 49 |
| 50 // Ask this reducer to finish operation, returns {true} if the reducer is | |
| 51 // done, while {false} indicates that the graph might need to be reduced | |
| 52 // again. | |
| 53 // TODO(turbofan): Remove this once the dead node trimming is in the | |
| 54 // GraphReducer. | |
| 55 virtual bool Finish(); | |
| 56 | |
| 57 // Helper functions for subclasses to produce reductions for a node. | 50 // Helper functions for subclasses to produce reductions for a node. |
| 58 static Reduction NoChange() { return Reduction(); } | 51 static Reduction NoChange() { return Reduction(); } |
| 59 static Reduction Replace(Node* node) { return Reduction(node); } | 52 static Reduction Replace(Node* node) { return Reduction(node); } |
| 60 static Reduction Changed(Node* node) { return Reduction(node); } | 53 static Reduction Changed(Node* node) { return Reduction(node); } |
| 61 }; | 54 }; |
| 62 | 55 |
| 63 | 56 |
| 64 // An advanced reducer can also edit the graphs by changing and replacing nodes | 57 // An advanced reducer can also edit the graphs by changing and replacing nodes |
| 65 // other than the one currently being reduced. | 58 // other than the one currently being reduced. |
| 66 class AdvancedReducer : public Reducer { | 59 class AdvancedReducer : public Reducer { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 ZoneStack<NodeState> stack_; | 172 ZoneStack<NodeState> stack_; |
| 180 | 173 |
| 181 DISALLOW_COPY_AND_ASSIGN(GraphReducer); | 174 DISALLOW_COPY_AND_ASSIGN(GraphReducer); |
| 182 }; | 175 }; |
| 183 | 176 |
| 184 } // namespace compiler | 177 } // namespace compiler |
| 185 } // namespace internal | 178 } // namespace internal |
| 186 } // namespace v8 | 179 } // namespace v8 |
| 187 | 180 |
| 188 #endif // V8_COMPILER_GRAPH_REDUCER_H_ | 181 #endif // V8_COMPILER_GRAPH_REDUCER_H_ |
| OLD | NEW |