Chromium Code Reviews| 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/instruction-selector.h" | 5 #include "src/compiler/instruction-selector.h" |
| 6 | 6 |
| 7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
| 10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 // matching may cover more than one node at a time. | 457 // matching may cover more than one node at a time. |
| 458 for (BasicBlock::reverse_iterator i = block->rbegin(); i != block->rend(); | 458 for (BasicBlock::reverse_iterator i = block->rbegin(); i != block->rend(); |
| 459 ++i) { | 459 ++i) { |
| 460 Node* node = *i; | 460 Node* node = *i; |
| 461 // Skip nodes that are unused or already defined. | 461 // Skip nodes that are unused or already defined. |
| 462 if (!IsUsed(node) || IsDefined(node)) continue; | 462 if (!IsUsed(node) || IsDefined(node)) continue; |
| 463 // Generate code for this node "top down", but schedule the code "bottom | 463 // Generate code for this node "top down", but schedule the code "bottom |
| 464 // up". | 464 // up". |
| 465 size_t current_node_end = instructions_.size(); | 465 size_t current_node_end = instructions_.size(); |
| 466 VisitNode(node); | 466 VisitNode(node); |
| 467 // TODO(turbofan): only reverse if > 1 instruction emitted. | |
|
Benedikt Meurer
2015/01/11 11:50:22
std::reverse handles that efficiently. No need to
titzer
2015/01/12 10:43:53
Hopefully so, TODO removed.
| |
| 467 std::reverse(instructions_.begin() + current_node_end, instructions_.end()); | 468 std::reverse(instructions_.begin() + current_node_end, instructions_.end()); |
| 468 } | 469 } |
| 469 | 470 |
| 470 // We're done with the block. | 471 // We're done with the block. |
| 471 InstructionBlock* instruction_block = | 472 InstructionBlock* instruction_block = |
| 472 sequence()->InstructionBlockAt(block->GetRpoNumber()); | 473 sequence()->InstructionBlockAt(block->GetRpoNumber()); |
| 473 instruction_block->set_code_start(static_cast<int>(instructions_.size())); | 474 instruction_block->set_code_start(static_cast<int>(instructions_.size())); |
| 474 instruction_block->set_code_end(current_block_end); | 475 instruction_block->set_code_end(current_block_end); |
| 475 | 476 |
| 476 current_block_ = NULL; | 477 current_block_ = NULL; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 case IrOpcode::kIfFalse: | 537 case IrOpcode::kIfFalse: |
| 537 case IrOpcode::kEffectPhi: | 538 case IrOpcode::kEffectPhi: |
| 538 case IrOpcode::kMerge: | 539 case IrOpcode::kMerge: |
| 539 case IrOpcode::kTerminate: | 540 case IrOpcode::kTerminate: |
| 540 // No code needed for these graph artifacts. | 541 // No code needed for these graph artifacts. |
| 541 return kMachNone; | 542 return kMachNone; |
| 542 case IrOpcode::kFinish: | 543 case IrOpcode::kFinish: |
| 543 return kMachAnyTagged; | 544 return kMachAnyTagged; |
| 544 case IrOpcode::kParameter: | 545 case IrOpcode::kParameter: |
| 545 return linkage()->GetParameterType(OpParameter<int>(node)); | 546 return linkage()->GetParameterType(OpParameter<int>(node)); |
| 547 case IrOpcode::kOsrValue: | |
| 548 return kMachAnyTagged; | |
| 546 case IrOpcode::kPhi: | 549 case IrOpcode::kPhi: |
| 547 return OpParameter<MachineType>(node); | 550 return OpParameter<MachineType>(node); |
| 548 case IrOpcode::kProjection: | 551 case IrOpcode::kProjection: |
| 549 // TODO(jarin) Really project from outputs. | 552 // TODO(jarin) Really project from outputs. |
| 550 return kMachAnyTagged; | 553 return kMachAnyTagged; |
| 551 case IrOpcode::kInt32Constant: | 554 case IrOpcode::kInt32Constant: |
| 552 return kMachInt32; | 555 return kMachInt32; |
| 553 case IrOpcode::kInt64Constant: | 556 case IrOpcode::kInt64Constant: |
| 554 return kMachInt64; | 557 return kMachInt64; |
| 555 case IrOpcode::kExternalConstant: | 558 case IrOpcode::kExternalConstant: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 674 case IrOpcode::kMerge: | 677 case IrOpcode::kMerge: |
| 675 // No code needed for these graph artifacts. | 678 // No code needed for these graph artifacts. |
| 676 return; | 679 return; |
| 677 case IrOpcode::kFinish: | 680 case IrOpcode::kFinish: |
| 678 return MarkAsReference(node), VisitFinish(node); | 681 return MarkAsReference(node), VisitFinish(node); |
| 679 case IrOpcode::kParameter: { | 682 case IrOpcode::kParameter: { |
| 680 MachineType type = linkage()->GetParameterType(OpParameter<int>(node)); | 683 MachineType type = linkage()->GetParameterType(OpParameter<int>(node)); |
| 681 MarkAsRepresentation(type, node); | 684 MarkAsRepresentation(type, node); |
| 682 return VisitParameter(node); | 685 return VisitParameter(node); |
| 683 } | 686 } |
| 687 case IrOpcode::kOsrValue: | |
| 688 return VisitOsrValue(node); | |
|
Benedikt Meurer
2015/01/11 11:50:22
Missing MarkAsReference(node) here.
titzer
2015/01/12 10:43:53
Done.
| |
| 684 case IrOpcode::kPhi: { | 689 case IrOpcode::kPhi: { |
| 685 MachineType type = OpParameter<MachineType>(node); | 690 MachineType type = OpParameter<MachineType>(node); |
| 686 MarkAsRepresentation(type, node); | 691 MarkAsRepresentation(type, node); |
| 687 return VisitPhi(node); | 692 return VisitPhi(node); |
| 688 } | 693 } |
| 689 case IrOpcode::kProjection: | 694 case IrOpcode::kProjection: |
| 690 return VisitProjection(node); | 695 return VisitProjection(node); |
| 691 case IrOpcode::kInt32Constant: | 696 case IrOpcode::kInt32Constant: |
| 692 case IrOpcode::kInt64Constant: | 697 case IrOpcode::kInt64Constant: |
| 693 case IrOpcode::kExternalConstant: | 698 case IrOpcode::kExternalConstant: |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 | 963 |
| 959 void InstructionSelector::VisitParameter(Node* node) { | 964 void InstructionSelector::VisitParameter(Node* node) { |
| 960 OperandGenerator g(this); | 965 OperandGenerator g(this); |
| 961 int index = OpParameter<int>(node); | 966 int index = OpParameter<int>(node); |
| 962 Emit(kArchNop, | 967 Emit(kArchNop, |
| 963 g.DefineAsLocation(node, linkage()->GetParameterLocation(index), | 968 g.DefineAsLocation(node, linkage()->GetParameterLocation(index), |
| 964 linkage()->GetParameterType(index))); | 969 linkage()->GetParameterType(index))); |
| 965 } | 970 } |
| 966 | 971 |
| 967 | 972 |
| 973 void InstructionSelector::VisitOsrValue(Node* node) { | |
| 974 OperandGenerator g(this); | |
| 975 int index = OpParameter<int>(node); | |
| 976 Emit(kArchNop, g.DefineAsLocation(node, linkage()->GetOsrValueLocation(index), | |
| 977 kMachAnyTagged)); | |
| 978 } | |
| 979 | |
| 980 | |
| 968 void InstructionSelector::VisitPhi(Node* node) { | 981 void InstructionSelector::VisitPhi(Node* node) { |
| 969 const int input_count = node->op()->ValueInputCount(); | 982 const int input_count = node->op()->ValueInputCount(); |
| 970 PhiInstruction* phi = new (instruction_zone()) | 983 PhiInstruction* phi = new (instruction_zone()) |
| 971 PhiInstruction(instruction_zone(), GetVirtualRegister(node), | 984 PhiInstruction(instruction_zone(), GetVirtualRegister(node), |
| 972 static_cast<size_t>(input_count)); | 985 static_cast<size_t>(input_count)); |
| 973 sequence()->InstructionBlockAt(current_block_->GetRpoNumber())->AddPhi(phi); | 986 sequence()->InstructionBlockAt(current_block_->GetRpoNumber())->AddPhi(phi); |
| 974 for (int i = 0; i < input_count; ++i) { | 987 for (int i = 0; i < input_count; ++i) { |
| 975 Node* const input = node->InputAt(i); | 988 Node* const input = node->InputAt(i); |
| 976 MarkAsUsed(input); | 989 MarkAsUsed(input); |
| 977 phi->Extend(instruction_zone(), GetVirtualRegister(input)); | 990 phi->Extend(instruction_zone(), GetVirtualRegister(input)); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1149 MachineOperatorBuilder::Flags | 1162 MachineOperatorBuilder::Flags |
| 1150 InstructionSelector::SupportedMachineOperatorFlags() { | 1163 InstructionSelector::SupportedMachineOperatorFlags() { |
| 1151 return MachineOperatorBuilder::Flag::kNoFlags; | 1164 return MachineOperatorBuilder::Flag::kNoFlags; |
| 1152 } | 1165 } |
| 1153 | 1166 |
| 1154 #endif // !V8_TURBOFAN_BACKEND | 1167 #endif // !V8_TURBOFAN_BACKEND |
| 1155 | 1168 |
| 1156 } // namespace compiler | 1169 } // namespace compiler |
| 1157 } // namespace internal | 1170 } // namespace internal |
| 1158 } // namespace v8 | 1171 } // namespace v8 |
| OLD | NEW |