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, 1, 1, |
48 #elif V8_TARGET_ARCH_X64 | 48 #elif V8_TARGET_ARCH_X64 |
49 kMaxAllocatableGeneralRegisterCount, | 49 kMaxAllocatableGeneralRegisterCount, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 static const int* GetAllocatableDoubleCodes() { | 97 static const int* GetAllocatableDoubleCodes() { |
98 #define REGISTER_CODE(R) DoubleRegister::kCode_##R, | 98 #define REGISTER_CODE(R) DoubleRegister::kCode_##R, |
99 static const int double_codes[] = { | 99 static const int double_codes[] = { |
100 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_CODE)}; | 100 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_CODE)}; |
101 #undef REGISTER_CODE | 101 #undef REGISTER_CODE |
102 return double_codes; | 102 return double_codes; |
103 } | 103 } |
104 }; | 104 }; |
105 | 105 |
106 | 106 |
107 static base::LazyInstance<ArchDefaultRegisterConfiguration>::type | 107 template <RegisterConfiguration::CompilerSelector compiler> |
108 kDefaultRegisterConfiguration = LAZY_INSTANCE_INITIALIZER; | 108 struct RegisterConfigurationInitializer { |
| 109 static void Construct(ArchDefaultRegisterConfiguration* config) { |
| 110 new (config) ArchDefaultRegisterConfiguration(compiler); |
| 111 } |
| 112 }; |
| 113 |
| 114 static base::LazyInstance< |
| 115 ArchDefaultRegisterConfiguration, |
| 116 RegisterConfigurationInitializer<RegisterConfiguration::CRANKSHAFT>>::type |
| 117 kDefaultRegisterConfigurationForCrankshaft = LAZY_INSTANCE_INITIALIZER; |
| 118 |
| 119 |
| 120 static base::LazyInstance< |
| 121 ArchDefaultRegisterConfiguration, |
| 122 RegisterConfigurationInitializer<RegisterConfiguration::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 CompilerSelector 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 |