| 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/graph.h" |
| 8 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 9 | 10 |
| 10 namespace v8 { | 11 namespace v8 { |
| 11 namespace internal { | 12 namespace internal { |
| 12 namespace compiler { | 13 namespace compiler { |
| 13 | 14 |
| 14 // Forward declarations. | |
| 15 class Graph; | |
| 16 class Node; | |
| 17 | |
| 18 | |
| 19 // Represents the result of trying to reduce a node in the graph. | 15 // Represents the result of trying to reduce a node in the graph. |
| 20 class Reduction FINAL { | 16 class Reduction FINAL { |
| 21 public: | 17 public: |
| 22 explicit Reduction(Node* replacement = NULL) : replacement_(replacement) {} | 18 explicit Reduction(Node* replacement = NULL) : replacement_(replacement) {} |
| 23 | 19 |
| 24 Node* replacement() const { return replacement_; } | 20 Node* replacement() const { return replacement_; } |
| 25 bool Changed() const { return replacement() != NULL; } | 21 bool Changed() const { return replacement() != NULL; } |
| 26 | 22 |
| 27 private: | 23 private: |
| 28 Node* replacement_; | 24 Node* replacement_; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 int input_index; | 69 int input_index; |
| 74 }; | 70 }; |
| 75 | 71 |
| 76 // Reduce a single node. | 72 // Reduce a single node. |
| 77 Reduction Reduce(Node* const); | 73 Reduction Reduce(Node* const); |
| 78 // Reduce the node on top of the stack. | 74 // Reduce the node on top of the stack. |
| 79 void ReduceTop(); | 75 void ReduceTop(); |
| 80 | 76 |
| 81 // Node stack operations. | 77 // Node stack operations. |
| 82 void Pop(); | 78 void Pop(); |
| 83 void Push(Node* const); | 79 void Push(Node* node); |
| 84 | 80 |
| 85 // Revisit queue operations. | 81 // Revisit queue operations. |
| 86 bool Recurse(Node* const); | 82 bool Recurse(Node* node); |
| 87 void Revisit(Node* const); | 83 void Revisit(Node* node); |
| 88 | 84 |
| 89 Graph* graph_; | 85 Graph* graph_; |
| 86 NodeMarker<State> state_; |
| 90 ZoneVector<Reducer*> reducers_; | 87 ZoneVector<Reducer*> reducers_; |
| 91 ZoneStack<Node*> revisit_; | 88 ZoneStack<Node*> revisit_; |
| 92 ZoneStack<NodeState> stack_; | 89 ZoneStack<NodeState> stack_; |
| 93 ZoneDeque<State> state_; | |
| 94 | 90 |
| 95 DISALLOW_COPY_AND_ASSIGN(GraphReducer); | 91 DISALLOW_COPY_AND_ASSIGN(GraphReducer); |
| 96 }; | 92 }; |
| 97 | 93 |
| 98 } // namespace compiler | 94 } // namespace compiler |
| 99 } // namespace internal | 95 } // namespace internal |
| 100 } // namespace v8 | 96 } // namespace v8 |
| 101 | 97 |
| 102 #endif // V8_COMPILER_GRAPH_REDUCER_H_ | 98 #endif // V8_COMPILER_GRAPH_REDUCER_H_ |
| OLD | NEW |