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/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/compiler/linkage.h" | 6 #include "src/compiler/linkage.h" |
7 #include "src/compiler/register-allocator.h" | 7 #include "src/compiler/register-allocator.h" |
8 #include "src/string-stream.h" | 8 #include "src/string-stream.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 3393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3404 | 3404 |
3405 void LiveRangeConnector::ResolveControlFlow(Zone* local_zone) { | 3405 void LiveRangeConnector::ResolveControlFlow(Zone* local_zone) { |
3406 // Lazily linearize live ranges in memory for fast lookup. | 3406 // Lazily linearize live ranges in memory for fast lookup. |
3407 LiveRangeFinder finder(data(), local_zone); | 3407 LiveRangeFinder finder(data(), local_zone); |
3408 ZoneVector<BitVector*>& live_in_sets = data()->live_in_sets(); | 3408 ZoneVector<BitVector*>& live_in_sets = data()->live_in_sets(); |
3409 for (const InstructionBlock* block : code()->instruction_blocks()) { | 3409 for (const InstructionBlock* block : code()->instruction_blocks()) { |
3410 if (CanEagerlyResolveControlFlow(block)) continue; | 3410 if (CanEagerlyResolveControlFlow(block)) continue; |
3411 BitVector* live = live_in_sets[block->rpo_number().ToInt()]; | 3411 BitVector* live = live_in_sets[block->rpo_number().ToInt()]; |
3412 BitVector::Iterator iterator(live); | 3412 BitVector::Iterator iterator(live); |
3413 while (!iterator.Done()) { | 3413 while (!iterator.Done()) { |
3414 LiveRangeBoundArray* array = finder.ArrayFor(iterator.Current()); | 3414 int vreg = iterator.Current(); |
| 3415 LiveRangeBoundArray* array = finder.ArrayFor(vreg); |
3415 for (const RpoNumber& pred : block->predecessors()) { | 3416 for (const RpoNumber& pred : block->predecessors()) { |
3416 FindResult result; | 3417 FindResult result; |
3417 const InstructionBlock* pred_block = code()->InstructionBlockAt(pred); | 3418 const InstructionBlock* pred_block = code()->InstructionBlockAt(pred); |
3418 if (!array->FindConnectableSubranges(block, pred_block, &result)) { | 3419 if (!array->FindConnectableSubranges(block, pred_block, &result)) { |
3419 continue; | 3420 continue; |
3420 } | 3421 } |
3421 InstructionOperand pred_op = result.pred_cover_->GetAssignedOperand(); | 3422 InstructionOperand pred_op = result.pred_cover_->GetAssignedOperand(); |
3422 InstructionOperand cur_op = result.cur_cover_->GetAssignedOperand(); | 3423 InstructionOperand cur_op = result.cur_cover_->GetAssignedOperand(); |
3423 if (pred_op.Equals(cur_op)) continue; | 3424 if (pred_op.Equals(cur_op)) continue; |
3424 if (!pred_op.IsAnyRegister() && cur_op.IsAnyRegister()) { | 3425 if (!pred_op.IsAnyRegister() && cur_op.IsAnyRegister()) { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3621 } | 3622 } |
3622 | 3623 |
3623 ZoneQueue<int> worklist(temp_zone); | 3624 ZoneQueue<int> worklist(temp_zone); |
3624 | 3625 |
3625 for (BitVector::Iterator iterator( | 3626 for (BitVector::Iterator iterator( |
3626 range->GetListOfBlocksRequiringSpillOperands()); | 3627 range->GetListOfBlocksRequiringSpillOperands()); |
3627 !iterator.Done(); iterator.Advance()) { | 3628 !iterator.Done(); iterator.Advance()) { |
3628 worklist.push(iterator.Current()); | 3629 worklist.push(iterator.Current()); |
3629 } | 3630 } |
3630 | 3631 |
| 3632 ZoneSet<std::pair<RpoNumber, int>> done_moves(temp_zone); |
3631 // Seek the deferred blocks that dominate locations requiring spill operands, | 3633 // Seek the deferred blocks that dominate locations requiring spill operands, |
3632 // and spill there. We only need to spill at the start of such blocks. | 3634 // and spill there. We only need to spill at the start of such blocks. |
3633 BitVector done_blocks( | 3635 BitVector done_blocks( |
3634 range->GetListOfBlocksRequiringSpillOperands()->length(), temp_zone); | 3636 range->GetListOfBlocksRequiringSpillOperands()->length(), temp_zone); |
3635 while (!worklist.empty()) { | 3637 while (!worklist.empty()) { |
3636 int block_id = worklist.front(); | 3638 int block_id = worklist.front(); |
3637 worklist.pop(); | 3639 worklist.pop(); |
3638 if (done_blocks.Contains(block_id)) continue; | 3640 if (done_blocks.Contains(block_id)) continue; |
3639 done_blocks.Add(block_id); | 3641 done_blocks.Add(block_id); |
3640 InstructionBlock* spill_block = | 3642 InstructionBlock* spill_block = |
3641 code->InstructionBlockAt(RpoNumber::FromInt(block_id)); | 3643 code->InstructionBlockAt(RpoNumber::FromInt(block_id)); |
3642 | 3644 |
3643 for (const RpoNumber& pred : spill_block->predecessors()) { | 3645 for (const RpoNumber& pred : spill_block->predecessors()) { |
3644 const InstructionBlock* pred_block = code->InstructionBlockAt(pred); | 3646 const InstructionBlock* pred_block = code->InstructionBlockAt(pred); |
3645 | 3647 |
3646 if (pred_block->IsDeferred()) { | 3648 if (pred_block->IsDeferred()) { |
3647 worklist.push(pred_block->rpo_number().ToInt()); | 3649 worklist.push(pred_block->rpo_number().ToInt()); |
3648 } else { | 3650 } else { |
3649 LifetimePosition pred_end = | 3651 LifetimePosition pred_end = |
3650 LifetimePosition::InstructionFromInstructionIndex( | 3652 LifetimePosition::InstructionFromInstructionIndex( |
3651 pred_block->last_instruction_index()); | 3653 pred_block->last_instruction_index()); |
3652 | 3654 |
3653 LiveRangeBound* bound = array->Find(pred_end); | 3655 LiveRangeBound* bound = array->Find(pred_end); |
3654 | 3656 |
3655 InstructionOperand pred_op = bound->range_->GetAssignedOperand(); | 3657 InstructionOperand pred_op = bound->range_->GetAssignedOperand(); |
3656 | 3658 |
3657 data()->AddGapMove(spill_block->first_instruction_index(), | 3659 RpoNumber spill_block_number = spill_block->rpo_number(); |
3658 Instruction::GapPosition::START, pred_op, | 3660 if (done_moves.find(std::make_pair( |
3659 spill_operand); | 3661 spill_block_number, range->vreg())) == done_moves.end()) { |
3660 spill_block->mark_needs_frame(); | 3662 data()->AddGapMove(spill_block->first_instruction_index(), |
| 3663 Instruction::GapPosition::START, pred_op, |
| 3664 spill_operand); |
| 3665 done_moves.insert(std::make_pair(spill_block_number, range->vreg())); |
| 3666 spill_block->mark_needs_frame(); |
| 3667 } |
3661 } | 3668 } |
3662 } | 3669 } |
3663 } | 3670 } |
3664 } | 3671 } |
3665 | 3672 |
3666 | 3673 |
3667 } // namespace compiler | 3674 } // namespace compiler |
3668 } // namespace internal | 3675 } // namespace internal |
3669 } // namespace v8 | 3676 } // namespace v8 |
OLD | NEW |