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