| 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(JITCompiler 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 <JITCompiler 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<ArchDefaultRegisterConfiguration, |
| 117 RegisterConfigurationInitializer<CRANKSHAFT>>::type |
| 118 kDefaultRegisterConfigurationForCrankshaft = LAZY_INSTANCE_INITIALIZER; |
| 119 |
| 120 |
| 121 static base::LazyInstance<ArchDefaultRegisterConfiguration, |
| 122 RegisterConfigurationInitializer<TURBOFAN>>::type |
| 123 kDefaultRegisterConfigurationForTurboFan = LAZY_INSTANCE_INITIALIZER; |
| 109 | 124 |
| 110 } // namespace | 125 } // namespace |
| 111 | 126 |
| 112 | 127 |
| 113 const RegisterConfiguration* RegisterConfiguration::ArchDefault() { | 128 const RegisterConfiguration* RegisterConfiguration::ArchDefault( |
| 114 return &kDefaultRegisterConfiguration.Get(); | 129 JITCompiler compiler) { |
| 130 return compiler == TURBOFAN |
| 131 ? &kDefaultRegisterConfigurationForTurboFan.Get() |
| 132 : &kDefaultRegisterConfigurationForCrankshaft.Get(); |
| 115 } | 133 } |
| 116 | 134 |
| 135 |
| 117 RegisterConfiguration::RegisterConfiguration( | 136 RegisterConfiguration::RegisterConfiguration( |
| 118 int num_general_registers, int num_double_registers, | 137 int num_general_registers, int num_double_registers, |
| 119 int num_allocatable_general_registers, int num_allocatable_double_registers, | 138 int num_allocatable_general_registers, int num_allocatable_double_registers, |
| 120 int num_allocatable_aliased_double_registers, | 139 int num_allocatable_aliased_double_registers, |
| 121 const int* allocatable_general_codes, const int* allocatable_double_codes, | 140 const int* allocatable_general_codes, const int* allocatable_double_codes, |
| 122 const char* const* general_register_names, | 141 const char* const* general_register_names, |
| 123 const char* const* double_register_names) | 142 const char* const* double_register_names) |
| 124 : num_general_registers_(num_general_registers), | 143 : num_general_registers_(num_general_registers), |
| 125 num_double_registers_(num_double_registers), | 144 num_double_registers_(num_double_registers), |
| 126 num_allocatable_general_registers_(num_allocatable_general_registers), | 145 num_allocatable_general_registers_(num_allocatable_general_registers), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 138 } | 157 } |
| 139 for (int i = 0; i < num_allocatable_double_registers_; ++i) { | 158 for (int i = 0; i < num_allocatable_double_registers_; ++i) { |
| 140 allocatable_double_codes_mask_ |= (1 << allocatable_double_codes_[i]); | 159 allocatable_double_codes_mask_ |= (1 << allocatable_double_codes_[i]); |
| 141 } | 160 } |
| 142 } | 161 } |
| 143 | 162 |
| 144 #undef REGISTER_COUNT | 163 #undef REGISTER_COUNT |
| 145 | 164 |
| 146 } // namespace internal | 165 } // namespace internal |
| 147 } // namespace v8 | 166 } // namespace v8 |
| OLD | NEW |