diff --git a/src/compiler/backend/register-allocator.cc b/src/compiler/backend/register-allocator.cc index 3942f59bed..39aa1bf59c 100644 --- a/src/compiler/backend/register-allocator.cc +++ b/src/compiler/backend/register-allocator.cc @@ -2806,10 +2806,6 @@ LinearScanAllocator::LinearScanAllocator(RegisterAllocationData* data, next_inactive_ranges_change_(LifetimePosition::Invalid()) { active_live_ranges().reserve(8); inactive_live_ranges().reserve(8); - // TryAllocateFreeReg and AllocateBlockedReg assume this - // when allocating local arrays. - DCHECK_GE(RegisterConfiguration::kMaxFPRegisters, - this->data()->config()->num_general_registers()); } void LinearScanAllocator::AllocateRegisters() { @@ -3121,9 +3117,8 @@ void LinearScanAllocator::FindFreeRegistersForRange( // - a phi. The same analysis as in the case of the input constraint applies. // void LinearScanAllocator::ProcessCurrentRange(LiveRange* current) { - LifetimePosition free_until_pos_buff[RegisterConfiguration::kMaxFPRegisters]; - Vector<LifetimePosition> free_until_pos( - free_until_pos_buff, RegisterConfiguration::kMaxFPRegisters); + EmbeddedVector<LifetimePosition, RegisterConfiguration::kMaxRegisters> + free_until_pos; FindFreeRegistersForRange(current, free_until_pos); if (!TryAllocatePreferredReg(current, free_until_pos)) { if (current->TopLevel()->IsSplinter()) { @@ -3245,8 +3240,8 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) { // use_pos keeps track of positions a register/alias is used at. // block_pos keeps track of positions where a register/alias is blocked // from. - LifetimePosition use_pos[RegisterConfiguration::kMaxFPRegisters]; - LifetimePosition block_pos[RegisterConfiguration::kMaxFPRegisters]; + LifetimePosition use_pos[RegisterConfiguration::kMaxRegisters]; + LifetimePosition block_pos[RegisterConfiguration::kMaxRegisters]; for (int i = 0; i < num_regs; i++) { use_pos[i] = block_pos[i] = LifetimePosition::MaxPosition(); } diff --git a/src/compiler/backend/register-allocator.h b/src/compiler/backend/register-allocator.h index 579e4d3d51..3015aea695 100644 --- a/src/compiler/backend/register-allocator.h +++ b/src/compiler/backend/register-allocator.h @@ -242,11 +242,7 @@ enum class UsePositionHintType : uint8_t { kUnresolved }; -static const int32_t kUnassignedRegister = - RegisterConfiguration::kMaxGeneralRegisters; - -static_assert(kUnassignedRegister <= RegisterConfiguration::kMaxFPRegisters, - "kUnassignedRegister too small"); +static const int32_t kUnassignedRegister = RegisterConfiguration::kMaxRegisters; // Representation of a use position. class V8_EXPORT_PRIVATE UsePosition final diff --git a/src/register-configuration.h b/src/register-configuration.h index 8f0af91766..f1c2c6cbc0 100644 --- a/src/register-configuration.h +++ b/src/register-configuration.h @@ -9,6 +9,7 @@ #include "src/globals.h" #include "src/machine-type.h" #include "src/reglist.h" +#include "src/utils.h" namespace v8 { namespace internal { @@ -25,8 +26,10 @@ class V8_EXPORT_PRIVATE RegisterConfiguration { }; // Architecture independent maxes. - static const int kMaxGeneralRegisters = 32; - static const int kMaxFPRegisters = 32; + static constexpr int kMaxGeneralRegisters = 32; + static constexpr int kMaxFPRegisters = 32; + static constexpr int kMaxRegisters = + Max(kMaxFPRegisters, kMaxGeneralRegisters); // Default RegisterConfigurations for the target architecture. static const RegisterConfiguration* Default();