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_PROPERTIES_INL_H_ | 5 #ifndef V8_COMPILER_NODE_PROPERTIES_INL_H_ |
6 #define V8_COMPILER_NODE_PROPERTIES_INL_H_ | 6 #define V8_COMPILER_NODE_PROPERTIES_INL_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 inline int NodeProperties::GetFrameStateIndex(Node* node) { | 97 inline int NodeProperties::GetFrameStateIndex(Node* node) { |
98 DCHECK(OperatorProperties::HasFrameStateInput(node->op())); | 98 DCHECK(OperatorProperties::HasFrameStateInput(node->op())); |
99 return FirstFrameStateIndex(node); | 99 return FirstFrameStateIndex(node); |
100 } | 100 } |
101 | 101 |
102 // ----------------------------------------------------------------------------- | 102 // ----------------------------------------------------------------------------- |
103 // Edge kinds. | 103 // Edge kinds. |
104 | 104 |
105 inline bool NodeProperties::IsInputRange(Node::Edge edge, int first, int num) { | 105 inline bool NodeProperties::IsInputRange(Edge edge, int first, int num) { |
106 // TODO(titzer): edge.index() is linear time; | 106 // TODO(titzer): edge.index() is linear time; |
107 // edges maybe need to be marked as value/effect/control. | 107 // edges maybe need to be marked as value/effect/control. |
108 if (num == 0) return false; | 108 if (num == 0) return false; |
109 int index = edge.index(); | 109 int index = edge.index(); |
110 return first <= index && index < first + num; | 110 return first <= index && index < first + num; |
111 } | 111 } |
112 | 112 |
113 inline bool NodeProperties::IsValueEdge(Node::Edge edge) { | 113 inline bool NodeProperties::IsValueEdge(Edge edge) { |
114 Node* node = edge.from(); | 114 Node* node = edge.from(); |
115 return IsInputRange(edge, FirstValueIndex(node), | 115 return IsInputRange(edge, FirstValueIndex(node), |
116 node->op()->ValueInputCount()); | 116 node->op()->ValueInputCount()); |
117 } | 117 } |
118 | 118 |
119 inline bool NodeProperties::IsContextEdge(Node::Edge edge) { | 119 inline bool NodeProperties::IsContextEdge(Edge edge) { |
120 Node* node = edge.from(); | 120 Node* node = edge.from(); |
121 return IsInputRange(edge, FirstContextIndex(node), | 121 return IsInputRange(edge, FirstContextIndex(node), |
122 OperatorProperties::GetContextInputCount(node->op())); | 122 OperatorProperties::GetContextInputCount(node->op())); |
123 } | 123 } |
124 | 124 |
125 inline bool NodeProperties::IsEffectEdge(Node::Edge edge) { | 125 inline bool NodeProperties::IsEffectEdge(Edge edge) { |
126 Node* node = edge.from(); | 126 Node* node = edge.from(); |
127 return IsInputRange(edge, FirstEffectIndex(node), | 127 return IsInputRange(edge, FirstEffectIndex(node), |
128 node->op()->EffectInputCount()); | 128 node->op()->EffectInputCount()); |
129 } | 129 } |
130 | 130 |
131 inline bool NodeProperties::IsControlEdge(Node::Edge edge) { | 131 inline bool NodeProperties::IsControlEdge(Edge edge) { |
132 Node* node = edge.from(); | 132 Node* node = edge.from(); |
133 return IsInputRange(edge, FirstControlIndex(node), | 133 return IsInputRange(edge, FirstControlIndex(node), |
134 node->op()->ControlInputCount()); | 134 node->op()->ControlInputCount()); |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 // ----------------------------------------------------------------------------- | 138 // ----------------------------------------------------------------------------- |
139 // Miscellaneous predicates. | 139 // Miscellaneous predicates. |
140 | 140 |
141 inline bool NodeProperties::IsControl(Node* node) { | 141 inline bool NodeProperties::IsControl(Node* node) { |
(...skipping 28 matching lines...) Expand all Loading... |
170 // Replace value uses of {node} with {value} and effect uses of {node} with | 170 // Replace value uses of {node} with {value} and effect uses of {node} with |
171 // {effect}. If {effect == NULL}, then use the effect input to {node}. | 171 // {effect}. If {effect == NULL}, then use the effect input to {node}. |
172 inline void NodeProperties::ReplaceWithValue(Node* node, Node* value, | 172 inline void NodeProperties::ReplaceWithValue(Node* node, Node* value, |
173 Node* effect) { | 173 Node* effect) { |
174 DCHECK(node->op()->ControlOutputCount() == 0); | 174 DCHECK(node->op()->ControlOutputCount() == 0); |
175 if (effect == NULL && node->op()->EffectInputCount() > 0) { | 175 if (effect == NULL && node->op()->EffectInputCount() > 0) { |
176 effect = NodeProperties::GetEffectInput(node); | 176 effect = NodeProperties::GetEffectInput(node); |
177 } | 177 } |
178 | 178 |
179 // Requires distinguishing between value and effect edges. | 179 // Requires distinguishing between value and effect edges. |
180 UseIter iter = node->uses().begin(); | 180 for (auto edge : node->use_edges()) { |
181 while (iter != node->uses().end()) { | 181 if (NodeProperties::IsEffectEdge(edge)) { |
182 if (NodeProperties::IsEffectEdge(iter.edge())) { | |
183 DCHECK_NE(NULL, effect); | 182 DCHECK_NE(NULL, effect); |
184 iter = iter.UpdateToAndIncrement(effect); | 183 edge.UpdateTo(effect); |
185 } else { | 184 } else { |
186 iter = iter.UpdateToAndIncrement(value); | 185 edge.UpdateTo(value); |
187 } | 186 } |
188 } | 187 } |
189 } | 188 } |
190 | 189 |
191 | 190 |
192 // ----------------------------------------------------------------------------- | 191 // ----------------------------------------------------------------------------- |
193 // Type Bounds. | 192 // Type Bounds. |
194 | 193 |
195 inline bool NodeProperties::IsTyped(Node* node) { | 194 inline bool NodeProperties::IsTyped(Node* node) { |
196 Bounds bounds = node->bounds(); | 195 Bounds bounds = node->bounds(); |
(...skipping 18 matching lines...) Expand all Loading... |
215 } | 214 } |
216 return true; | 215 return true; |
217 } | 216 } |
218 | 217 |
219 | 218 |
220 } | 219 } |
221 } | 220 } |
222 } // namespace v8::internal::compiler | 221 } // namespace v8::internal::compiler |
223 | 222 |
224 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_ | 223 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_ |
OLD | NEW |