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

Side by Side Diff: src/compiler/register-allocator.cc

Issue 1912093005: [turbofan] Single entry into deferred regions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 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/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
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 int vreg = iterator.Current();
Benedikt Meurer 2016/04/23 12:04:49 Stale change?
Mircea Trofin 2016/04/23 16:27:07 Ya, I meant to use vreg in the finder.ArrayFor cal
3415 USE(vreg);
3414 LiveRangeBoundArray* array = finder.ArrayFor(iterator.Current()); 3416 LiveRangeBoundArray* array = finder.ArrayFor(iterator.Current());
3415 for (const RpoNumber& pred : block->predecessors()) { 3417 for (const RpoNumber& pred : block->predecessors()) {
3416 FindResult result; 3418 FindResult result;
3417 const InstructionBlock* pred_block = code()->InstructionBlockAt(pred); 3419 const InstructionBlock* pred_block = code()->InstructionBlockAt(pred);
3418 if (!array->FindConnectableSubranges(block, pred_block, &result)) { 3420 if (!array->FindConnectableSubranges(block, pred_block, &result)) {
3419 continue; 3421 continue;
3420 } 3422 }
3421 InstructionOperand pred_op = result.pred_cover_->GetAssignedOperand(); 3423 InstructionOperand pred_op = result.pred_cover_->GetAssignedOperand();
3422 InstructionOperand cur_op = result.cur_cover_->GetAssignedOperand(); 3424 InstructionOperand cur_op = result.cur_cover_->GetAssignedOperand();
3423 if (pred_op.Equals(cur_op)) continue; 3425 if (pred_op.Equals(cur_op)) continue;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
3621 } 3623 }
3622 3624
3623 ZoneQueue<int> worklist(temp_zone); 3625 ZoneQueue<int> worklist(temp_zone);
3624 3626
3625 for (BitVector::Iterator iterator( 3627 for (BitVector::Iterator iterator(
3626 range->GetListOfBlocksRequiringSpillOperands()); 3628 range->GetListOfBlocksRequiringSpillOperands());
3627 !iterator.Done(); iterator.Advance()) { 3629 !iterator.Done(); iterator.Advance()) {
3628 worklist.push(iterator.Current()); 3630 worklist.push(iterator.Current());
3629 } 3631 }
3630 3632
3633 ZoneSet<std::pair<RpoNumber, int>> done_moves(temp_zone);
3631 // Seek the deferred blocks that dominate locations requiring spill operands, 3634 // 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. 3635 // and spill there. We only need to spill at the start of such blocks.
3633 BitVector done_blocks( 3636 BitVector done_blocks(
3634 range->GetListOfBlocksRequiringSpillOperands()->length(), temp_zone); 3637 range->GetListOfBlocksRequiringSpillOperands()->length(), temp_zone);
3635 while (!worklist.empty()) { 3638 while (!worklist.empty()) {
3636 int block_id = worklist.front(); 3639 int block_id = worklist.front();
3637 worklist.pop(); 3640 worklist.pop();
3638 if (done_blocks.Contains(block_id)) continue; 3641 if (done_blocks.Contains(block_id)) continue;
3639 done_blocks.Add(block_id); 3642 done_blocks.Add(block_id);
3640 InstructionBlock* spill_block = 3643 InstructionBlock* spill_block =
3641 code->InstructionBlockAt(RpoNumber::FromInt(block_id)); 3644 code->InstructionBlockAt(RpoNumber::FromInt(block_id));
3642 3645
3643 for (const RpoNumber& pred : spill_block->predecessors()) { 3646 for (const RpoNumber& pred : spill_block->predecessors()) {
3644 const InstructionBlock* pred_block = code->InstructionBlockAt(pred); 3647 const InstructionBlock* pred_block = code->InstructionBlockAt(pred);
3645 3648
3646 if (pred_block->IsDeferred()) { 3649 if (pred_block->IsDeferred()) {
3647 worklist.push(pred_block->rpo_number().ToInt()); 3650 worklist.push(pred_block->rpo_number().ToInt());
3648 } else { 3651 } else {
3649 LifetimePosition pred_end = 3652 LifetimePosition pred_end =
3650 LifetimePosition::InstructionFromInstructionIndex( 3653 LifetimePosition::InstructionFromInstructionIndex(
3651 pred_block->last_instruction_index()); 3654 pred_block->last_instruction_index());
3652 3655
3653 LiveRangeBound* bound = array->Find(pred_end); 3656 LiveRangeBound* bound = array->Find(pred_end);
3654 3657
3655 InstructionOperand pred_op = bound->range_->GetAssignedOperand(); 3658 InstructionOperand pred_op = bound->range_->GetAssignedOperand();
3656 3659
3657 data()->AddGapMove(spill_block->first_instruction_index(), 3660 RpoNumber spill_block_number = spill_block->rpo_number();
3658 Instruction::GapPosition::START, pred_op, 3661 if (done_moves.find(std::make_pair(
3659 spill_operand); 3662 spill_block_number, range->vreg())) == done_moves.end()) {
3660 spill_block->mark_needs_frame(); 3663 data()->AddGapMove(spill_block->first_instruction_index(),
3664 Instruction::GapPosition::START, pred_op,
3665 spill_operand);
3666 done_moves.insert(std::make_pair(spill_block_number, range->vreg()));
3667 spill_block->mark_needs_frame();
3668 }
3661 } 3669 }
3662 } 3670 }
3663 } 3671 }
3664 } 3672 }
3665 3673
3666 3674
3667 } // namespace compiler 3675 } // namespace compiler
3668 } // namespace internal 3676 } // namespace internal
3669 } // namespace v8 3677 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698