Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: src/compiler/graph.h

Issue 767733002: De-generify the GenericGraph. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased again. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/generic-node-inl.h ('k') | src/compiler/graph.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/generic-algorithm.h" 11 #include "src/compiler/generic-algorithm.h"
12 #include "src/compiler/node.h" 12 #include "src/compiler/node.h"
13 #include "src/compiler/node-aux-data.h" 13 #include "src/compiler/node-aux-data.h"
14 #include "src/compiler/source-position.h" 14 #include "src/compiler/source-position.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 namespace compiler { 18 namespace compiler {
19 19
20 class GraphDecorator; 20 class GraphDecorator;
21 21
22 class Graph : public GenericGraph<Node> { 22 class Graph : public ZoneObject {
23 public: 23 public:
24 explicit Graph(Zone* zone); 24 explicit Graph(Zone* zone);
25 25
26 // Base implementation used by all factory methods. 26 // Base implementation used by all factory methods.
27 Node* NewNode(const Operator* op, int input_count, Node** inputs, 27 Node* NewNode(const Operator* op, int input_count, Node** inputs,
28 bool incomplete = false); 28 bool incomplete = false);
29 29
30 // Factories for nodes with static input counts. 30 // Factories for nodes with static input counts.
31 Node* NewNode(const Operator* op) { 31 Node* NewNode(const Operator* op) {
32 return NewNode(op, 0, static_cast<Node**>(NULL)); 32 return NewNode(op, 0, static_cast<Node**>(NULL));
(...skipping 23 matching lines...) Expand all
56 } 56 }
57 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, 57 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
58 Node* n5, Node* n6, Node* n7) { 58 Node* n5, Node* n6, Node* n7) {
59 Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7}; 59 Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7};
60 return NewNode(op, arraysize(nodes), nodes); 60 return NewNode(op, arraysize(nodes), nodes);
61 } 61 }
62 62
63 template <class Visitor> 63 template <class Visitor>
64 void VisitNodeInputsFromEnd(Visitor* visitor); 64 void VisitNodeInputsFromEnd(Visitor* visitor);
65 65
66 Zone* zone() const { return zone_; }
67 Node* start() const { return start_; }
68 Node* end() const { return end_; }
69
70 void SetStart(Node* start) { start_ = start; }
71 void SetEnd(Node* end) { end_ = end; }
72
73 NodeId NextNodeID() { return next_node_id_++; }
74 NodeId NodeCount() const { return next_node_id_; }
75
66 void Decorate(Node* node); 76 void Decorate(Node* node);
67 77
68 void AddDecorator(GraphDecorator* decorator) { 78 void AddDecorator(GraphDecorator* decorator) {
69 decorators_.push_back(decorator); 79 decorators_.push_back(decorator);
70 } 80 }
71 81
72 void RemoveDecorator(GraphDecorator* decorator) { 82 void RemoveDecorator(GraphDecorator* decorator) {
73 ZoneVector<GraphDecorator*>::iterator it = 83 ZoneVector<GraphDecorator*>::iterator it =
74 std::find(decorators_.begin(), decorators_.end(), decorator); 84 std::find(decorators_.begin(), decorators_.end(), decorator);
75 DCHECK(it != decorators_.end()); 85 DCHECK(it != decorators_.end());
76 decorators_.erase(it, it + 1); 86 decorators_.erase(it, it + 1);
77 } 87 }
78 88
79 private: 89 private:
80 template <typename State> 90 template <typename State>
81 friend class NodeMarker; 91 friend class NodeMarker;
82 92
93 Zone* zone_;
94 Node* start_;
95 Node* end_;
83 Mark mark_max_; 96 Mark mark_max_;
97 NodeId next_node_id_;
84 ZoneVector<GraphDecorator*> decorators_; 98 ZoneVector<GraphDecorator*> decorators_;
99
100 DISALLOW_COPY_AND_ASSIGN(Graph);
85 }; 101 };
86 102
87 103
88 // A NodeMarker uses monotonically increasing marks to assign local "states" 104 // A NodeMarker uses monotonically increasing marks to assign local "states"
89 // to nodes. Only one NodeMarker per graph is valid at a given time. 105 // to nodes. Only one NodeMarker per graph is valid at a given time.
90 template <typename State> 106 template <typename State>
91 class NodeMarker BASE_EMBEDDED { 107 class NodeMarker BASE_EMBEDDED {
92 public: 108 public:
93 NodeMarker(Graph* graph, uint32_t num_states) 109 NodeMarker(Graph* graph, uint32_t num_states)
94 : mark_min_(graph->mark_max_), mark_max_(graph->mark_max_ += num_states) { 110 : mark_min_(graph->mark_max_), mark_max_(graph->mark_max_ += num_states) {
(...skipping 30 matching lines...) Expand all
125 public: 141 public:
126 virtual ~GraphDecorator() {} 142 virtual ~GraphDecorator() {}
127 virtual void Decorate(Node* node) = 0; 143 virtual void Decorate(Node* node) = 0;
128 }; 144 };
129 145
130 } // namespace compiler 146 } // namespace compiler
131 } // namespace internal 147 } // namespace internal
132 } // namespace v8 148 } // namespace v8
133 149
134 #endif // V8_COMPILER_GRAPH_H_ 150 #endif // V8_COMPILER_GRAPH_H_
OLDNEW
« no previous file with comments | « src/compiler/generic-node-inl.h ('k') | src/compiler/graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698