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

Side by Side Diff: src/compiler/node-properties-inl.h

Issue 765983002: Clean up node iteration (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix windows build Created 6 years 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
« no previous file with comments | « src/compiler/node-properties.h ('k') | src/compiler/scheduler.cc » ('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_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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 95
96 inline int NodeProperties::GetFrameStateIndex(Node* node) { 96 inline int NodeProperties::GetFrameStateIndex(Node* node) {
97 DCHECK(OperatorProperties::HasFrameStateInput(node->op())); 97 DCHECK(OperatorProperties::HasFrameStateInput(node->op()));
98 return FirstFrameStateIndex(node); 98 return FirstFrameStateIndex(node);
99 } 99 }
100 100
101 // ----------------------------------------------------------------------------- 101 // -----------------------------------------------------------------------------
102 // Edge kinds. 102 // Edge kinds.
103 103
104 inline bool NodeProperties::IsInputRange(Node::Edge edge, int first, int num) { 104 inline bool NodeProperties::IsInputRange(Edge edge, int first, int num) {
105 // TODO(titzer): edge.index() is linear time; 105 // TODO(titzer): edge.index() is linear time;
106 // edges maybe need to be marked as value/effect/control. 106 // edges maybe need to be marked as value/effect/control.
107 if (num == 0) return false; 107 if (num == 0) return false;
108 int index = edge.index(); 108 int index = edge.index();
109 return first <= index && index < first + num; 109 return first <= index && index < first + num;
110 } 110 }
111 111
112 inline bool NodeProperties::IsValueEdge(Node::Edge edge) { 112 inline bool NodeProperties::IsValueEdge(Edge edge) {
113 Node* node = edge.from(); 113 Node* node = edge.from();
114 return IsInputRange(edge, FirstValueIndex(node), 114 return IsInputRange(edge, FirstValueIndex(node),
115 node->op()->ValueInputCount()); 115 node->op()->ValueInputCount());
116 } 116 }
117 117
118 inline bool NodeProperties::IsContextEdge(Node::Edge edge) { 118 inline bool NodeProperties::IsContextEdge(Edge edge) {
119 Node* node = edge.from(); 119 Node* node = edge.from();
120 return IsInputRange(edge, FirstContextIndex(node), 120 return IsInputRange(edge, FirstContextIndex(node),
121 OperatorProperties::GetContextInputCount(node->op())); 121 OperatorProperties::GetContextInputCount(node->op()));
122 } 122 }
123 123
124 inline bool NodeProperties::IsEffectEdge(Node::Edge edge) { 124 inline bool NodeProperties::IsEffectEdge(Edge edge) {
125 Node* node = edge.from(); 125 Node* node = edge.from();
126 return IsInputRange(edge, FirstEffectIndex(node), 126 return IsInputRange(edge, FirstEffectIndex(node),
127 node->op()->EffectInputCount()); 127 node->op()->EffectInputCount());
128 } 128 }
129 129
130 inline bool NodeProperties::IsControlEdge(Node::Edge edge) { 130 inline bool NodeProperties::IsControlEdge(Edge edge) {
131 Node* node = edge.from(); 131 Node* node = edge.from();
132 return IsInputRange(edge, FirstControlIndex(node), 132 return IsInputRange(edge, FirstControlIndex(node),
133 node->op()->ControlInputCount()); 133 node->op()->ControlInputCount());
134 } 134 }
135 135
136 136
137 // ----------------------------------------------------------------------------- 137 // -----------------------------------------------------------------------------
138 // Miscellaneous predicates. 138 // Miscellaneous predicates.
139 139
140 inline bool NodeProperties::IsControl(Node* node) { 140 inline bool NodeProperties::IsControl(Node* node) {
(...skipping 28 matching lines...) Expand all
169 // Replace value uses of {node} with {value} and effect uses of {node} with 169 // Replace value uses of {node} with {value} and effect uses of {node} with
170 // {effect}. If {effect == NULL}, then use the effect input to {node}. 170 // {effect}. If {effect == NULL}, then use the effect input to {node}.
171 inline void NodeProperties::ReplaceWithValue(Node* node, Node* value, 171 inline void NodeProperties::ReplaceWithValue(Node* node, Node* value,
172 Node* effect) { 172 Node* effect) {
173 DCHECK(node->op()->ControlOutputCount() == 0); 173 DCHECK(node->op()->ControlOutputCount() == 0);
174 if (effect == NULL && node->op()->EffectInputCount() > 0) { 174 if (effect == NULL && node->op()->EffectInputCount() > 0) {
175 effect = NodeProperties::GetEffectInput(node); 175 effect = NodeProperties::GetEffectInput(node);
176 } 176 }
177 177
178 // Requires distinguishing between value and effect edges. 178 // Requires distinguishing between value and effect edges.
179 UseIter iter = node->uses().begin(); 179 for (Edge edge : node->use_edges()) {
180 while (iter != node->uses().end()) { 180 if (NodeProperties::IsEffectEdge(edge)) {
181 if (NodeProperties::IsEffectEdge(iter.edge())) {
182 DCHECK_NE(NULL, effect); 181 DCHECK_NE(NULL, effect);
183 iter = iter.UpdateToAndIncrement(effect); 182 edge.UpdateTo(effect);
184 } else { 183 } else {
185 iter = iter.UpdateToAndIncrement(value); 184 edge.UpdateTo(value);
186 } 185 }
187 } 186 }
188 } 187 }
189 188
190 189
191 // ----------------------------------------------------------------------------- 190 // -----------------------------------------------------------------------------
192 // Type Bounds. 191 // Type Bounds.
193 192
194 inline bool NodeProperties::IsTyped(Node* node) { 193 inline bool NodeProperties::IsTyped(Node* node) {
195 Bounds bounds = node->bounds(); 194 Bounds bounds = node->bounds();
(...skipping 18 matching lines...) Expand all
214 } 213 }
215 return true; 214 return true;
216 } 215 }
217 216
218 217
219 } 218 }
220 } 219 }
221 } // namespace v8::internal::compiler 220 } // namespace v8::internal::compiler
222 221
223 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_ 222 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_
OLDNEW
« no previous file with comments | « src/compiler/node-properties.h ('k') | src/compiler/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698