OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_H_ | 5 #ifndef V8_COMPILER_GRAPH_H_ |
6 #define V8_COMPILER_GRAPH_H_ | 6 #define V8_COMPILER_GRAPH_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "src/compiler/node.h" | 11 #include "src/compiler/node.h" |
12 #include "src/compiler/node-aux-data.h" | 12 #include "src/compiler/node-aux-data.h" |
13 #include "src/compiler/source-position.h" | 13 #include "src/compiler/source-position.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 namespace compiler { | 17 namespace compiler { |
18 | 18 |
| 19 // Forward declarations. |
19 class GraphDecorator; | 20 class GraphDecorator; |
20 | 21 |
| 22 |
21 class Graph : public ZoneObject { | 23 class Graph : public ZoneObject { |
22 public: | 24 public: |
23 explicit Graph(Zone* zone); | 25 explicit Graph(Zone* zone); |
24 | 26 |
25 // Base implementation used by all factory methods. | 27 // Base implementation used by all factory methods. |
26 Node* NewNode(const Operator* op, int input_count, Node** inputs, | 28 Node* NewNode(const Operator* op, int input_count, Node** inputs, |
27 bool incomplete = false); | 29 bool incomplete = false); |
28 | 30 |
29 // Factories for nodes with static input counts. | 31 // Factories for nodes with static input counts. |
30 Node* NewNode(const Operator* op) { | 32 Node* NewNode(const Operator* op) { |
31 return NewNode(op, 0, static_cast<Node**>(NULL)); | 33 return NewNode(op, 0, static_cast<Node**>(nullptr)); |
32 } | 34 } |
33 Node* NewNode(const Operator* op, Node* n1) { return NewNode(op, 1, &n1); } | 35 Node* NewNode(const Operator* op, Node* n1) { return NewNode(op, 1, &n1); } |
34 Node* NewNode(const Operator* op, Node* n1, Node* n2) { | 36 Node* NewNode(const Operator* op, Node* n1, Node* n2) { |
35 Node* nodes[] = {n1, n2}; | 37 Node* nodes[] = {n1, n2}; |
36 return NewNode(op, arraysize(nodes), nodes); | 38 return NewNode(op, arraysize(nodes), nodes); |
37 } | 39 } |
38 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) { | 40 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) { |
39 Node* nodes[] = {n1, n2, n3}; | 41 Node* nodes[] = {n1, n2, n3}; |
40 return NewNode(op, arraysize(nodes), nodes); | 42 return NewNode(op, arraysize(nodes), nodes); |
41 } | 43 } |
(...skipping 11 matching lines...) Expand all Loading... |
53 Node* nodes[] = {n1, n2, n3, n4, n5, n6}; | 55 Node* nodes[] = {n1, n2, n3, n4, n5, n6}; |
54 return NewNode(op, arraysize(nodes), nodes); | 56 return NewNode(op, arraysize(nodes), nodes); |
55 } | 57 } |
56 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | 58 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, |
57 Node* n5, Node* n6, Node* n7) { | 59 Node* n5, Node* n6, Node* n7) { |
58 Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7}; | 60 Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7}; |
59 return NewNode(op, arraysize(nodes), nodes); | 61 return NewNode(op, arraysize(nodes), nodes); |
60 } | 62 } |
61 | 63 |
62 template <class Visitor> | 64 template <class Visitor> |
63 void VisitNodeInputsFromEnd(Visitor* visitor); | 65 inline void VisitNodeInputsFromEnd(Visitor* visitor); |
64 | 66 |
65 Zone* zone() const { return zone_; } | 67 Zone* zone() const { return zone_; } |
66 Node* start() const { return start_; } | 68 Node* start() const { return start_; } |
67 Node* end() const { return end_; } | 69 Node* end() const { return end_; } |
68 | 70 |
69 void SetStart(Node* start) { start_ = start; } | 71 void SetStart(Node* start) { start_ = start; } |
70 void SetEnd(Node* end) { end_ = end; } | 72 void SetEnd(Node* end) { end_ = end; } |
71 | 73 |
72 NodeId NextNodeID() { return next_node_id_++; } | 74 NodeId NextNodeID() { return next_node_id_++; } |
73 NodeId NodeCount() const { return next_node_id_; } | 75 NodeId NodeCount() const { return next_node_id_; } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 public: | 142 public: |
141 virtual ~GraphDecorator() {} | 143 virtual ~GraphDecorator() {} |
142 virtual void Decorate(Node* node) = 0; | 144 virtual void Decorate(Node* node) = 0; |
143 }; | 145 }; |
144 | 146 |
145 } // namespace compiler | 147 } // namespace compiler |
146 } // namespace internal | 148 } // namespace internal |
147 } // namespace v8 | 149 } // namespace v8 |
148 | 150 |
149 #endif // V8_COMPILER_GRAPH_H_ | 151 #endif // V8_COMPILER_GRAPH_H_ |
OLD | NEW |