| 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/linkage.h" | 5 #include "src/compiler/linkage.h" |
| 6 #include "src/compiler/register-allocator.h" | 6 #include "src/compiler/register-allocator.h" |
| 7 #include "src/string-stream.h" | 7 #include "src/string-stream.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 } | 1071 } |
| 1072 } | 1072 } |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 | 1075 |
| 1076 void RegisterAllocator::ProcessPhis(const InstructionBlock* block) { | 1076 void RegisterAllocator::ProcessPhis(const InstructionBlock* block) { |
| 1077 for (auto phi : block->phis()) { | 1077 for (auto phi : block->phis()) { |
| 1078 auto output = phi->output(); | 1078 auto output = phi->output(); |
| 1079 int phi_vreg = phi->virtual_register(); | 1079 int phi_vreg = phi->virtual_register(); |
| 1080 LiveRange* live_range = LiveRangeFor(phi_vreg); | 1080 LiveRange* live_range = LiveRangeFor(phi_vreg); |
| 1081 BlockStartInstruction* block_start = | 1081 GapInstruction* gap = code()->GapAt(block->code_start() + 1); |
| 1082 code()->GetBlockStart(block->rpo_number()); | 1082 gap->GetOrCreateParallelMove(GapInstruction::BEFORE, code_zone()) |
| 1083 block_start->GetOrCreateParallelMove(GapInstruction::BEFORE, code_zone()) | |
| 1084 ->AddMove(output, live_range->GetSpillOperand(), code_zone()); | 1083 ->AddMove(output, live_range->GetSpillOperand(), code_zone()); |
| 1085 live_range->SetSpillStartIndex(block->first_instruction_index()); | 1084 live_range->SetSpillStartIndex(block->first_instruction_index()); |
| 1086 } | 1085 } |
| 1087 } | 1086 } |
| 1088 | 1087 |
| 1089 | 1088 |
| 1090 void RegisterAllocator::MeetRegisterConstraints() { | 1089 void RegisterAllocator::MeetRegisterConstraints() { |
| 1091 for (auto block : code()->instruction_blocks()) { | 1090 for (auto block : code()->instruction_blocks()) { |
| 1092 ProcessPhis(block); | 1091 ProcessPhis(block); |
| 1093 MeetRegisterConstraints(block); | 1092 MeetRegisterConstraints(block); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 } | 1338 } |
| 1340 | 1339 |
| 1341 | 1340 |
| 1342 void RegisterAllocator::ResolveControlFlow(const InstructionBlock* block, | 1341 void RegisterAllocator::ResolveControlFlow(const InstructionBlock* block, |
| 1343 InstructionOperand* cur_op, | 1342 InstructionOperand* cur_op, |
| 1344 const InstructionBlock* pred, | 1343 const InstructionBlock* pred, |
| 1345 InstructionOperand* pred_op) { | 1344 InstructionOperand* pred_op) { |
| 1346 if (pred_op->Equals(cur_op)) return; | 1345 if (pred_op->Equals(cur_op)) return; |
| 1347 GapInstruction* gap = nullptr; | 1346 GapInstruction* gap = nullptr; |
| 1348 if (block->PredecessorCount() == 1) { | 1347 if (block->PredecessorCount() == 1) { |
| 1349 gap = code()->GapAt(block->first_instruction_index()); | 1348 gap = code()->GapAt(block->first_instruction_index() + 1); |
| 1350 } else { | 1349 } else { |
| 1351 DCHECK(pred->SuccessorCount() == 1); | 1350 DCHECK(pred->SuccessorCount() == 1); |
| 1352 gap = GetLastGap(pred); | 1351 gap = GetLastGap(pred); |
| 1353 | 1352 DCHECK(!InstructionAt(pred->last_instruction_index())->HasPointerMap()); |
| 1354 Instruction* branch = InstructionAt(pred->last_instruction_index()); | |
| 1355 DCHECK(!branch->HasPointerMap()); | |
| 1356 USE(branch); | |
| 1357 } | 1353 } |
| 1358 gap->GetOrCreateParallelMove(GapInstruction::START, code_zone()) | 1354 gap->GetOrCreateParallelMove(GapInstruction::START, code_zone()) |
| 1359 ->AddMove(pred_op, cur_op, code_zone()); | 1355 ->AddMove(pred_op, cur_op, code_zone()); |
| 1360 } | 1356 } |
| 1361 | 1357 |
| 1362 | 1358 |
| 1363 void RegisterAllocator::BuildLiveRanges() { | 1359 void RegisterAllocator::BuildLiveRanges() { |
| 1364 InitializeLivenessAnalysis(); | 1360 InitializeLivenessAnalysis(); |
| 1365 // Process the blocks in reverse order. | 1361 // Process the blocks in reverse order. |
| 1366 for (int block_id = code()->InstructionBlockCount() - 1; block_id >= 0; | 1362 for (int block_id = code()->InstructionBlockCount() - 1; block_id >= 0; |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2233 } else { | 2229 } else { |
| 2234 DCHECK(range->Kind() == GENERAL_REGISTERS); | 2230 DCHECK(range->Kind() == GENERAL_REGISTERS); |
| 2235 assigned_registers_->Add(reg); | 2231 assigned_registers_->Add(reg); |
| 2236 } | 2232 } |
| 2237 range->set_assigned_register(reg, code_zone()); | 2233 range->set_assigned_register(reg, code_zone()); |
| 2238 } | 2234 } |
| 2239 | 2235 |
| 2240 } | 2236 } |
| 2241 } | 2237 } |
| 2242 } // namespace v8::internal::compiler | 2238 } // namespace v8::internal::compiler |
| OLD | NEW |