| 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_GENERIC_NODE_H_ | 5 #ifndef V8_COMPILER_GENERIC_NODE_H_ |
| 6 #define V8_COMPILER_GENERIC_NODE_H_ | 6 #define V8_COMPILER_GENERIC_NODE_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/zone-containers.h" | 10 #include "src/zone-containers.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 namespace compiler { | 14 namespace compiler { |
| 15 | 15 |
| 16 class GenericGraphBase; | 16 class Graph; |
| 17 | 17 |
| 18 typedef int NodeId; | 18 typedef int NodeId; |
| 19 | 19 |
| 20 // A GenericNode<> is the basic primitive of graphs. GenericNode's are | 20 // A GenericNode<> is the basic primitive of graphs. GenericNode's are |
| 21 // chained together by input/use chains but by default otherwise contain only an | 21 // chained together by input/use chains but by default otherwise contain only an |
| 22 // identifying number which specific applications of graphs and nodes can use | 22 // identifying number which specific applications of graphs and nodes can use |
| 23 // to index auxiliary out-of-line data, especially transient data. | 23 // to index auxiliary out-of-line data, especially transient data. |
| 24 // Specializations of the templatized GenericNode<> class must provide a base | 24 // Specializations of the templatized GenericNode<> class must provide a base |
| 25 // class B that contains all of the members to be made available in each | 25 // class B that contains all of the members to be made available in each |
| 26 // specialized Node instance. GenericNode uses a mixin template pattern to | 26 // specialized Node instance. GenericNode uses a mixin template pattern to |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 private: | 85 private: |
| 86 GenericNode* node_; | 86 GenericNode* node_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 Uses uses() { return Uses(this); } | 89 Uses uses() { return Uses(this); } |
| 90 | 90 |
| 91 class Edge; | 91 class Edge; |
| 92 | 92 |
| 93 bool OwnedBy(GenericNode* owner) const; | 93 bool OwnedBy(GenericNode* owner) const; |
| 94 | 94 |
| 95 static S* New(GenericGraphBase* graph, int input_count, S** inputs, | 95 static S* New(Graph* graph, int input_count, S** inputs, |
| 96 bool has_extensible_inputs); | 96 bool has_extensible_inputs); |
| 97 | 97 |
| 98 protected: | 98 protected: |
| 99 friend class GenericGraphBase; | 99 friend class Graph; |
| 100 | 100 |
| 101 class Use : public ZoneObject { | 101 class Use : public ZoneObject { |
| 102 public: | 102 public: |
| 103 GenericNode* from; | 103 GenericNode* from; |
| 104 Use* next; | 104 Use* next; |
| 105 Use* prev; | 105 Use* prev; |
| 106 int input_index; | 106 int input_index; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 class Input { | 109 class Input { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 122 } else { | 122 } else { |
| 123 return inputs_.static_ + index; | 123 return inputs_.static_ + index; |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 inline void AppendUse(Use* use); | 127 inline void AppendUse(Use* use); |
| 128 inline void RemoveUse(Use* use); | 128 inline void RemoveUse(Use* use); |
| 129 | 129 |
| 130 void* operator new(size_t, void* location) { return location; } | 130 void* operator new(size_t, void* location) { return location; } |
| 131 | 131 |
| 132 GenericNode(GenericGraphBase* graph, int input_count, | 132 GenericNode(Graph* graph, int input_count, int reserved_input_count); |
| 133 int reserved_input_count); | |
| 134 | 133 |
| 135 private: | 134 private: |
| 136 void AssignUniqueID(GenericGraphBase* graph); | 135 void AssignUniqueID(Graph* graph); |
| 137 | 136 |
| 138 typedef ZoneDeque<Input> InputDeque; | 137 typedef ZoneDeque<Input> InputDeque; |
| 139 | 138 |
| 140 static const int kReservedInputCountBits = 2; | 139 static const int kReservedInputCountBits = 2; |
| 141 static const int kMaxReservedInputs = (1 << kReservedInputCountBits) - 1; | 140 static const int kMaxReservedInputs = (1 << kReservedInputCountBits) - 1; |
| 142 static const int kDefaultReservedInputs = kMaxReservedInputs; | 141 static const int kDefaultReservedInputs = kMaxReservedInputs; |
| 143 | 142 |
| 144 NodeId id_; | 143 NodeId id_; |
| 145 int input_count_ : 29; | 144 int input_count_ : 29; |
| 146 unsigned int reserve_input_count_ : kReservedInputCountBits; | 145 unsigned int reserve_input_count_ : kReservedInputCountBits; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 269 } |
| 271 | 270 |
| 272 typename GenericNode<B, S>::Use* current_; | 271 typename GenericNode<B, S>::Use* current_; |
| 273 int index_; | 272 int index_; |
| 274 }; | 273 }; |
| 275 } | 274 } |
| 276 } | 275 } |
| 277 } // namespace v8::internal::compiler | 276 } // namespace v8::internal::compiler |
| 278 | 277 |
| 279 #endif // V8_COMPILER_GENERIC_NODE_H_ | 278 #endif // V8_COMPILER_GENERIC_NODE_H_ |
| OLD | NEW |