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

Side by Side Diff: src/compiler/node-properties.cc

Issue 1368913002: [turbofan] Check node input/use consistency for changed operators and new nodes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Resurrect the control equivalence test. Created 5 years, 2 months 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include "src/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/node-properties.h" 7 #include "src/compiler/node-properties.h"
8 #include "src/compiler/operator-properties.h" 8 #include "src/compiler/operator-properties.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } else { 190 } else {
191 DCHECK_NOT_NULL(value); 191 DCHECK_NOT_NULL(value);
192 edge.UpdateTo(value); 192 edge.UpdateTo(value);
193 } 193 }
194 } 194 }
195 } 195 }
196 196
197 197
198 // static 198 // static
199 void NodeProperties::ChangeOp(Node* node, const Operator* new_op) { 199 void NodeProperties::ChangeOp(Node* node, const Operator* new_op) {
200 DCHECK_EQ(OperatorProperties::GetTotalInputCount(new_op), node->InputCount());
201 node->set_op(new_op); 200 node->set_op(new_op);
201
202 #ifdef DEBUG
203 Verify(node);
204 #endif // DEBUG
202 } 205 }
203 206
204 207
208 // static
209 void NodeProperties::Verify(Node* node) {
210 CHECK_EQ(OperatorProperties::GetTotalInputCount(node->op()),
211 node->InputCount());
212 // If this node has no effect or no control outputs,
213 // we check that no its uses are effect or control inputs.
214 bool check_no_control = node->op()->ControlOutputCount() == 0;
215 bool check_no_effect = node->op()->EffectOutputCount() == 0;
216 bool check_no_frame_state = node->opcode() != IrOpcode::kFrameState;
217 if (check_no_effect || check_no_control) {
218 for (Edge edge : node->use_edges()) {
219 Node* const user = edge.from();
220 CHECK(!user->IsDead());
221 if (NodeProperties::IsControlEdge(edge)) {
222 CHECK(!check_no_control);
223 } else if (NodeProperties::IsEffectEdge(edge)) {
224 CHECK(!check_no_effect);
225 } else if (NodeProperties::IsFrameStateEdge(edge)) {
226 CHECK(!check_no_frame_state);
227 }
228 }
229 }
230 // Frame state inputs should be frame states (or sentinels).
231 for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(node->op());
232 i++) {
233 Node* input = NodeProperties::GetFrameStateInput(node, i);
234 CHECK(input->opcode() == IrOpcode::kFrameState ||
235 input->opcode() == IrOpcode::kStart ||
236 input->opcode() == IrOpcode::kDead);
237 }
238 // Effect inputs should be effect-producing nodes (or sentinels).
239 for (int i = 0; i < node->op()->EffectInputCount(); i++) {
240 Node* input = NodeProperties::GetEffectInput(node, i);
241 CHECK(input->op()->EffectOutputCount() > 0 ||
242 input->opcode() == IrOpcode::kDead);
243 }
244 // Control inputs should be control-producing nodes (or sentinels).
245 for (int i = 0; i < node->op()->ControlInputCount(); i++) {
246 Node* input = NodeProperties::GetControlInput(node, i);
247 CHECK(input->op()->ControlOutputCount() > 0 ||
248 input->opcode() == IrOpcode::kDead);
249 }
250 }
251
252
205 // static 253 // static
206 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) { 254 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) {
207 for (auto use : node->uses()) { 255 for (auto use : node->uses()) {
208 if (use->opcode() == IrOpcode::kProjection && 256 if (use->opcode() == IrOpcode::kProjection &&
209 ProjectionIndexOf(use->op()) == projection_index) { 257 ProjectionIndexOf(use->op()) == projection_index) {
210 return use; 258 return use;
211 } 259 }
212 } 260 }
213 return nullptr; 261 return nullptr;
214 } 262 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // static 328 // static
281 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { 329 bool NodeProperties::IsInputRange(Edge edge, int first, int num) {
282 if (num == 0) return false; 330 if (num == 0) return false;
283 int const index = edge.index(); 331 int const index = edge.index();
284 return first <= index && index < first + num; 332 return first <= index && index < first + num;
285 } 333 }
286 334
287 } // namespace compiler 335 } // namespace compiler
288 } // namespace internal 336 } // namespace internal
289 } // namespace v8 337 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698