| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Observe the actions of this reducer. | 66 // Observe the actions of this reducer. |
| 67 class Editor { | 67 class Editor { |
| 68 public: | 68 public: |
| 69 virtual ~Editor() {} | 69 virtual ~Editor() {} |
| 70 | 70 |
| 71 // Replace {node} with {replacement}. | 71 // Replace {node} with {replacement}. |
| 72 virtual void Replace(Node* node, Node* replacement) = 0; | 72 virtual void Replace(Node* node, Node* replacement) = 0; |
| 73 // Revisit the {node} again later. | 73 // Revisit the {node} again later. |
| 74 virtual void Revisit(Node* node) = 0; | 74 virtual void Revisit(Node* node) = 0; |
| 75 // Replace value uses of {node} with {value} and effect uses of {node} with | 75 // Replace value uses of {node} with {value} and effect uses of {node} with |
| 76 // {effect}. If {effect == NULL}, then use the effect input to {node}. All | 76 // {effect}. If {effect == nullptr}, then use the effect input to {node}. |
| 77 // All |
| 77 // control uses will be relaxed assuming {node} cannot throw. | 78 // control uses will be relaxed assuming {node} cannot throw. |
| 78 virtual void ReplaceWithValue(Node* node, Node* value, Node* effect, | 79 virtual void ReplaceWithValue(Node* node, Node* value, Node* effect, |
| 79 Node* control) = 0; | 80 Node* control) = 0; |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 explicit AdvancedReducer(Editor* editor) : editor_(editor) {} | 83 explicit AdvancedReducer(Editor* editor) : editor_(editor) {} |
| 83 | 84 |
| 84 protected: | 85 protected: |
| 85 // Helper functions for subclasses to produce reductions for a node. | 86 // Helper functions for subclasses to produce reductions for a node. |
| 86 static Reduction Replace(Node* node) { return Reducer::Replace(node); } | 87 static Reduction Replace(Node* node) { return Reducer::Replace(node); } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 143 |
| 143 // Reduce a single node. | 144 // Reduce a single node. |
| 144 Reduction Reduce(Node* const); | 145 Reduction Reduce(Node* const); |
| 145 // Reduce the node on top of the stack. | 146 // Reduce the node on top of the stack. |
| 146 void ReduceTop(); | 147 void ReduceTop(); |
| 147 | 148 |
| 148 // Replace {node} with {replacement}. | 149 // Replace {node} with {replacement}. |
| 149 void Replace(Node* node, Node* replacement) final; | 150 void Replace(Node* node, Node* replacement) final; |
| 150 | 151 |
| 151 // Replace value uses of {node} with {value} and effect uses of {node} with | 152 // Replace value uses of {node} with {value} and effect uses of {node} with |
| 152 // {effect}. If {effect == NULL}, then use the effect input to {node}. All | 153 // {effect}. If {effect == nullptr}, then use the effect input to {node}. All |
| 153 // control uses will be relaxed assuming {node} cannot throw. | 154 // control uses will be relaxed assuming {node} cannot throw. |
| 154 void ReplaceWithValue(Node* node, Node* value, Node* effect, | 155 void ReplaceWithValue(Node* node, Node* value, Node* effect, |
| 155 Node* control) final; | 156 Node* control) final; |
| 156 | 157 |
| 157 // Replace all uses of {node} with {replacement} if the id of {replacement} is | 158 // Replace all uses of {node} with {replacement} if the id of {replacement} is |
| 158 // less than or equal to {max_id}. Otherwise, replace all uses of {node} whose | 159 // less than or equal to {max_id}. Otherwise, replace all uses of {node} whose |
| 159 // id is less than or equal to {max_id} with the {replacement}. | 160 // id is less than or equal to {max_id} with the {replacement}. |
| 160 void Replace(Node* node, Node* replacement, NodeId max_id); | 161 void Replace(Node* node, Node* replacement, NodeId max_id); |
| 161 | 162 |
| 162 // Node stack operations. | 163 // Node stack operations. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 175 ZoneStack<NodeState> stack_; | 176 ZoneStack<NodeState> stack_; |
| 176 | 177 |
| 177 DISALLOW_COPY_AND_ASSIGN(GraphReducer); | 178 DISALLOW_COPY_AND_ASSIGN(GraphReducer); |
| 178 }; | 179 }; |
| 179 | 180 |
| 180 } // namespace compiler | 181 } // namespace compiler |
| 181 } // namespace internal | 182 } // namespace internal |
| 182 } // namespace v8 | 183 } // namespace v8 |
| 183 | 184 |
| 184 #endif // V8_COMPILER_GRAPH_REDUCER_H_ | 185 #endif // V8_COMPILER_GRAPH_REDUCER_H_ |
| OLD | NEW |