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

Unified Diff: src/compiler/instruction-scheduler.cc

Issue 2193063003: [turbofan] Use a map to cache values definition in instruction scheduler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/instruction-scheduler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/instruction-scheduler.cc
diff --git a/src/compiler/instruction-scheduler.cc b/src/compiler/instruction-scheduler.cc
index 478246c155b076af7837ba6ded4e4a3932c4f578..2e10794d69d6f829fe096bf82d0d3d407ff10a66 100644
--- a/src/compiler/instruction-scheduler.cc
+++ b/src/compiler/instruction-scheduler.cc
@@ -83,8 +83,8 @@ InstructionScheduler::InstructionScheduler(Zone* zone,
last_side_effect_instr_(nullptr),
pending_loads_(zone),
last_live_in_reg_marker_(nullptr),
- last_deopt_(nullptr) {
-}
+ last_deopt_(nullptr),
+ operands_map_(zone) {}
void InstructionScheduler::StartBlock(RpoNumber rpo) {
@@ -93,6 +93,7 @@ void InstructionScheduler::StartBlock(RpoNumber rpo) {
DCHECK(pending_loads_.empty());
DCHECK(last_live_in_reg_marker_ == nullptr);
DCHECK(last_deopt_ == nullptr);
+ DCHECK(operands_map_.empty());
sequence()->StartBlock(rpo);
}
@@ -109,6 +110,7 @@ void InstructionScheduler::EndBlock(RpoNumber rpo) {
pending_loads_.clear();
last_live_in_reg_marker_ = nullptr;
last_deopt_ = nullptr;
+ operands_map_.clear();
}
@@ -165,9 +167,26 @@ void InstructionScheduler::AddInstruction(Instruction* instr) {
}
// Look for operand dependencies.
- for (ScheduleGraphNode* node : graph_) {
- if (HasOperandDependency(node->instruction(), instr)) {
- node->AddSuccessor(new_node);
+ for (size_t i = 0; i < instr->InputCount(); ++i) {
+ const InstructionOperand* input = instr->InputAt(i);
+ if (input->IsUnallocated()) {
+ int32_t vreg = UnallocatedOperand::cast(input)->virtual_register();
+ auto it = operands_map_.find(vreg);
+ if (it != operands_map_.end()) {
+ it->second->AddSuccessor(new_node);
+ }
+ }
+ }
+
+ // Record the virtual registers defined by this instruction.
+ for (size_t i = 0; i < instr->OutputCount(); ++i) {
+ const InstructionOperand* output = instr->OutputAt(i);
+ if (output->IsUnallocated()) {
+ operands_map_[UnallocatedOperand::cast(output)->virtual_register()] =
+ new_node;
+ } else if (output->IsConstant()) {
+ operands_map_[ConstantOperand::cast(output)->virtual_register()] =
+ new_node;
}
}
}
@@ -317,33 +336,6 @@ int InstructionScheduler::GetInstructionFlags(const Instruction* instr) const {
}
-bool InstructionScheduler::HasOperandDependency(
- const Instruction* instr1, const Instruction* instr2) const {
- for (size_t i = 0; i < instr1->OutputCount(); ++i) {
- for (size_t j = 0; j < instr2->InputCount(); ++j) {
- const InstructionOperand* output = instr1->OutputAt(i);
- const InstructionOperand* input = instr2->InputAt(j);
-
- if (output->IsUnallocated() && input->IsUnallocated() &&
- (UnallocatedOperand::cast(output)->virtual_register() ==
- UnallocatedOperand::cast(input)->virtual_register())) {
- return true;
- }
-
- if (output->IsConstant() && input->IsUnallocated() &&
- (ConstantOperand::cast(output)->virtual_register() ==
- UnallocatedOperand::cast(input)->virtual_register())) {
- return true;
- }
- }
- }
-
- // TODO(bafsa): Do we need to look for anti-dependencies/output-dependencies?
-
- return false;
-}
-
-
bool InstructionScheduler::IsBlockTerminator(const Instruction* instr) const {
return ((GetInstructionFlags(instr) & kIsBlockTerminator) ||
(instr->flags_mode() == kFlags_branch));
« no previous file with comments | « src/compiler/instruction-scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698