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 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 namespace compiler { | 13 namespace compiler { |
14 | 14 |
15 // Forward declarations. | 15 // Forward declarations. |
16 class Graph; | 16 class Graph; |
17 class Node; | 17 class Node; |
18 | 18 |
19 | 19 |
20 // Represents the result of trying to reduce a node in the graph. | 20 // Represents the result of trying to reduce a node in the graph. |
21 class Reduction FINAL { | 21 class Reduction final { |
22 public: | 22 public: |
23 explicit Reduction(Node* replacement = NULL) : replacement_(replacement) {} | 23 explicit Reduction(Node* replacement = NULL) : replacement_(replacement) {} |
24 | 24 |
25 Node* replacement() const { return replacement_; } | 25 Node* replacement() const { return replacement_; } |
26 bool Changed() const { return replacement() != NULL; } | 26 bool Changed() const { return replacement() != NULL; } |
27 | 27 |
28 private: | 28 private: |
29 Node* replacement_; | 29 Node* replacement_; |
30 }; | 30 }; |
31 | 31 |
(...skipping 15 matching lines...) Expand all Loading... |
47 static Reduction NoChange() { return Reduction(); } | 47 static Reduction NoChange() { return Reduction(); } |
48 static Reduction Replace(Node* node) { return Reduction(node); } | 48 static Reduction Replace(Node* node) { return Reduction(node); } |
49 static Reduction Changed(Node* node) { return Reduction(node); } | 49 static Reduction Changed(Node* node) { return Reduction(node); } |
50 | 50 |
51 private: | 51 private: |
52 DISALLOW_COPY_AND_ASSIGN(Reducer); | 52 DISALLOW_COPY_AND_ASSIGN(Reducer); |
53 }; | 53 }; |
54 | 54 |
55 | 55 |
56 // Performs an iterative reduction of a node graph. | 56 // Performs an iterative reduction of a node graph. |
57 class GraphReducer FINAL { | 57 class GraphReducer final { |
58 public: | 58 public: |
59 GraphReducer(Graph* graph, Zone* zone); | 59 GraphReducer(Graph* graph, Zone* zone); |
60 | 60 |
61 Graph* graph() const { return graph_; } | 61 Graph* graph() const { return graph_; } |
62 | 62 |
63 void AddReducer(Reducer* reducer); | 63 void AddReducer(Reducer* reducer); |
64 | 64 |
65 // Reduce a single node. | 65 // Reduce a single node. |
66 void ReduceNode(Node* const); | 66 void ReduceNode(Node* const); |
67 // Reduce the whole graph. | 67 // Reduce the whole graph. |
(...skipping 26 matching lines...) Expand all Loading... |
94 ZoneStack<NodeState> stack_; | 94 ZoneStack<NodeState> stack_; |
95 | 95 |
96 DISALLOW_COPY_AND_ASSIGN(GraphReducer); | 96 DISALLOW_COPY_AND_ASSIGN(GraphReducer); |
97 }; | 97 }; |
98 | 98 |
99 } // namespace compiler | 99 } // namespace compiler |
100 } // namespace internal | 100 } // namespace internal |
101 } // namespace v8 | 101 } // namespace v8 |
102 | 102 |
103 #endif // V8_COMPILER_GRAPH_REDUCER_H_ | 103 #endif // V8_COMPILER_GRAPH_REDUCER_H_ |
OLD | NEW |