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_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 typedef uint32_t TraversalState; |
| 25 |
24 class NodeData { | 26 class NodeData { |
25 public: | 27 public: |
26 const Operator* op() const { return op_; } | 28 const Operator* op() const { return op_; } |
27 void set_op(const Operator* op) { op_ = op; } | 29 void set_op(const Operator* op) { op_ = op; } |
28 | 30 |
29 IrOpcode::Value opcode() const { | 31 IrOpcode::Value opcode() const { |
30 DCHECK(op_->opcode() <= IrOpcode::kLast); | 32 DCHECK(op_->opcode() <= IrOpcode::kLast); |
31 return static_cast<IrOpcode::Value>(op_->opcode()); | 33 return static_cast<IrOpcode::Value>(op_->opcode()); |
32 } | 34 } |
33 | 35 |
| 36 TraversalState traversal_state() { return traversal_state_; } |
| 37 void set_traversal_state(TraversalState s) { traversal_state_ = s; } |
| 38 |
34 protected: | 39 protected: |
35 const Operator* op_; | 40 const Operator* op_; |
36 Bounds bounds_; | 41 Bounds bounds_; |
| 42 TraversalState traversal_state_; |
37 explicit NodeData(Zone* zone) {} | 43 explicit NodeData(Zone* zone) {} |
38 | 44 |
39 friend class NodeProperties; | 45 friend class NodeProperties; |
40 Bounds bounds() { return bounds_; } | 46 Bounds bounds() { return bounds_; } |
41 void set_bounds(Bounds b) { bounds_ = b; } | 47 void set_bounds(Bounds b) { bounds_ = b; } |
42 }; | 48 }; |
43 | 49 |
44 // A Node is the basic primitive of an IR graph. In addition to the members | 50 // A Node is the basic primitive of an IR graph. In addition to the members |
45 // inherited from Vector, Nodes only contain a mutable Operator that may change | 51 // inherited from Vector, Nodes only contain a mutable Operator that may change |
46 // during compilation, e.g. during lowering passes. Other information that | 52 // during compilation, e.g. during lowering passes. Other information that |
47 // needs to be associated with Nodes during compilation must be stored | 53 // needs to be associated with Nodes during compilation must be stored |
48 // out-of-line indexed by the Node's id. | 54 // out-of-line indexed by the Node's id. |
49 class Node FINAL : public GenericNode<NodeData, Node> { | 55 class Node FINAL : public GenericNode<NodeData, Node> { |
50 public: | 56 public: |
51 Node(GenericGraphBase* graph, int input_count, int reserve_input_count) | 57 Node(GenericGraphBase* graph, int input_count, int reserve_input_count) |
52 : GenericNode<NodeData, Node>(graph, input_count, reserve_input_count) {} | 58 : GenericNode<NodeData, Node>(graph, input_count, reserve_input_count) {} |
53 | 59 |
54 void Initialize(const Operator* op) { set_op(op); } | 60 void Initialize(const Operator* op) { |
| 61 set_op(op); |
| 62 set_traversal_state(0); |
| 63 } |
55 | 64 |
56 bool IsDead() const { return InputCount() > 0 && InputAt(0) == NULL; } | 65 bool IsDead() const { return InputCount() > 0 && InputAt(0) == NULL; } |
57 void Kill(); | 66 void Kill(); |
58 | 67 |
59 void CollectProjections(ZoneVector<Node*>* projections); | 68 void CollectProjections(ZoneVector<Node*>* projections); |
60 Node* FindProjection(size_t projection_index); | 69 Node* FindProjection(size_t projection_index); |
61 }; | 70 }; |
62 | 71 |
63 std::ostream& operator<<(std::ostream& os, const Node& n); | 72 std::ostream& operator<<(std::ostream& os, const Node& n); |
64 | 73 |
(...skipping 21 matching lines...) Expand all Loading... |
86 template <typename T> | 95 template <typename T> |
87 static inline const T& OpParameter(const Node* node) { | 96 static inline const T& OpParameter(const Node* node) { |
88 return OpParameter<T>(node->op()); | 97 return OpParameter<T>(node->op()); |
89 } | 98 } |
90 | 99 |
91 } // namespace compiler | 100 } // namespace compiler |
92 } // namespace internal | 101 } // namespace internal |
93 } // namespace v8 | 102 } // namespace v8 |
94 | 103 |
95 #endif // V8_COMPILER_NODE_H_ | 104 #endif // V8_COMPILER_NODE_H_ |
OLD | NEW |