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

Side by Side Diff: src/crankshaft/lithium-allocator.cc

Issue 2092413002: [RegisterConfiguration] Streamline access to arch defaults, simplify Registers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile. Created 4 years, 5 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/crankshaft/lithium.cc ('k') | src/crankshaft/mips/lithium-codegen-mips.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/crankshaft/lithium-allocator.h" 5 #include "src/crankshaft/lithium-allocator.h"
6 6
7 #include "src/crankshaft/hydrogen.h" 7 #include "src/crankshaft/hydrogen.h"
8 #include "src/crankshaft/lithium-inl.h" 8 #include "src/crankshaft/lithium-inl.h"
9 #include "src/crankshaft/lithium-allocator-inl.h" 9 #include "src/crankshaft/lithium-allocator-inl.h"
10 #include "src/register-configuration.h" 10 #include "src/register-configuration.h"
11 #include "src/string-stream.h" 11 #include "src/string-stream.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 const auto GetRegConfig = RegisterConfiguration::Crankshaft;
17
16 static inline LifetimePosition Min(LifetimePosition a, LifetimePosition b) { 18 static inline LifetimePosition Min(LifetimePosition a, LifetimePosition b) {
17 return a.Value() < b.Value() ? a : b; 19 return a.Value() < b.Value() ? a : b;
18 } 20 }
19 21
20 22
21 static inline LifetimePosition Max(LifetimePosition a, LifetimePosition b) { 23 static inline LifetimePosition Max(LifetimePosition a, LifetimePosition b) {
22 return a.Value() > b.Value() ? a : b; 24 return a.Value() > b.Value() ? a : b;
23 } 25 }
24 26
25 27
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 LOperand* output = instr->Output(); 935 LOperand* output = instr->Output();
934 if (output != NULL) { 936 if (output != NULL) {
935 if (output->IsUnallocated()) { 937 if (output->IsUnallocated()) {
936 live->Remove(LUnallocated::cast(output)->virtual_register()); 938 live->Remove(LUnallocated::cast(output)->virtual_register());
937 } 939 }
938 Define(curr_position, output, NULL); 940 Define(curr_position, output, NULL);
939 } 941 }
940 942
941 if (instr->ClobbersRegisters()) { 943 if (instr->ClobbersRegisters()) {
942 for (int i = 0; i < Register::kNumRegisters; ++i) { 944 for (int i = 0; i < Register::kNumRegisters; ++i) {
943 if (Register::from_code(i).IsAllocatable()) { 945 if (GetRegConfig()->IsAllocatableGeneralCode(i)) {
944 if (output == NULL || !output->IsRegister() || 946 if (output == NULL || !output->IsRegister() ||
945 output->index() != i) { 947 output->index() != i) {
946 LiveRange* range = FixedLiveRangeFor(i); 948 LiveRange* range = FixedLiveRangeFor(i);
947 range->AddUseInterval(curr_position, 949 range->AddUseInterval(curr_position,
948 curr_position.InstructionEnd(), zone()); 950 curr_position.InstructionEnd(), zone());
949 } 951 }
950 } 952 }
951 } 953 }
952 } 954 }
953 955
954 if (instr->ClobbersDoubleRegisters(isolate())) { 956 if (instr->ClobbersDoubleRegisters(isolate())) {
955 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) { 957 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) {
956 if (DoubleRegister::from_code(i).IsAllocatable()) { 958 if (GetRegConfig()->IsAllocatableDoubleCode(i)) {
957 if (output == NULL || !output->IsDoubleRegister() || 959 if (output == NULL || !output->IsDoubleRegister() ||
958 output->index() != i) { 960 output->index() != i) {
959 LiveRange* range = FixedDoubleLiveRangeFor(i); 961 LiveRange* range = FixedDoubleLiveRangeFor(i);
960 range->AddUseInterval(curr_position, 962 range->AddUseInterval(curr_position,
961 curr_position.InstructionEnd(), zone()); 963 curr_position.InstructionEnd(), zone());
962 } 964 }
963 } 965 }
964 } 966 }
965 } 967 }
966 968
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 DCHECK(!operand->IsStackSlot()); 1455 DCHECK(!operand->IsStackSlot());
1454 map->RecordPointer(operand, chunk()->zone()); 1456 map->RecordPointer(operand, chunk()->zone());
1455 } 1457 }
1456 } 1458 }
1457 } 1459 }
1458 } 1460 }
1459 1461
1460 1462
1461 void LAllocator::AllocateGeneralRegisters() { 1463 void LAllocator::AllocateGeneralRegisters() {
1462 LAllocatorPhase phase("L_Allocate general registers", this); 1464 LAllocatorPhase phase("L_Allocate general registers", this);
1463 num_registers_ = 1465 num_registers_ = GetRegConfig()->num_allocatable_general_registers();
1464 RegisterConfiguration::ArchDefault(RegisterConfiguration::CRANKSHAFT) 1466 allocatable_register_codes_ = GetRegConfig()->allocatable_general_codes();
1465 ->num_allocatable_general_registers();
1466 allocatable_register_codes_ =
1467 RegisterConfiguration::ArchDefault(RegisterConfiguration::CRANKSHAFT)
1468 ->allocatable_general_codes();
1469 mode_ = GENERAL_REGISTERS; 1467 mode_ = GENERAL_REGISTERS;
1470 AllocateRegisters(); 1468 AllocateRegisters();
1471 } 1469 }
1472 1470
1473 1471
1474 void LAllocator::AllocateDoubleRegisters() { 1472 void LAllocator::AllocateDoubleRegisters() {
1475 LAllocatorPhase phase("L_Allocate double registers", this); 1473 LAllocatorPhase phase("L_Allocate double registers", this);
1476 num_registers_ = 1474 num_registers_ = GetRegConfig()->num_allocatable_double_registers();
1477 RegisterConfiguration::ArchDefault(RegisterConfiguration::CRANKSHAFT) 1475 allocatable_register_codes_ = GetRegConfig()->allocatable_double_codes();
1478 ->num_allocatable_double_registers();
1479 allocatable_register_codes_ =
1480 RegisterConfiguration::ArchDefault(RegisterConfiguration::CRANKSHAFT)
1481 ->allocatable_double_codes();
1482 mode_ = DOUBLE_REGISTERS; 1476 mode_ = DOUBLE_REGISTERS;
1483 AllocateRegisters(); 1477 AllocateRegisters();
1484 } 1478 }
1485 1479
1486 1480
1487 void LAllocator::AllocateRegisters() { 1481 void LAllocator::AllocateRegisters() {
1488 DCHECK(unhandled_live_ranges_.is_empty()); 1482 DCHECK(unhandled_live_ranges_.is_empty());
1489 1483
1490 for (int i = 0; i < live_ranges_.length(); ++i) { 1484 for (int i = 0; i < live_ranges_.length(); ++i) {
1491 if (live_ranges_[i] != NULL) { 1485 if (live_ranges_[i] != NULL) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 } 1583 }
1590 1584
1591 reusable_slots_.Rewind(0); 1585 reusable_slots_.Rewind(0);
1592 active_live_ranges_.Rewind(0); 1586 active_live_ranges_.Rewind(0);
1593 inactive_live_ranges_.Rewind(0); 1587 inactive_live_ranges_.Rewind(0);
1594 } 1588 }
1595 1589
1596 1590
1597 const char* LAllocator::RegisterName(int allocation_index) { 1591 const char* LAllocator::RegisterName(int allocation_index) {
1598 if (mode_ == GENERAL_REGISTERS) { 1592 if (mode_ == GENERAL_REGISTERS) {
1599 return Register::from_code(allocation_index).ToString(); 1593 return GetRegConfig()->GetGeneralRegisterName(allocation_index);
1600 } else { 1594 } else {
1601 return DoubleRegister::from_code(allocation_index).ToString(); 1595 return GetRegConfig()->GetDoubleRegisterName(allocation_index);
1602 } 1596 }
1603 } 1597 }
1604 1598
1605 1599
1606 void LAllocator::TraceAlloc(const char* msg, ...) { 1600 void LAllocator::TraceAlloc(const char* msg, ...) {
1607 if (FLAG_trace_alloc) { 1601 if (FLAG_trace_alloc) {
1608 va_list arguments; 1602 va_list arguments;
1609 va_start(arguments, msg); 1603 va_start(arguments, msg);
1610 base::OS::VPrint(msg, arguments); 1604 base::OS::VPrint(msg, arguments);
1611 va_end(arguments); 1605 va_end(arguments);
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 } 2182 }
2189 2183
2190 #ifdef DEBUG 2184 #ifdef DEBUG
2191 if (allocator_ != NULL) allocator_->Verify(); 2185 if (allocator_ != NULL) allocator_->Verify();
2192 #endif 2186 #endif
2193 } 2187 }
2194 2188
2195 2189
2196 } // namespace internal 2190 } // namespace internal
2197 } // namespace v8 2191 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/lithium.cc ('k') | src/crankshaft/mips/lithium-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698