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

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

Issue 1205173002: [turbofan] Greedy allocator refactoring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 range->Spill(); 1845 range->Spill();
1846 } 1846 }
1847 1847
1848 1848
1849 const ZoneVector<LiveRange*>& RegisterAllocator::GetFixedRegisters() const { 1849 const ZoneVector<LiveRange*>& RegisterAllocator::GetFixedRegisters() const {
1850 return mode() == DOUBLE_REGISTERS ? data()->fixed_double_live_ranges() 1850 return mode() == DOUBLE_REGISTERS ? data()->fixed_double_live_ranges()
1851 : data()->fixed_live_ranges(); 1851 : data()->fixed_live_ranges();
1852 } 1852 }
1853 1853
1854 1854
1855 const char* RegisterAllocator::RegisterName(int allocation_index) const {
1856 if (mode() == GENERAL_REGISTERS) {
1857 return data()->config()->general_register_name(allocation_index);
1858 } else {
1859 return data()->config()->double_register_name(allocation_index);
1860 }
1861 }
1862
1863
1855 LinearScanAllocator::LinearScanAllocator(RegisterAllocationData* data, 1864 LinearScanAllocator::LinearScanAllocator(RegisterAllocationData* data,
1856 RegisterKind kind, Zone* local_zone) 1865 RegisterKind kind, Zone* local_zone)
1857 : RegisterAllocator(data, kind), 1866 : RegisterAllocator(data, kind),
1858 unhandled_live_ranges_(local_zone), 1867 unhandled_live_ranges_(local_zone),
1859 active_live_ranges_(local_zone), 1868 active_live_ranges_(local_zone),
1860 inactive_live_ranges_(local_zone) { 1869 inactive_live_ranges_(local_zone) {
1861 unhandled_live_ranges().reserve( 1870 unhandled_live_ranges().reserve(
1862 static_cast<size_t>(code()->VirtualRegisterCount() * 2)); 1871 static_cast<size_t>(code()->VirtualRegisterCount() * 2));
1863 active_live_ranges().reserve(8); 1872 active_live_ranges().reserve(8);
1864 inactive_live_ranges().reserve(8); 1873 inactive_live_ranges().reserve(8);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 1960
1952 bool result = TryAllocateFreeReg(current); 1961 bool result = TryAllocateFreeReg(current);
1953 if (!result) AllocateBlockedReg(current); 1962 if (!result) AllocateBlockedReg(current);
1954 if (current->HasRegisterAssigned()) { 1963 if (current->HasRegisterAssigned()) {
1955 AddToActive(current); 1964 AddToActive(current);
1956 } 1965 }
1957 } 1966 }
1958 } 1967 }
1959 1968
1960 1969
1961 const char* LinearScanAllocator::RegisterName(int allocation_index) const {
1962 if (mode() == GENERAL_REGISTERS) {
1963 return data()->config()->general_register_name(allocation_index);
1964 } else {
1965 return data()->config()->double_register_name(allocation_index);
1966 }
1967 }
1968
1969
1970 void LinearScanAllocator::SetLiveRangeAssignedRegister(LiveRange* range, 1970 void LinearScanAllocator::SetLiveRangeAssignedRegister(LiveRange* range,
1971 int reg) { 1971 int reg) {
1972 data()->MarkAllocated(range->kind(), reg); 1972 data()->MarkAllocated(range->kind(), reg);
1973 range->set_assigned_register(reg); 1973 range->set_assigned_register(reg);
1974 range->SetUseHints(reg); 1974 range->SetUseHints(reg);
1975 if (range->is_phi()) { 1975 if (range->is_phi()) {
1976 data()->GetPhiMapValueFor(range->id())->set_assigned_register(reg); 1976 data()->GetPhiMapValueFor(range->id())->set_assigned_register(reg);
1977 } 1977 }
1978 } 1978 }
1979 1979
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
2861 auto eliminate = moves->PrepareInsertAfter(move); 2861 auto eliminate = moves->PrepareInsertAfter(move);
2862 to_insert.push_back(move); 2862 to_insert.push_back(move);
2863 if (eliminate != nullptr) to_eliminate.push_back(eliminate); 2863 if (eliminate != nullptr) to_eliminate.push_back(eliminate);
2864 } 2864 }
2865 } 2865 }
2866 2866
2867 2867
2868 } // namespace compiler 2868 } // namespace compiler
2869 } // namespace internal 2869 } // namespace internal
2870 } // namespace v8 2870 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698