OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/crankshaft/x87/lithium-gap-resolver-x87.h" | 7 #include "src/crankshaft/x87/lithium-gap-resolver-x87.h" |
8 #include "src/register-configuration.h" | 8 #include "src/register-configuration.h" |
9 | 9 |
10 #include "src/crankshaft/x87/lithium-codegen-x87.h" | 10 #include "src/crankshaft/x87/lithium-codegen-x87.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 if (!moves_[i].IsEliminated() && moves_[i].source()->Equals(operand)) { | 161 if (!moves_[i].IsEliminated() && moves_[i].source()->Equals(operand)) { |
162 ++count; | 162 ++count; |
163 } | 163 } |
164 } | 164 } |
165 return count; | 165 return count; |
166 } | 166 } |
167 | 167 |
168 | 168 |
169 Register LGapResolver::GetFreeRegisterNot(Register reg) { | 169 Register LGapResolver::GetFreeRegisterNot(Register reg) { |
170 int skip_index = reg.is(no_reg) ? -1 : reg.code(); | 170 int skip_index = reg.is(no_reg) ? -1 : reg.code(); |
171 const RegisterConfiguration* config = | 171 const RegisterConfiguration* config = RegisterConfiguration::Crankshaft(); |
172 RegisterConfiguration::ArchDefault(RegisterConfiguration::CRANKSHAFT); | |
173 for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { | 172 for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { |
174 int code = config->GetAllocatableGeneralCode(i); | 173 int code = config->GetAllocatableGeneralCode(i); |
175 if (source_uses_[code] == 0 && destination_uses_[code] > 0 && | 174 if (source_uses_[code] == 0 && destination_uses_[code] > 0 && |
176 code != skip_index) { | 175 code != skip_index) { |
177 return Register::from_code(code); | 176 return Register::from_code(code); |
178 } | 177 } |
179 } | 178 } |
180 return no_reg; | 179 return no_reg; |
181 } | 180 } |
182 | 181 |
183 | 182 |
184 bool LGapResolver::HasBeenReset() { | 183 bool LGapResolver::HasBeenReset() { |
185 if (!moves_.is_empty()) return false; | 184 if (!moves_.is_empty()) return false; |
186 if (spilled_register_ >= 0) return false; | 185 if (spilled_register_ >= 0) return false; |
187 const RegisterConfiguration* config = | 186 const RegisterConfiguration* config = RegisterConfiguration::Crankshaft(); |
188 RegisterConfiguration::ArchDefault(RegisterConfiguration::CRANKSHAFT); | |
189 for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { | 187 for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { |
190 int code = config->GetAllocatableGeneralCode(i); | 188 int code = config->GetAllocatableGeneralCode(i); |
191 if (source_uses_[code] != 0) return false; | 189 if (source_uses_[code] != 0) return false; |
192 if (destination_uses_[code] != 0) return false; | 190 if (destination_uses_[code] != 0) return false; |
193 } | 191 } |
194 return true; | 192 return true; |
195 } | 193 } |
196 | 194 |
197 | 195 |
198 void LGapResolver::Verify() { | 196 void LGapResolver::Verify() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if (spilled_register_ >= 0) { | 230 if (spilled_register_ >= 0) { |
233 return Register::from_code(spilled_register_); | 231 return Register::from_code(spilled_register_); |
234 } | 232 } |
235 | 233 |
236 // 2. We may have a free register that we can use without spilling. | 234 // 2. We may have a free register that we can use without spilling. |
237 Register free = GetFreeRegisterNot(no_reg); | 235 Register free = GetFreeRegisterNot(no_reg); |
238 if (!free.is(no_reg)) return free; | 236 if (!free.is(no_reg)) return free; |
239 | 237 |
240 // 3. Prefer to spill a register that is not used in any remaining move | 238 // 3. Prefer to spill a register that is not used in any remaining move |
241 // because it will not need to be restored until the end. | 239 // because it will not need to be restored until the end. |
242 const RegisterConfiguration* config = | 240 const RegisterConfiguration* config = RegisterConfiguration::Crankshaft(); |
243 RegisterConfiguration::ArchDefault(RegisterConfiguration::CRANKSHAFT); | |
244 for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { | 241 for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { |
245 int code = config->GetAllocatableGeneralCode(i); | 242 int code = config->GetAllocatableGeneralCode(i); |
246 if (source_uses_[code] == 0 && destination_uses_[code] == 0) { | 243 if (source_uses_[code] == 0 && destination_uses_[code] == 0) { |
247 Register scratch = Register::from_code(code); | 244 Register scratch = Register::from_code(code); |
248 __ push(scratch); | 245 __ push(scratch); |
249 spilled_register_ = code; | 246 spilled_register_ = code; |
250 return scratch; | 247 return scratch; |
251 } | 248 } |
252 } | 249 } |
253 | 250 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 source_uses_[destination->index()] = CountSourceUses(destination); | 448 source_uses_[destination->index()] = CountSourceUses(destination); |
452 } | 449 } |
453 } | 450 } |
454 | 451 |
455 #undef __ | 452 #undef __ |
456 | 453 |
457 } // namespace internal | 454 } // namespace internal |
458 } // namespace v8 | 455 } // namespace v8 |
459 | 456 |
460 #endif // V8_TARGET_ARCH_X87 | 457 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |