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

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

Issue 838783002: [turbofan] Cleanup Graph and related classes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Parameter pack causes compile errors. Created 5 years, 11 months 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/loop-analysis.cc ('k') | src/compiler/node.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_NODE_H_ 5 #ifndef V8_COMPILER_NODE_H_
6 #define V8_COMPILER_NODE_H_ 6 #define V8_COMPILER_NODE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <set>
10 #include <vector> 9 #include <vector>
11 10
12 #include "src/v8.h"
13
14 #include "src/compiler/opcodes.h" 11 #include "src/compiler/opcodes.h"
15 #include "src/compiler/operator.h" 12 #include "src/compiler/operator.h"
16 #include "src/types.h" 13 #include "src/types-inl.h"
17 #include "src/zone.h" 14 #include "src/zone.h"
18 #include "src/zone-allocator.h" 15 #include "src/zone-allocator.h"
19 #include "src/zone-containers.h" 16 #include "src/zone-containers.h"
20 17
21 namespace v8 { 18 namespace v8 {
22 namespace internal { 19 namespace internal {
23 namespace compiler { 20 namespace compiler {
24 21
25 // Forward declarations. 22 // Forward declarations.
26 class Edge; 23 class Edge;
27 class Graph; 24 class Graph;
28 25
29 26
30 // Marks are used during traversal of the graph to distinguish states of nodes. 27 // Marks are used during traversal of the graph to distinguish states of nodes.
31 // Each node has a mark which is a monotonically increasing integer, and a 28 // Each node has a mark which is a monotonically increasing integer, and a
32 // {NodeMarker} has a range of values that indicate states of a node. 29 // {NodeMarker} has a range of values that indicate states of a node.
33 typedef uint32_t Mark; 30 typedef uint32_t Mark;
34 31
32
35 // NodeIds are identifying numbers for nodes that can be used to index auxiliary 33 // NodeIds are identifying numbers for nodes that can be used to index auxiliary
36 // out-of-line data associated with each node. 34 // out-of-line data associated with each node.
37 typedef int NodeId; 35 typedef int32_t NodeId;
36
38 37
39 // A Node is the basic primitive of graphs. Nodes are chained together by 38 // A Node is the basic primitive of graphs. Nodes are chained together by
40 // input/use chains but by default otherwise contain only an identifying number 39 // input/use chains but by default otherwise contain only an identifying number
41 // which specific applications of graphs and nodes can use to index auxiliary 40 // which specific applications of graphs and nodes can use to index auxiliary
42 // out-of-line data, especially transient data. 41 // out-of-line data, especially transient data.
43 // 42 //
44 // In addition Nodes only contain a mutable Operator that may change during 43 // In addition Nodes only contain a mutable Operator that may change during
45 // compilation, e.g. during lowering passes. Other information that needs to be 44 // compilation, e.g. during lowering passes. Other information that needs to be
46 // associated with Nodes during compilation must be stored out-of-line indexed 45 // associated with Nodes during compilation must be stored out-of-line indexed
47 // by the Node's id. 46 // by the Node's id.
48 class Node FINAL { 47 class Node FINAL {
49 public: 48 public:
50 void Initialize(const Operator* op) {
51 set_op(op);
52 set_mark(0);
53 }
54
55 bool IsDead() const { return InputCount() > 0 && InputAt(0) == NULL; } 49 bool IsDead() const { return InputCount() > 0 && InputAt(0) == NULL; }
56 void Kill(); 50 void Kill();
57 51
58 void CollectProjections(ZoneVector<Node*>* projections); 52 void CollectProjections(ZoneVector<Node*>* projections);
59 Node* FindProjection(size_t projection_index); 53 Node* FindProjection(size_t projection_index);
60 54
61 const Operator* op() const { return op_; } 55 const Operator* op() const { return op_; }
62 void set_op(const Operator* op) { op_ = op; } 56 void set_op(const Operator* op) { op_ = op; }
63 57
64 IrOpcode::Value opcode() const { 58 IrOpcode::Value opcode() const {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 131
138 private: 132 private:
139 Node* node_; 133 Node* node_;
140 }; 134 };
141 135
142 Uses uses() { return Uses(this); } 136 Uses uses() { return Uses(this); }
143 UseEdges use_edges() { return UseEdges(this); } 137 UseEdges use_edges() { return UseEdges(this); }
144 138
145 bool OwnedBy(Node* owner) const; 139 bool OwnedBy(Node* owner) const;
146 140
147 static Node* New(Graph* graph, int input_count, Node** inputs, 141 static Node* New(Zone* zone, NodeId id, const Operator* op, int input_count,
148 bool has_extensible_inputs); 142 Node** inputs, bool has_extensible_inputs);
149 143
150 protected: 144 protected:
151 friend class Graph; 145 friend class Graph;
152 friend class Edge; 146 friend class Edge;
153 147
154 class Use : public ZoneObject { 148 class Use : public ZoneObject {
155 public: 149 public:
156 Node* from; 150 Node* from;
157 Use* next; 151 Use* next;
158 Use* prev; 152 Use* prev;
(...skipping 17 matching lines...) Expand all
176 return &inputs_.static_[index]; 170 return &inputs_.static_[index];
177 } 171 }
178 } 172 }
179 173
180 inline void AppendUse(Use* use); 174 inline void AppendUse(Use* use);
181 inline void RemoveUse(Use* use); 175 inline void RemoveUse(Use* use);
182 176
183 void* operator new(size_t, void* location) { return location; } 177 void* operator new(size_t, void* location) { return location; }
184 178
185 private: 179 private:
186 inline Node(NodeId id, int input_count, int reserve_input_count); 180 inline Node(NodeId id, const Operator* op, int input_count,
181 int reserve_input_count);
187 182
188 typedef ZoneDeque<Input> InputDeque; 183 typedef ZoneDeque<Input> InputDeque;
189 184
185 friend class NodeMarkerBase;
190 friend class NodeProperties; 186 friend class NodeProperties;
191 template <typename State>
192 friend class NodeMarker;
193 187
194 // Only NodeProperties should manipulate the bounds. 188 // Only NodeProperties should manipulate the bounds.
195 Bounds bounds() { return bounds_; } 189 Bounds bounds() { return bounds_; }
196 void set_bounds(Bounds b) { bounds_ = b; } 190 void set_bounds(Bounds b) { bounds_ = b; }
197 191
198 // Only NodeMarkers should manipulate the marks on nodes. 192 // Only NodeMarkers should manipulate the marks on nodes.
199 Mark mark() { return mark_; } 193 Mark mark() { return mark_; }
200 void set_mark(Mark mark) { mark_ = mark; } 194 void set_mark(Mark mark) { mark_ = mark; }
201 195
202 int input_count() const { return InputCountField::decode(bit_field_); } 196 int input_count() const { return InputCountField::decode(bit_field_); }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 Input* CurrentInput() const { 428 Input* CurrentInput() const {
435 return current_->from->GetInputRecordPtr(current_->input_index); 429 return current_->from->GetInputRecordPtr(current_->input_index);
436 } 430 }
437 431
438 Node::Use* current_; 432 Node::Use* current_;
439 }; 433 };
440 434
441 435
442 std::ostream& operator<<(std::ostream& os, const Node& n); 436 std::ostream& operator<<(std::ostream& os, const Node& n);
443 437
444 typedef std::set<Node*, std::less<Node*>, zone_allocator<Node*> > NodeSet;
445 typedef NodeSet::iterator NodeSetIter;
446 typedef NodeSet::reverse_iterator NodeSetRIter;
447
448 typedef ZoneDeque<Node*> NodeDeque; 438 typedef ZoneDeque<Node*> NodeDeque;
449 439
450 typedef ZoneVector<Node*> NodeVector; 440 typedef ZoneVector<Node*> NodeVector;
451 typedef NodeVector::iterator NodeVectorIter; 441 typedef NodeVector::iterator NodeVectorIter;
452 typedef NodeVector::const_iterator NodeVectorConstIter; 442 typedef NodeVector::const_iterator NodeVectorConstIter;
453 typedef NodeVector::reverse_iterator NodeVectorRIter; 443 typedef NodeVector::reverse_iterator NodeVectorRIter;
454 444
455 typedef ZoneVector<NodeVector> NodeVectorVector; 445 typedef ZoneVector<NodeVector> NodeVectorVector;
456 typedef NodeVectorVector::iterator NodeVectorVectorIter; 446 typedef NodeVectorVector::iterator NodeVectorVectorIter;
457 typedef NodeVectorVector::reverse_iterator NodeVectorVectorRIter; 447 typedef NodeVectorVector::reverse_iterator NodeVectorVectorRIter;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 inline bool Node::OwnedBy(Node* owner) const { 642 inline bool Node::OwnedBy(Node* owner) const {
653 return first_use_ != NULL && first_use_->from == owner && 643 return first_use_ != NULL && first_use_->from == owner &&
654 first_use_->next == NULL; 644 first_use_->next == NULL;
655 } 645 }
656 646
657 } // namespace compiler 647 } // namespace compiler
658 } // namespace internal 648 } // namespace internal
659 } // namespace v8 649 } // namespace v8
660 650
661 #endif // V8_COMPILER_NODE_H_ 651 #endif // V8_COMPILER_NODE_H_
OLDNEW
« no previous file with comments | « src/compiler/loop-analysis.cc ('k') | src/compiler/node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698