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

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

Issue 539933002: [turbofan] Make sure Operator is really immutable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/node-matchers.h » ('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> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "src/compiler/generic-algorithm.h" 12 #include "src/compiler/generic-algorithm.h"
13 #include "src/compiler/generic-node.h" 13 #include "src/compiler/generic-node.h"
14 #include "src/compiler/opcodes.h" 14 #include "src/compiler/opcodes.h"
15 #include "src/compiler/operator.h" 15 #include "src/compiler/operator.h"
16 #include "src/types.h" 16 #include "src/types.h"
17 #include "src/zone.h" 17 #include "src/zone.h"
18 #include "src/zone-allocator.h" 18 #include "src/zone-allocator.h"
19 19
20 namespace v8 { 20 namespace v8 {
21 namespace internal { 21 namespace internal {
22 namespace compiler { 22 namespace compiler {
23 23
24 class NodeData { 24 class NodeData {
25 public: 25 public:
26 Operator* op() const { return op_; } 26 const Operator* op() const { return op_; }
27 void set_op(Operator* op) { op_ = op; } 27 void set_op(const Operator* op) { op_ = op; }
28 28
29 IrOpcode::Value opcode() const { 29 IrOpcode::Value opcode() const {
30 DCHECK(op_->opcode() <= IrOpcode::kLast); 30 DCHECK(op_->opcode() <= IrOpcode::kLast);
31 return static_cast<IrOpcode::Value>(op_->opcode()); 31 return static_cast<IrOpcode::Value>(op_->opcode());
32 } 32 }
33 33
34 Bounds bounds() { return bounds_; } 34 Bounds bounds() { return bounds_; }
35 35
36 protected: 36 protected:
37 Operator* op_; 37 const Operator* op_;
38 Bounds bounds_; 38 Bounds bounds_;
39 explicit NodeData(Zone* zone) : bounds_(Bounds(Type::None(zone))) {} 39 explicit NodeData(Zone* zone) : bounds_(Bounds(Type::None(zone))) {}
40 40
41 friend class NodeProperties; 41 friend class NodeProperties;
42 void set_bounds(Bounds b) { bounds_ = b; } 42 void set_bounds(Bounds b) { bounds_ = b; }
43 }; 43 };
44 44
45 // A Node is the basic primitive of an IR graph. In addition to the members 45 // A Node is the basic primitive of an IR graph. In addition to the members
46 // inherited from Vector, Nodes only contain a mutable Operator that may change 46 // inherited from Vector, Nodes only contain a mutable Operator that may change
47 // during compilation, e.g. during lowering passes. Other information that 47 // during compilation, e.g. during lowering passes. Other information that
48 // needs to be associated with Nodes during compilation must be stored 48 // needs to be associated with Nodes during compilation must be stored
49 // out-of-line indexed by the Node's id. 49 // out-of-line indexed by the Node's id.
50 class Node : public GenericNode<NodeData, Node> { 50 class Node FINAL : public GenericNode<NodeData, Node> {
51 public: 51 public:
52 Node(GenericGraphBase* graph, int input_count) 52 Node(GenericGraphBase* graph, int input_count)
53 : GenericNode<NodeData, Node>(graph, input_count) {} 53 : GenericNode<NodeData, Node>(graph, input_count) {}
54 54
55 void Initialize(Operator* op) { set_op(op); } 55 void Initialize(const Operator* op) { set_op(op); }
56 void Kill(); 56 void Kill();
57 57
58 void CollectProjections(ZoneVector<Node*>* projections); 58 void CollectProjections(ZoneVector<Node*>* projections);
59 Node* FindProjection(int32_t projection_index); 59 Node* FindProjection(int32_t projection_index);
60 }; 60 };
61 61
62 OStream& operator<<(OStream& os, const Node& n); 62 OStream& operator<<(OStream& os, const Node& n);
63 63
64 typedef GenericGraphVisit::NullNodeVisitor<NodeData, Node> NullNodeVisitor; 64 typedef GenericGraphVisit::NullNodeVisitor<NodeData, Node> NullNodeVisitor;
65 65
66 typedef std::set<Node*, std::less<Node*>, zone_allocator<Node*> > NodeSet; 66 typedef std::set<Node*, std::less<Node*>, zone_allocator<Node*> > NodeSet;
67 typedef NodeSet::iterator NodeSetIter; 67 typedef NodeSet::iterator NodeSetIter;
68 typedef NodeSet::reverse_iterator NodeSetRIter; 68 typedef NodeSet::reverse_iterator NodeSetRIter;
69 69
70 typedef ZoneVector<Node*> NodeVector; 70 typedef ZoneVector<Node*> NodeVector;
71 typedef NodeVector::iterator NodeVectorIter; 71 typedef NodeVector::iterator NodeVectorIter;
72 typedef NodeVector::reverse_iterator NodeVectorRIter; 72 typedef NodeVector::reverse_iterator NodeVectorRIter;
73 73
74 typedef ZoneVector<NodeVector> NodeVectorVector; 74 typedef ZoneVector<NodeVector> NodeVectorVector;
75 typedef NodeVectorVector::iterator NodeVectorVectorIter; 75 typedef NodeVectorVector::iterator NodeVectorVectorIter;
76 typedef NodeVectorVector::reverse_iterator NodeVectorVectorRIter; 76 typedef NodeVectorVector::reverse_iterator NodeVectorVectorRIter;
77 77
78 typedef Node::Uses::iterator UseIter; 78 typedef Node::Uses::iterator UseIter;
79 typedef Node::Inputs::iterator InputIter; 79 typedef Node::Inputs::iterator InputIter;
80 80
81 // Helper to extract parameters from Operator1<*> operator. 81 // Helper to extract parameters from Operator1<*> nodes.
82 template <typename T> 82 template <typename T>
83 static inline T OpParameter(Operator* op) { 83 static inline T OpParameter(const Node* node) {
84 return reinterpret_cast<Operator1<T>*>(op)->parameter(); 84 return OpParameter<T>(node->op());
85 } 85 }
86 86
87 87 } // namespace compiler
88 // Helper to extract parameters from Operator1<*> nodes. 88 } // namespace internal
89 template <typename T> 89 } // namespace v8
90 static inline T OpParameter(Node* node) {
91 return OpParameter<T>(node->op());
92 }
93 }
94 }
95 } // namespace v8::internal::compiler
96 90
97 #endif // V8_COMPILER_NODE_H_ 91 #endif // V8_COMPILER_NODE_H_
OLDNEW
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/node-matchers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698