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

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

Issue 1518573002: RegisterAllocator: Clean up before adding aliasing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. 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
« no previous file with comments | « src/compiler/register-allocator.h ('k') | src/register-configuration.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 1393
1394 RegisterAllocationData::RegisterAllocationData( 1394 RegisterAllocationData::RegisterAllocationData(
1395 const RegisterConfiguration* config, Zone* zone, Frame* frame, 1395 const RegisterConfiguration* config, Zone* zone, Frame* frame,
1396 InstructionSequence* code, const char* debug_name) 1396 InstructionSequence* code, const char* debug_name)
1397 : allocation_zone_(zone), 1397 : allocation_zone_(zone),
1398 frame_(frame), 1398 frame_(frame),
1399 code_(code), 1399 code_(code),
1400 debug_name_(debug_name), 1400 debug_name_(debug_name),
1401 config_(config), 1401 config_(config),
1402 phi_map_(allocation_zone()), 1402 phi_map_(allocation_zone()),
1403 allocatable_codes_(this->config()->num_general_registers(), -1,
1404 allocation_zone()),
1405 allocatable_double_codes_(this->config()->num_double_registers(), -1,
1406 allocation_zone()),
1407 live_in_sets_(code->InstructionBlockCount(), nullptr, allocation_zone()), 1403 live_in_sets_(code->InstructionBlockCount(), nullptr, allocation_zone()),
1408 live_out_sets_(code->InstructionBlockCount(), nullptr, allocation_zone()), 1404 live_out_sets_(code->InstructionBlockCount(), nullptr, allocation_zone()),
1409 live_ranges_(code->VirtualRegisterCount() * 2, nullptr, 1405 live_ranges_(code->VirtualRegisterCount() * 2, nullptr,
1410 allocation_zone()), 1406 allocation_zone()),
1411 fixed_live_ranges_(this->config()->num_general_registers(), nullptr, 1407 fixed_live_ranges_(this->config()->num_general_registers(), nullptr,
1412 allocation_zone()), 1408 allocation_zone()),
1413 fixed_double_live_ranges_(this->config()->num_double_registers(), nullptr, 1409 fixed_double_live_ranges_(this->config()->num_double_registers(), nullptr,
1414 allocation_zone()), 1410 allocation_zone()),
1415 spill_ranges_(code->VirtualRegisterCount(), nullptr, allocation_zone()), 1411 spill_ranges_(code->VirtualRegisterCount(), nullptr, allocation_zone()),
1416 delayed_references_(allocation_zone()), 1412 delayed_references_(allocation_zone()),
1417 assigned_registers_(nullptr), 1413 assigned_registers_(nullptr),
1418 assigned_double_registers_(nullptr), 1414 assigned_double_registers_(nullptr),
1419 virtual_register_count_(code->VirtualRegisterCount()), 1415 virtual_register_count_(code->VirtualRegisterCount()),
1420 preassigned_slot_ranges_(zone) { 1416 preassigned_slot_ranges_(zone) {
1421 DCHECK(this->config()->num_general_registers() <=
1422 RegisterConfiguration::kMaxGeneralRegisters);
1423 DCHECK(this->config()->num_double_registers() <=
1424 RegisterConfiguration::kMaxDoubleRegisters);
1425 assigned_registers_ = new (code_zone()) 1417 assigned_registers_ = new (code_zone())
1426 BitVector(this->config()->num_general_registers(), code_zone()); 1418 BitVector(this->config()->num_general_registers(), code_zone());
1427 assigned_double_registers_ = new (code_zone()) 1419 assigned_double_registers_ = new (code_zone())
1428 BitVector(this->config()->num_double_registers(), code_zone()); 1420 BitVector(this->config()->num_double_registers(), code_zone());
1429 this->frame()->SetAllocatedRegisters(assigned_registers_); 1421 this->frame()->SetAllocatedRegisters(assigned_registers_);
1430 this->frame()->SetAllocatedDoubleRegisters(assigned_double_registers_); 1422 this->frame()->SetAllocatedDoubleRegisters(assigned_double_registers_);
1431 } 1423 }
1432 1424
1433 1425
1434 MoveOperands* RegisterAllocationData::AddGapMove( 1426 MoveOperands* RegisterAllocationData::AddGapMove(
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 : RegisterAllocator(data, kind), 2601 : RegisterAllocator(data, kind),
2610 unhandled_live_ranges_(local_zone), 2602 unhandled_live_ranges_(local_zone),
2611 active_live_ranges_(local_zone), 2603 active_live_ranges_(local_zone),
2612 inactive_live_ranges_(local_zone) { 2604 inactive_live_ranges_(local_zone) {
2613 unhandled_live_ranges().reserve( 2605 unhandled_live_ranges().reserve(
2614 static_cast<size_t>(code()->VirtualRegisterCount() * 2)); 2606 static_cast<size_t>(code()->VirtualRegisterCount() * 2));
2615 active_live_ranges().reserve(8); 2607 active_live_ranges().reserve(8);
2616 inactive_live_ranges().reserve(8); 2608 inactive_live_ranges().reserve(8);
2617 // TryAllocateFreeReg and AllocateBlockedReg assume this 2609 // TryAllocateFreeReg and AllocateBlockedReg assume this
2618 // when allocating local arrays. 2610 // when allocating local arrays.
2619 DCHECK(RegisterConfiguration::kMaxDoubleRegisters >= 2611 DCHECK(RegisterConfiguration::kMaxFPRegisters >=
2620 this->data()->config()->num_general_registers()); 2612 this->data()->config()->num_general_registers());
2621 } 2613 }
2622 2614
2623 2615
2624 void LinearScanAllocator::AllocateRegisters() { 2616 void LinearScanAllocator::AllocateRegisters() {
2625 DCHECK(unhandled_live_ranges().empty()); 2617 DCHECK(unhandled_live_ranges().empty());
2626 DCHECK(active_live_ranges().empty()); 2618 DCHECK(active_live_ranges().empty());
2627 DCHECK(inactive_live_ranges().empty()); 2619 DCHECK(inactive_live_ranges().empty());
2628 2620
2629 SplitAndSpillRangesDefinedByMemoryOperand(code()->VirtualRegisterCount() <= 2621 SplitAndSpillRangesDefinedByMemoryOperand(code()->VirtualRegisterCount() <=
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2806 2798
2807 void LinearScanAllocator::InactiveToActive(LiveRange* range) { 2799 void LinearScanAllocator::InactiveToActive(LiveRange* range) {
2808 RemoveElement(&inactive_live_ranges(), range); 2800 RemoveElement(&inactive_live_ranges(), range);
2809 active_live_ranges().push_back(range); 2801 active_live_ranges().push_back(range);
2810 TRACE("Moving live range %d:%d from inactive to active\n", 2802 TRACE("Moving live range %d:%d from inactive to active\n",
2811 range->TopLevel()->vreg(), range->relative_id()); 2803 range->TopLevel()->vreg(), range->relative_id());
2812 } 2804 }
2813 2805
2814 2806
2815 bool LinearScanAllocator::TryAllocateFreeReg(LiveRange* current) { 2807 bool LinearScanAllocator::TryAllocateFreeReg(LiveRange* current) {
2816 LifetimePosition free_until_pos[RegisterConfiguration::kMaxDoubleRegisters]; 2808 LifetimePosition free_until_pos[RegisterConfiguration::kMaxFPRegisters];
2817 2809
2818 for (int i = 0; i < num_registers(); i++) { 2810 for (int i = 0; i < num_registers(); i++) {
2819 free_until_pos[i] = LifetimePosition::MaxPosition(); 2811 free_until_pos[i] = LifetimePosition::MaxPosition();
2820 } 2812 }
2821 2813
2822 for (LiveRange* cur_active : active_live_ranges()) { 2814 for (LiveRange* cur_active : active_live_ranges()) {
2823 free_until_pos[cur_active->assigned_register()] = 2815 free_until_pos[cur_active->assigned_register()] =
2824 LifetimePosition::GapFromInstructionIndex(0); 2816 LifetimePosition::GapFromInstructionIndex(0);
2825 TRACE("Register %s is free until pos %d (1)\n", 2817 TRACE("Register %s is free until pos %d (1)\n",
2826 RegisterName(cur_active->assigned_register()), 2818 RegisterName(cur_active->assigned_register()),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2892 2884
2893 void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) { 2885 void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) {
2894 UsePosition* register_use = current->NextRegisterPosition(current->Start()); 2886 UsePosition* register_use = current->NextRegisterPosition(current->Start());
2895 if (register_use == nullptr) { 2887 if (register_use == nullptr) {
2896 // There is no use in the current live range that requires a register. 2888 // There is no use in the current live range that requires a register.
2897 // We can just spill it. 2889 // We can just spill it.
2898 Spill(current); 2890 Spill(current);
2899 return; 2891 return;
2900 } 2892 }
2901 2893
2902 LifetimePosition use_pos[RegisterConfiguration::kMaxDoubleRegisters]; 2894 LifetimePosition use_pos[RegisterConfiguration::kMaxFPRegisters];
2903 LifetimePosition block_pos[RegisterConfiguration::kMaxDoubleRegisters]; 2895 LifetimePosition block_pos[RegisterConfiguration::kMaxFPRegisters];
2904 2896
2905 for (int i = 0; i < num_registers(); i++) { 2897 for (int i = 0; i < num_registers(); i++) {
2906 use_pos[i] = block_pos[i] = LifetimePosition::MaxPosition(); 2898 use_pos[i] = block_pos[i] = LifetimePosition::MaxPosition();
2907 } 2899 }
2908 2900
2909 for (LiveRange* range : active_live_ranges()) { 2901 for (LiveRange* range : active_live_ranges()) {
2910 int cur_reg = range->assigned_register(); 2902 int cur_reg = range->assigned_register();
2911 if (range->TopLevel()->IsFixed() || 2903 if (range->TopLevel()->IsFixed() ||
2912 !range->CanBeSpilled(current->Start())) { 2904 !range->CanBeSpilled(current->Start())) {
2913 block_pos[cur_reg] = use_pos[cur_reg] = 2905 block_pos[cur_reg] = use_pos[cur_reg] =
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
3667 } 3659 }
3668 } 3660 }
3669 } 3661 }
3670 } 3662 }
3671 } 3663 }
3672 3664
3673 3665
3674 } // namespace compiler 3666 } // namespace compiler
3675 } // namespace internal 3667 } // namespace internal
3676 } // namespace v8 3668 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/register-allocator.h ('k') | src/register-configuration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698