| OLD | NEW |
| 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/register-configuration.h" | 5 #include "src/register-configuration.h" |
| 6 #include "src/globals.h" | 6 #include "src/globals.h" |
| 7 #include "src/macro-assembler.h" | 7 #include "src/macro-assembler.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #undef REGISTER_NAME | 29 #undef REGISTER_NAME |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 STATIC_ASSERT(RegisterConfiguration::kMaxGeneralRegisters >= | 32 STATIC_ASSERT(RegisterConfiguration::kMaxGeneralRegisters >= |
| 33 Register::kNumRegisters); | 33 Register::kNumRegisters); |
| 34 STATIC_ASSERT(RegisterConfiguration::kMaxDoubleRegisters >= | 34 STATIC_ASSERT(RegisterConfiguration::kMaxDoubleRegisters >= |
| 35 DoubleRegister::kMaxNumRegisters); | 35 DoubleRegister::kMaxNumRegisters); |
| 36 | 36 |
| 37 class ArchDefaultRegisterConfiguration : public RegisterConfiguration { | 37 class ArchDefaultRegisterConfiguration : public RegisterConfiguration { |
| 38 public: | 38 public: |
| 39 ArchDefaultRegisterConfiguration() | 39 explicit ArchDefaultRegisterConfiguration(CompilerSelector compiler) |
| 40 : RegisterConfiguration( | 40 : RegisterConfiguration( |
| 41 Register::kNumRegisters, DoubleRegister::kMaxNumRegisters, | 41 Register::kNumRegisters, DoubleRegister::kMaxNumRegisters, |
| 42 #if V8_TARGET_ARCH_IA32 | 42 #if V8_TARGET_ARCH_IA32 |
| 43 kMaxAllocatableGeneralRegisterCount, | 43 kMaxAllocatableGeneralRegisterCount, |
| 44 kMaxAllocatableDoubleRegisterCount, | 44 kMaxAllocatableDoubleRegisterCount, |
| 45 kMaxAllocatableDoubleRegisterCount, | 45 kMaxAllocatableDoubleRegisterCount, |
| 46 #elif V8_TARGET_ARCH_X87 | 46 #elif V8_TARGET_ARCH_X87 |
| 47 kMaxAllocatableGeneralRegisterCount, 1, 1, | 47 kMaxAllocatableGeneralRegisterCount, |
| 48 compiler == TURBOFAN ? 1 : kMaxAllocatableDoubleRegisterCount, |
| 49 compiler == TURBOFAN ? 1 : kMaxAllocatableDoubleRegisterCount, |
| 48 #elif V8_TARGET_ARCH_X64 | 50 #elif V8_TARGET_ARCH_X64 |
| 49 kMaxAllocatableGeneralRegisterCount, | 51 kMaxAllocatableGeneralRegisterCount, |
| 50 kMaxAllocatableDoubleRegisterCount, | 52 kMaxAllocatableDoubleRegisterCount, |
| 51 kMaxAllocatableDoubleRegisterCount, | 53 kMaxAllocatableDoubleRegisterCount, |
| 52 #elif V8_TARGET_ARCH_ARM | 54 #elif V8_TARGET_ARCH_ARM |
| 53 FLAG_enable_embedded_constant_pool | 55 FLAG_enable_embedded_constant_pool |
| 54 ? (kMaxAllocatableGeneralRegisterCount - 1) | 56 ? (kMaxAllocatableGeneralRegisterCount - 1) |
| 55 : kMaxAllocatableGeneralRegisterCount, | 57 : kMaxAllocatableGeneralRegisterCount, |
| 56 CpuFeatures::IsSupported(VFP32DREGS) | 58 CpuFeatures::IsSupported(VFP32DREGS) |
| 57 ? kMaxAllocatableDoubleRegisterCount | 59 ? kMaxAllocatableDoubleRegisterCount |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 static const int* GetAllocatableDoubleCodes() { | 99 static const int* GetAllocatableDoubleCodes() { |
| 98 #define REGISTER_CODE(R) DoubleRegister::kCode_##R, | 100 #define REGISTER_CODE(R) DoubleRegister::kCode_##R, |
| 99 static const int double_codes[] = { | 101 static const int double_codes[] = { |
| 100 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_CODE)}; | 102 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_CODE)}; |
| 101 #undef REGISTER_CODE | 103 #undef REGISTER_CODE |
| 102 return double_codes; | 104 return double_codes; |
| 103 } | 105 } |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 | 108 |
| 107 static base::LazyInstance<ArchDefaultRegisterConfiguration>::type | 109 template <RegisterConfiguration::CompilerSelector compiler> |
| 108 kDefaultRegisterConfiguration = LAZY_INSTANCE_INITIALIZER; | 110 struct RegisterConfigurationInitializer { |
| 111 static void Construct(ArchDefaultRegisterConfiguration* config) { |
| 112 new (config) ArchDefaultRegisterConfiguration(compiler); |
| 113 } |
| 114 }; |
| 115 |
| 116 static base::LazyInstance< |
| 117 ArchDefaultRegisterConfiguration, |
| 118 RegisterConfigurationInitializer<RegisterConfiguration::CRANKSHAFT>>::type |
| 119 kDefaultRegisterConfigurationForCrankshaft = LAZY_INSTANCE_INITIALIZER; |
| 120 |
| 121 |
| 122 static base::LazyInstance< |
| 123 ArchDefaultRegisterConfiguration, |
| 124 RegisterConfigurationInitializer<RegisterConfiguration::TURBOFAN>>::type |
| 125 kDefaultRegisterConfigurationForTurboFan = LAZY_INSTANCE_INITIALIZER; |
| 109 | 126 |
| 110 } // namespace | 127 } // namespace |
| 111 | 128 |
| 112 | 129 |
| 113 const RegisterConfiguration* RegisterConfiguration::ArchDefault() { | 130 const RegisterConfiguration* RegisterConfiguration::ArchDefault( |
| 114 return &kDefaultRegisterConfiguration.Get(); | 131 CompilerSelector compiler) { |
| 132 return compiler == TURBOFAN |
| 133 ? &kDefaultRegisterConfigurationForTurboFan.Get() |
| 134 : &kDefaultRegisterConfigurationForCrankshaft.Get(); |
| 115 } | 135 } |
| 116 | 136 |
| 137 |
| 117 RegisterConfiguration::RegisterConfiguration( | 138 RegisterConfiguration::RegisterConfiguration( |
| 118 int num_general_registers, int num_double_registers, | 139 int num_general_registers, int num_double_registers, |
| 119 int num_allocatable_general_registers, int num_allocatable_double_registers, | 140 int num_allocatable_general_registers, int num_allocatable_double_registers, |
| 120 int num_allocatable_aliased_double_registers, | 141 int num_allocatable_aliased_double_registers, |
| 121 const int* allocatable_general_codes, const int* allocatable_double_codes, | 142 const int* allocatable_general_codes, const int* allocatable_double_codes, |
| 122 const char* const* general_register_names, | 143 const char* const* general_register_names, |
| 123 const char* const* double_register_names) | 144 const char* const* double_register_names) |
| 124 : num_general_registers_(num_general_registers), | 145 : num_general_registers_(num_general_registers), |
| 125 num_double_registers_(num_double_registers), | 146 num_double_registers_(num_double_registers), |
| 126 num_allocatable_general_registers_(num_allocatable_general_registers), | 147 num_allocatable_general_registers_(num_allocatable_general_registers), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 138 } | 159 } |
| 139 for (int i = 0; i < num_allocatable_double_registers_; ++i) { | 160 for (int i = 0; i < num_allocatable_double_registers_; ++i) { |
| 140 allocatable_double_codes_mask_ |= (1 << allocatable_double_codes_[i]); | 161 allocatable_double_codes_mask_ |= (1 << allocatable_double_codes_[i]); |
| 141 } | 162 } |
| 142 } | 163 } |
| 143 | 164 |
| 144 #undef REGISTER_COUNT | 165 #undef REGISTER_COUNT |
| 145 | 166 |
| 146 } // namespace internal | 167 } // namespace internal |
| 147 } // namespace v8 | 168 } // namespace v8 |
| OLD | NEW |