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 <deque> | 8 #include <deque> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 public: | 36 public: |
37 typedef B BaseClass; | 37 typedef B BaseClass; |
38 typedef S DerivedClass; | 38 typedef S DerivedClass; |
39 | 39 |
40 inline NodeId id() const { return id_; } | 40 inline NodeId id() const { return id_; } |
41 | 41 |
42 int InputCount() const { return input_count_; } | 42 int InputCount() const { return input_count_; } |
43 S* InputAt(int index) const { | 43 S* InputAt(int index) const { |
44 return static_cast<S*>(GetInputRecordPtr(index)->to); | 44 return static_cast<S*>(GetInputRecordPtr(index)->to); |
45 } | 45 } |
46 void ReplaceInput(int index, GenericNode* new_input); | 46 inline void ReplaceInput(int index, GenericNode* new_input); |
47 void AppendInput(Zone* zone, GenericNode* new_input); | 47 inline void AppendInput(Zone* zone, GenericNode* new_input); |
48 void InsertInput(Zone* zone, int index, GenericNode* new_input); | 48 inline void InsertInput(Zone* zone, int index, GenericNode* new_input); |
49 | 49 |
50 int UseCount() { return use_count_; } | 50 int UseCount() { return use_count_; } |
51 S* UseAt(int index) { | 51 S* UseAt(int index) { |
52 DCHECK(index < use_count_); | 52 DCHECK(index < use_count_); |
53 Use* current = first_use_; | 53 Use* current = first_use_; |
54 while (index-- != 0) { | 54 while (index-- != 0) { |
55 current = current->next; | 55 current = current->next; |
56 } | 56 } |
57 return static_cast<S*>(current->from); | 57 return static_cast<S*>(current->from); |
58 } | 58 } |
59 inline void ReplaceUses(GenericNode* replace_to); | 59 inline void ReplaceUses(GenericNode* replace_to); |
60 template <class UnaryPredicate> | 60 template <class UnaryPredicate> |
61 inline void ReplaceUsesIf(UnaryPredicate pred, GenericNode* replace_to); | 61 inline void ReplaceUsesIf(UnaryPredicate pred, GenericNode* replace_to); |
62 void RemoveAllInputs(); | 62 inline void RemoveAllInputs(); |
63 | 63 |
64 void TrimInputCount(int input_count); | 64 void TrimInputCount(int input_count); |
65 | 65 |
66 class Inputs { | 66 class Inputs { |
67 public: | 67 public: |
68 class iterator; | 68 class iterator; |
69 iterator begin(); | 69 iterator begin(); |
70 iterator end(); | 70 iterator end(); |
71 | 71 |
72 explicit Inputs(GenericNode* node) : node_(node) {} | 72 explicit Inputs(GenericNode* node) : node_(node) {} |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void EnsureAppendableInputs(Zone* zone); | 120 void EnsureAppendableInputs(Zone* zone); |
121 | 121 |
122 Input* GetInputRecordPtr(int index) const { | 122 Input* GetInputRecordPtr(int index) const { |
123 if (has_appendable_inputs_) { | 123 if (has_appendable_inputs_) { |
124 return &((*inputs_.appendable_)[index]); | 124 return &((*inputs_.appendable_)[index]); |
125 } else { | 125 } else { |
126 return inputs_.static_ + index; | 126 return inputs_.static_ + index; |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 void AppendUse(Use* use); | 130 inline void AppendUse(Use* use); |
131 void RemoveUse(Use* use); | 131 inline void RemoveUse(Use* use); |
132 | 132 |
133 void* operator new(size_t, void* location) { return location; } | 133 void* operator new(size_t, void* location) { return location; } |
134 | 134 |
135 GenericNode(GenericGraphBase* graph, int input_count); | 135 GenericNode(GenericGraphBase* graph, int input_count); |
136 | 136 |
137 private: | 137 private: |
138 void AssignUniqueID(GenericGraphBase* graph); | 138 void AssignUniqueID(GenericGraphBase* graph); |
139 | 139 |
140 typedef zone_allocator<Input> ZoneInputAllocator; | 140 typedef zone_allocator<Input> ZoneInputAllocator; |
141 typedef std::deque<Input, ZoneInputAllocator> InputDeque; | 141 typedef std::deque<Input, ZoneInputAllocator> InputDeque; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 | 269 |
270 typename GenericNode<B, S>::Use* current_; | 270 typename GenericNode<B, S>::Use* current_; |
271 int index_; | 271 int index_; |
272 }; | 272 }; |
273 } | 273 } |
274 } | 274 } |
275 } // namespace v8::internal::compiler | 275 } // namespace v8::internal::compiler |
276 | 276 |
277 #endif // V8_COMPILER_GENERIC_NODE_H_ | 277 #endif // V8_COMPILER_GENERIC_NODE_H_ |
OLD | NEW |