| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/diamond.h" | 10 #include "src/compiler/diamond.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 for (int i = std::max(index, NodeProperties::FirstControlIndex(node)); | 230 for (int i = std::max(index, NodeProperties::FirstControlIndex(node)); |
| 231 i < NodeProperties::PastControlIndex(node); ++i) { | 231 i < NodeProperties::PastControlIndex(node); ++i) { |
| 232 Enqueue(node->InputAt(i)); // Control inputs: just visit | 232 Enqueue(node->InputAt(i)); // Control inputs: just visit |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 // The default, most general visitation case. For {node}, process all value, | 236 // The default, most general visitation case. For {node}, process all value, |
| 237 // context, effect, and control inputs, assuming that value inputs should have | 237 // context, effect, and control inputs, assuming that value inputs should have |
| 238 // {kRepTagged} representation and can observe all output values {kTypeAny}. | 238 // {kRepTagged} representation and can observe all output values {kTypeAny}. |
| 239 void VisitInputs(Node* node) { | 239 void VisitInputs(Node* node) { |
| 240 InputIter i = node->inputs().begin(); | 240 auto i = node->input_edges().begin(); |
| 241 for (int j = node->op()->ValueInputCount(); j > 0; ++i, j--) { | 241 for (int j = node->op()->ValueInputCount(); j > 0; ++i, j--) { |
| 242 ProcessInput(node, i.index(), kMachAnyTagged); // Value inputs | 242 ProcessInput(node, (*i).index(), kMachAnyTagged); // Value inputs |
| 243 } | 243 } |
| 244 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; | 244 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; |
| 245 ++i, j--) { | 245 ++i, j--) { |
| 246 ProcessInput(node, i.index(), kMachAnyTagged); // Context inputs | 246 ProcessInput(node, (*i).index(), kMachAnyTagged); // Context inputs |
| 247 } | 247 } |
| 248 for (int j = node->op()->EffectInputCount(); j > 0; ++i, j--) { | 248 for (int j = node->op()->EffectInputCount(); j > 0; ++i, j--) { |
| 249 Enqueue(*i); // Effect inputs: just visit | 249 Enqueue((*i).to()); // Effect inputs: just visit |
| 250 } | 250 } |
| 251 for (int j = node->op()->ControlInputCount(); j > 0; ++i, j--) { | 251 for (int j = node->op()->ControlInputCount(); j > 0; ++i, j--) { |
| 252 Enqueue(*i); // Control inputs: just visit | 252 Enqueue((*i).to()); // Control inputs: just visit |
| 253 } | 253 } |
| 254 SetOutput(node, kMachAnyTagged); | 254 SetOutput(node, kMachAnyTagged); |
| 255 } | 255 } |
| 256 | 256 |
| 257 // Helper for binops of the I x I -> O variety. | 257 // Helper for binops of the I x I -> O variety. |
| 258 void VisitBinop(Node* node, MachineTypeUnion input_use, | 258 void VisitBinop(Node* node, MachineTypeUnion input_use, |
| 259 MachineTypeUnion output) { | 259 MachineTypeUnion output) { |
| 260 DCHECK_EQ(2, node->InputCount()); | 260 DCHECK_EQ(2, node->InputCount()); |
| 261 ProcessInput(node, 0, input_use); | 261 ProcessInput(node, 0, input_use); |
| 262 ProcessInput(node, 1, input_use); | 262 ProcessInput(node, 1, input_use); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 int values = node->op()->ValueInputCount(); | 372 int values = node->op()->ValueInputCount(); |
| 373 | 373 |
| 374 if (lower()) { | 374 if (lower()) { |
| 375 // Update the phi operator. | 375 // Update the phi operator. |
| 376 MachineType type = static_cast<MachineType>(output_type); | 376 MachineType type = static_cast<MachineType>(output_type); |
| 377 if (type != OpParameter<MachineType>(node)) { | 377 if (type != OpParameter<MachineType>(node)) { |
| 378 node->set_op(lowering->common()->Phi(type, values)); | 378 node->set_op(lowering->common()->Phi(type, values)); |
| 379 } | 379 } |
| 380 | 380 |
| 381 // Convert inputs to the output representation of this phi. | 381 // Convert inputs to the output representation of this phi. |
| 382 Node::Inputs inputs = node->inputs(); | 382 for (Edge const edge : node->input_edges()) { |
| 383 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); | |
| 384 ++iter, --values) { | |
| 385 // TODO(titzer): it'd be nice to have distinguished edge kinds here. | 383 // TODO(titzer): it'd be nice to have distinguished edge kinds here. |
| 386 ProcessInput(node, iter.index(), values > 0 ? output_type : 0); | 384 ProcessInput(node, edge.index(), values > 0 ? output_type : 0); |
| 385 values--; |
| 387 } | 386 } |
| 388 } else { | 387 } else { |
| 389 // Propagate {use} of the phi to value inputs, and 0 to control. | 388 // Propagate {use} of the phi to value inputs, and 0 to control. |
| 390 Node::Inputs inputs = node->inputs(); | |
| 391 MachineType use_type = | 389 MachineType use_type = |
| 392 static_cast<MachineType>((use & kTypeMask) | output); | 390 static_cast<MachineType>((use & kTypeMask) | output); |
| 393 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); | 391 for (Edge const edge : node->input_edges()) { |
| 394 ++iter, --values) { | |
| 395 // TODO(titzer): it'd be nice to have distinguished edge kinds here. | 392 // TODO(titzer): it'd be nice to have distinguished edge kinds here. |
| 396 ProcessInput(node, iter.index(), values > 0 ? use_type : 0); | 393 ProcessInput(node, edge.index(), values > 0 ? use_type : 0); |
| 394 values--; |
| 397 } | 395 } |
| 398 } | 396 } |
| 399 } | 397 } |
| 400 | 398 |
| 401 const Operator* Int32Op(Node* node) { | 399 const Operator* Int32Op(Node* node) { |
| 402 return changer_->Int32OperatorFor(node->opcode()); | 400 return changer_->Int32OperatorFor(node->opcode()); |
| 403 } | 401 } |
| 404 | 402 |
| 405 const Operator* Uint32Op(Node* node) { | 403 const Operator* Uint32Op(Node* node) { |
| 406 return changer_->Uint32OperatorFor(node->opcode()); | 404 return changer_->Uint32OperatorFor(node->opcode()); |
| (...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1449 |
| 1452 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1450 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
| 1453 node->set_op(machine()->IntLessThanOrEqual()); | 1451 node->set_op(machine()->IntLessThanOrEqual()); |
| 1454 node->ReplaceInput(0, StringComparison(node, true)); | 1452 node->ReplaceInput(0, StringComparison(node, true)); |
| 1455 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1453 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
| 1456 } | 1454 } |
| 1457 | 1455 |
| 1458 } // namespace compiler | 1456 } // namespace compiler |
| 1459 } // namespace internal | 1457 } // namespace internal |
| 1460 } // namespace v8 | 1458 } // namespace v8 |
| OLD | NEW |