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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 private: | 50 private: |
51 DISALLOW_COPY_AND_ASSIGN(Reducer); | 51 DISALLOW_COPY_AND_ASSIGN(Reducer); |
52 }; | 52 }; |
53 | 53 |
54 | 54 |
55 // Performs an iterative reduction of a node graph. | 55 // Performs an iterative reduction of a node graph. |
56 class GraphReducer FINAL { | 56 class GraphReducer FINAL { |
57 public: | 57 public: |
58 explicit GraphReducer(Graph* graph); | 58 explicit GraphReducer(Graph* graph); |
| 59 GraphReducer(Graph* graph, Zone* zone); |
59 | 60 |
60 Graph* graph() const { return graph_; } | 61 Graph* graph() const { return graph_; } |
61 | 62 |
62 void AddReducer(Reducer* reducer) { reducers_.push_back(reducer); } | 63 void AddReducer(Reducer* reducer); |
63 | 64 |
64 // Reduce a single node. | 65 // Reduce a single node. |
65 void ReduceNode(Node* node); | 66 void ReduceNode(Node* const); |
66 // Reduce the whole graph. | 67 // Reduce the whole graph. |
67 void ReduceGraph(); | 68 void ReduceGraph(); |
68 | 69 |
69 private: | 70 private: |
| 71 enum class State : uint8_t; |
| 72 |
| 73 // Reduce a single node. |
| 74 Reduction Reduce(Node* const); |
| 75 // Reduce the node on top of the stack. |
| 76 void ReduceTop(); |
| 77 |
| 78 // Node stack operations. |
| 79 void Pop(); |
| 80 void Push(Node* const); |
| 81 Node* Top() const; |
| 82 |
| 83 // Revisit queue operations. |
| 84 bool Recurse(Node* const); |
| 85 void Revisit(Node* const); |
| 86 |
70 Graph* graph_; | 87 Graph* graph_; |
71 ZoneVector<Reducer*> reducers_; | 88 ZoneVector<Reducer*> reducers_; |
| 89 ZoneStack<Node*> revisit_; |
| 90 ZoneStack<Node*> stack_; |
| 91 ZoneDeque<State> state_; |
72 | 92 |
73 DISALLOW_COPY_AND_ASSIGN(GraphReducer); | 93 DISALLOW_COPY_AND_ASSIGN(GraphReducer); |
74 }; | 94 }; |
75 | 95 |
76 } // namespace compiler | 96 } // namespace compiler |
77 } // namespace internal | 97 } // namespace internal |
78 } // namespace v8 | 98 } // namespace v8 |
79 | 99 |
80 #endif // V8_COMPILER_GRAPH_REDUCER_H_ | 100 #endif // V8_COMPILER_GRAPH_REDUCER_H_ |
OLD | NEW |