| 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/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
| 9 #include "src/compiler/graph-inl.h" | 9 #include "src/compiler/graph-inl.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 PrintInfo(output); | 181 PrintInfo(output); |
| 182 TRACE((" to ")); | 182 TRACE((" to ")); |
| 183 PrintInfo(use); | 183 PrintInfo(use); |
| 184 TRACE(("\n")); | 184 TRACE(("\n")); |
| 185 Node* n = changer_->GetRepresentationFor(input, output, use); | 185 Node* n = changer_->GetRepresentationFor(input, output, use); |
| 186 node->ReplaceInput(index, n); | 186 node->ReplaceInput(index, n); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 void ProcessRemainingInputs(Node* node, int index) { |
| 192 DCHECK_GE(index, NodeProperties::PastValueIndex(node)); |
| 193 DCHECK_GE(index, NodeProperties::PastContextIndex(node)); |
| 194 for (int i = std::max(index, NodeProperties::FirstEffectIndex(node)); |
| 195 i < NodeProperties::PastEffectIndex(node); ++i) { |
| 196 Enqueue(node->InputAt(i)); // Effect inputs: just visit |
| 197 } |
| 198 for (int i = std::max(index, NodeProperties::FirstControlIndex(node)); |
| 199 i < NodeProperties::PastControlIndex(node); ++i) { |
| 200 Enqueue(node->InputAt(i)); // Control inputs: just visit |
| 201 } |
| 202 } |
| 203 |
| 191 // The default, most general visitation case. For {node}, process all value, | 204 // The default, most general visitation case. For {node}, process all value, |
| 192 // context, effect, and control inputs, assuming that value inputs should have | 205 // context, effect, and control inputs, assuming that value inputs should have |
| 193 // {kRepTagged} representation and can observe all output values {kTypeAny}. | 206 // {kRepTagged} representation and can observe all output values {kTypeAny}. |
| 194 void VisitInputs(Node* node) { | 207 void VisitInputs(Node* node) { |
| 195 InputIter i = node->inputs().begin(); | 208 InputIter i = node->inputs().begin(); |
| 196 for (int j = OperatorProperties::GetValueInputCount(node->op()); j > 0; | 209 for (int j = OperatorProperties::GetValueInputCount(node->op()); j > 0; |
| 197 ++i, j--) { | 210 ++i, j--) { |
| 198 ProcessInput(node, i.index(), kMachAnyTagged); // Value inputs | 211 ProcessInput(node, i.index(), kMachAnyTagged); // Value inputs |
| 199 } | 212 } |
| 200 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; | 213 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 break; | 535 break; |
| 523 } | 536 } |
| 524 case IrOpcode::kStringAdd: { | 537 case IrOpcode::kStringAdd: { |
| 525 VisitBinop(node, kMachAnyTagged, kMachAnyTagged); | 538 VisitBinop(node, kMachAnyTagged, kMachAnyTagged); |
| 526 if (lower()) lowering->DoStringAdd(node); | 539 if (lower()) lowering->DoStringAdd(node); |
| 527 break; | 540 break; |
| 528 } | 541 } |
| 529 case IrOpcode::kLoadField: { | 542 case IrOpcode::kLoadField: { |
| 530 FieldAccess access = FieldAccessOf(node->op()); | 543 FieldAccess access = FieldAccessOf(node->op()); |
| 531 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); | 544 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); |
| 545 ProcessRemainingInputs(node, 1); |
| 532 SetOutput(node, access.machine_type); | 546 SetOutput(node, access.machine_type); |
| 533 if (lower()) lowering->DoLoadField(node); | 547 if (lower()) lowering->DoLoadField(node); |
| 534 break; | 548 break; |
| 535 } | 549 } |
| 536 case IrOpcode::kStoreField: { | 550 case IrOpcode::kStoreField: { |
| 537 FieldAccess access = FieldAccessOf(node->op()); | 551 FieldAccess access = FieldAccessOf(node->op()); |
| 538 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); | 552 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); |
| 539 ProcessInput(node, 1, access.machine_type); | 553 ProcessInput(node, 1, access.machine_type); |
| 554 ProcessRemainingInputs(node, 2); |
| 540 SetOutput(node, 0); | 555 SetOutput(node, 0); |
| 541 if (lower()) lowering->DoStoreField(node); | 556 if (lower()) lowering->DoStoreField(node); |
| 542 break; | 557 break; |
| 543 } | 558 } |
| 544 case IrOpcode::kLoadElement: { | 559 case IrOpcode::kLoadElement: { |
| 545 ElementAccess access = ElementAccessOf(node->op()); | 560 ElementAccess access = ElementAccessOf(node->op()); |
| 546 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); | 561 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); |
| 547 ProcessInput(node, 1, kMachInt32); // element index | 562 ProcessInput(node, 1, kMachInt32); // element index |
| 563 ProcessRemainingInputs(node, 2); |
| 548 SetOutput(node, access.machine_type); | 564 SetOutput(node, access.machine_type); |
| 549 if (lower()) lowering->DoLoadElement(node); | 565 if (lower()) lowering->DoLoadElement(node); |
| 550 break; | 566 break; |
| 551 } | 567 } |
| 552 case IrOpcode::kStoreElement: { | 568 case IrOpcode::kStoreElement: { |
| 553 ElementAccess access = ElementAccessOf(node->op()); | 569 ElementAccess access = ElementAccessOf(node->op()); |
| 554 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); | 570 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); |
| 555 ProcessInput(node, 1, kMachInt32); // element index | 571 ProcessInput(node, 1, kMachInt32); // element index |
| 556 ProcessInput(node, 2, access.machine_type); | 572 ProcessInput(node, 2, access.machine_type); |
| 573 ProcessRemainingInputs(node, 3); |
| 557 SetOutput(node, 0); | 574 SetOutput(node, 0); |
| 558 if (lower()) lowering->DoStoreElement(node); | 575 if (lower()) lowering->DoStoreElement(node); |
| 559 break; | 576 break; |
| 560 } | 577 } |
| 561 | 578 |
| 562 //------------------------------------------------------------------ | 579 //------------------------------------------------------------------ |
| 563 // Machine-level operators. | 580 // Machine-level operators. |
| 564 //------------------------------------------------------------------ | 581 //------------------------------------------------------------------ |
| 565 case IrOpcode::kLoad: { | 582 case IrOpcode::kLoad: { |
| 566 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? | 583 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? |
| 567 MachineType tBase = kRepTagged; | 584 MachineType tBase = kRepTagged; |
| 568 MachineType machine_type = OpParameter<MachineType>(node); | 585 MachineType machine_type = OpParameter<MachineType>(node); |
| 569 ProcessInput(node, 0, tBase); // pointer or object | 586 ProcessInput(node, 0, tBase); // pointer or object |
| 570 ProcessInput(node, 1, kMachInt32); // index | 587 ProcessInput(node, 1, kMachInt32); // index |
| 588 ProcessRemainingInputs(node, 2); |
| 571 SetOutput(node, machine_type); | 589 SetOutput(node, machine_type); |
| 572 break; | 590 break; |
| 573 } | 591 } |
| 574 case IrOpcode::kStore: { | 592 case IrOpcode::kStore: { |
| 575 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? | 593 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? |
| 576 MachineType tBase = kRepTagged; | 594 MachineType tBase = kRepTagged; |
| 577 StoreRepresentation rep = OpParameter<StoreRepresentation>(node); | 595 StoreRepresentation rep = OpParameter<StoreRepresentation>(node); |
| 578 ProcessInput(node, 0, tBase); // pointer or object | 596 ProcessInput(node, 0, tBase); // pointer or object |
| 579 ProcessInput(node, 1, kMachInt32); // index | 597 ProcessInput(node, 1, kMachInt32); // index |
| 580 ProcessInput(node, 2, rep.machine_type); | 598 ProcessInput(node, 2, rep.machine_type); |
| 599 ProcessRemainingInputs(node, 3); |
| 581 SetOutput(node, 0); | 600 SetOutput(node, 0); |
| 582 break; | 601 break; |
| 583 } | 602 } |
| 584 case IrOpcode::kWord32Shr: | 603 case IrOpcode::kWord32Shr: |
| 585 // We output unsigned int32 for shift right because JavaScript. | 604 // We output unsigned int32 for shift right because JavaScript. |
| 586 return VisitBinop(node, kRepWord32, kRepWord32 | kTypeUint32); | 605 return VisitBinop(node, kRepWord32, kRepWord32 | kTypeUint32); |
| 587 case IrOpcode::kWord32And: | 606 case IrOpcode::kWord32And: |
| 588 case IrOpcode::kWord32Or: | 607 case IrOpcode::kWord32Or: |
| 589 case IrOpcode::kWord32Xor: | 608 case IrOpcode::kWord32Xor: |
| 590 case IrOpcode::kWord32Shl: | 609 case IrOpcode::kWord32Shl: |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 jsgraph()->UndefinedConstant()); | 872 jsgraph()->UndefinedConstant()); |
| 854 node->set_op(machine()->WordEqual()); | 873 node->set_op(machine()->WordEqual()); |
| 855 node->ReplaceInput(0, call); | 874 node->ReplaceInput(0, call); |
| 856 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 875 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
| 857 } | 876 } |
| 858 | 877 |
| 859 | 878 |
| 860 } // namespace compiler | 879 } // namespace compiler |
| 861 } // namespace internal | 880 } // namespace internal |
| 862 } // namespace v8 | 881 } // namespace v8 |
| OLD | NEW |