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/zone-containers.h" | 8 #include "src/zone-containers.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 void AddReducer(Reducer* reducer); | 62 void AddReducer(Reducer* reducer); |
63 | 63 |
64 // Reduce a single node. | 64 // Reduce a single node. |
65 void ReduceNode(Node* const); | 65 void ReduceNode(Node* const); |
66 // Reduce the whole graph. | 66 // Reduce the whole graph. |
67 void ReduceGraph(); | 67 void ReduceGraph(); |
68 | 68 |
69 private: | 69 private: |
70 enum class State : uint8_t; | 70 enum class State : uint8_t; |
| 71 struct NodeState { |
| 72 Node* node; |
| 73 int input_index; |
| 74 }; |
71 | 75 |
72 // Reduce a single node. | 76 // Reduce a single node. |
73 Reduction Reduce(Node* const); | 77 Reduction Reduce(Node* const); |
74 // Reduce the node on top of the stack. | 78 // Reduce the node on top of the stack. |
75 void ReduceTop(); | 79 void ReduceTop(); |
76 | 80 |
77 // Node stack operations. | 81 // Node stack operations. |
78 void Pop(); | 82 void Pop(); |
79 void Push(Node* const); | 83 void Push(Node* const); |
80 Node* Top() const; | |
81 | 84 |
82 // Revisit queue operations. | 85 // Revisit queue operations. |
83 bool Recurse(Node* const); | 86 bool Recurse(Node* const); |
84 void Revisit(Node* const); | 87 void Revisit(Node* const); |
85 | 88 |
86 Graph* graph_; | 89 Graph* graph_; |
87 ZoneVector<Reducer*> reducers_; | 90 ZoneVector<Reducer*> reducers_; |
88 ZoneStack<Node*> revisit_; | 91 ZoneStack<Node*> revisit_; |
89 ZoneStack<Node*> stack_; | 92 ZoneStack<NodeState> stack_; |
90 ZoneDeque<State> state_; | 93 ZoneDeque<State> state_; |
91 | 94 |
92 DISALLOW_COPY_AND_ASSIGN(GraphReducer); | 95 DISALLOW_COPY_AND_ASSIGN(GraphReducer); |
93 }; | 96 }; |
94 | 97 |
95 } // namespace compiler | 98 } // namespace compiler |
96 } // namespace internal | 99 } // namespace internal |
97 } // namespace v8 | 100 } // namespace v8 |
98 | 101 |
99 #endif // V8_COMPILER_GRAPH_REDUCER_H_ | 102 #endif // V8_COMPILER_GRAPH_REDUCER_H_ |
OLD | NEW |