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

Side by Side Diff: src/compiler/instruction-selector.cc

Issue 809333002: [turbofan] Implement OSR for outer loops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 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/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/instruction-selector-impl.h" 8 #include "src/compiler/instruction-selector-impl.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // matching may cover more than one node at a time. 450 // matching may cover more than one node at a time.
451 for (BasicBlock::reverse_iterator i = block->rbegin(); i != block->rend(); 451 for (BasicBlock::reverse_iterator i = block->rbegin(); i != block->rend();
452 ++i) { 452 ++i) {
453 Node* node = *i; 453 Node* node = *i;
454 // Skip nodes that are unused or already defined. 454 // Skip nodes that are unused or already defined.
455 if (!IsUsed(node) || IsDefined(node)) continue; 455 if (!IsUsed(node) || IsDefined(node)) continue;
456 // Generate code for this node "top down", but schedule the code "bottom 456 // Generate code for this node "top down", but schedule the code "bottom
457 // up". 457 // up".
458 size_t current_node_end = instructions_.size(); 458 size_t current_node_end = instructions_.size();
459 VisitNode(node); 459 VisitNode(node);
460 // TODO(turbofan): only reverse if > 1 instruction emitted.
460 std::reverse(instructions_.begin() + current_node_end, instructions_.end()); 461 std::reverse(instructions_.begin() + current_node_end, instructions_.end());
461 } 462 }
462 463
463 // We're done with the block. 464 // We're done with the block.
464 InstructionBlock* instruction_block = 465 InstructionBlock* instruction_block =
465 sequence()->InstructionBlockAt(block->GetRpoNumber()); 466 sequence()->InstructionBlockAt(block->GetRpoNumber());
466 instruction_block->set_code_start(static_cast<int>(instructions_.size())); 467 instruction_block->set_code_start(static_cast<int>(instructions_.size()));
467 instruction_block->set_code_end(current_block_end); 468 instruction_block->set_code_end(current_block_end);
468 469
469 current_block_ = NULL; 470 current_block_ = NULL;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 case IrOpcode::kIfFalse: 530 case IrOpcode::kIfFalse:
530 case IrOpcode::kEffectPhi: 531 case IrOpcode::kEffectPhi:
531 case IrOpcode::kMerge: 532 case IrOpcode::kMerge:
532 case IrOpcode::kTerminate: 533 case IrOpcode::kTerminate:
533 // No code needed for these graph artifacts. 534 // No code needed for these graph artifacts.
534 return kMachNone; 535 return kMachNone;
535 case IrOpcode::kFinish: 536 case IrOpcode::kFinish:
536 return kMachAnyTagged; 537 return kMachAnyTagged;
537 case IrOpcode::kParameter: 538 case IrOpcode::kParameter:
538 return linkage()->GetParameterType(OpParameter<int>(node)); 539 return linkage()->GetParameterType(OpParameter<int>(node));
540 case IrOpcode::kOsrValue:
541 return kMachAnyTagged;
539 case IrOpcode::kPhi: 542 case IrOpcode::kPhi:
540 return OpParameter<MachineType>(node); 543 return OpParameter<MachineType>(node);
541 case IrOpcode::kProjection: 544 case IrOpcode::kProjection:
542 // TODO(jarin) Really project from outputs. 545 // TODO(jarin) Really project from outputs.
543 return kMachAnyTagged; 546 return kMachAnyTagged;
544 case IrOpcode::kInt32Constant: 547 case IrOpcode::kInt32Constant:
545 return kMachInt32; 548 return kMachInt32;
546 case IrOpcode::kInt64Constant: 549 case IrOpcode::kInt64Constant:
547 return kMachInt64; 550 return kMachInt64;
548 case IrOpcode::kExternalConstant: 551 case IrOpcode::kExternalConstant:
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 case IrOpcode::kMerge: 670 case IrOpcode::kMerge:
668 // No code needed for these graph artifacts. 671 // No code needed for these graph artifacts.
669 return; 672 return;
670 case IrOpcode::kFinish: 673 case IrOpcode::kFinish:
671 return MarkAsReference(node), VisitFinish(node); 674 return MarkAsReference(node), VisitFinish(node);
672 case IrOpcode::kParameter: { 675 case IrOpcode::kParameter: {
673 MachineType type = linkage()->GetParameterType(OpParameter<int>(node)); 676 MachineType type = linkage()->GetParameterType(OpParameter<int>(node));
674 MarkAsRepresentation(type, node); 677 MarkAsRepresentation(type, node);
675 return VisitParameter(node); 678 return VisitParameter(node);
676 } 679 }
680 case IrOpcode::kOsrValue:
681 return VisitOsrValue(node);
677 case IrOpcode::kPhi: { 682 case IrOpcode::kPhi: {
678 MachineType type = OpParameter<MachineType>(node); 683 MachineType type = OpParameter<MachineType>(node);
679 MarkAsRepresentation(type, node); 684 MarkAsRepresentation(type, node);
680 return VisitPhi(node); 685 return VisitPhi(node);
681 } 686 }
682 case IrOpcode::kProjection: 687 case IrOpcode::kProjection:
683 return VisitProjection(node); 688 return VisitProjection(node);
684 case IrOpcode::kInt32Constant: 689 case IrOpcode::kInt32Constant:
685 case IrOpcode::kInt64Constant: 690 case IrOpcode::kInt64Constant:
686 case IrOpcode::kExternalConstant: 691 case IrOpcode::kExternalConstant:
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 956
952 void InstructionSelector::VisitParameter(Node* node) { 957 void InstructionSelector::VisitParameter(Node* node) {
953 OperandGenerator g(this); 958 OperandGenerator g(this);
954 int index = OpParameter<int>(node); 959 int index = OpParameter<int>(node);
955 Emit(kArchNop, 960 Emit(kArchNop,
956 g.DefineAsLocation(node, linkage()->GetParameterLocation(index), 961 g.DefineAsLocation(node, linkage()->GetParameterLocation(index),
957 linkage()->GetParameterType(index))); 962 linkage()->GetParameterType(index)));
958 } 963 }
959 964
960 965
966 void InstructionSelector::VisitOsrValue(Node* node) {
967 OperandGenerator g(this);
968 int index = OpParameter<int>(node);
969 Emit(kArchNop, g.DefineAsLocation(node, linkage()->GetOsrValueLocation(index),
970 kMachAnyTagged));
971 }
972
973
961 void InstructionSelector::VisitPhi(Node* node) { 974 void InstructionSelector::VisitPhi(Node* node) {
962 const int input_count = node->op()->ValueInputCount(); 975 const int input_count = node->op()->ValueInputCount();
963 PhiInstruction* phi = new (instruction_zone()) 976 PhiInstruction* phi = new (instruction_zone())
964 PhiInstruction(instruction_zone(), GetVirtualRegister(node), 977 PhiInstruction(instruction_zone(), GetVirtualRegister(node),
965 static_cast<size_t>(input_count)); 978 static_cast<size_t>(input_count));
966 sequence()->InstructionBlockAt(current_block_->GetRpoNumber())->AddPhi(phi); 979 sequence()->InstructionBlockAt(current_block_->GetRpoNumber())->AddPhi(phi);
967 for (int i = 0; i < input_count; ++i) { 980 for (int i = 0; i < input_count; ++i) {
968 Node* const input = node->InputAt(i); 981 Node* const input = node->InputAt(i);
969 MarkAsUsed(input); 982 MarkAsUsed(input);
970 phi->Extend(instruction_zone(), GetVirtualRegister(input)); 983 phi->Extend(instruction_zone(), GetVirtualRegister(input));
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 MachineOperatorBuilder::Flags 1155 MachineOperatorBuilder::Flags
1143 InstructionSelector::SupportedMachineOperatorFlags() { 1156 InstructionSelector::SupportedMachineOperatorFlags() {
1144 return MachineOperatorBuilder::Flag::kNoFlags; 1157 return MachineOperatorBuilder::Flag::kNoFlags;
1145 } 1158 }
1146 1159
1147 #endif // !V8_TURBOFAN_BACKEND 1160 #endif // !V8_TURBOFAN_BACKEND
1148 1161
1149 } // namespace compiler 1162 } // namespace compiler
1150 } // namespace internal 1163 } // namespace internal
1151 } // namespace v8 1164 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698