| 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/base/adapters.h" | 5 #include "src/base/adapters.h" |
| 6 #include "src/compiler/linkage.h" | 6 #include "src/compiler/linkage.h" |
| 7 #include "src/compiler/register-allocator.h" | 7 #include "src/compiler/register-allocator.h" |
| 8 #include "src/string-stream.h" | 8 #include "src/string-stream.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 3157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3168 } | 3168 } |
| 3169 | 3169 |
| 3170 int num_regs = num_registers(); | 3170 int num_regs = num_registers(); |
| 3171 int num_codes = num_allocatable_registers(); | 3171 int num_codes = num_allocatable_registers(); |
| 3172 const int* codes = allocatable_register_codes(); | 3172 const int* codes = allocatable_register_codes(); |
| 3173 MachineRepresentation rep = current->representation(); | 3173 MachineRepresentation rep = current->representation(); |
| 3174 if (!kSimpleFPAliasing && (rep == MachineRepresentation::kFloat32 || | 3174 if (!kSimpleFPAliasing && (rep == MachineRepresentation::kFloat32 || |
| 3175 rep == MachineRepresentation::kSimd128)) | 3175 rep == MachineRepresentation::kSimd128)) |
| 3176 GetFPRegisterSet(rep, &num_regs, &num_codes, &codes); | 3176 GetFPRegisterSet(rep, &num_regs, &num_codes, &codes); |
| 3177 | 3177 |
| 3178 // use_pos keeps track of positions a register/alias is used at. |
| 3179 // block_pos keeps track of positions where a register/alias is blocked |
| 3180 // from. |
| 3178 LifetimePosition use_pos[RegisterConfiguration::kMaxFPRegisters]; | 3181 LifetimePosition use_pos[RegisterConfiguration::kMaxFPRegisters]; |
| 3179 LifetimePosition block_pos[RegisterConfiguration::kMaxFPRegisters]; | 3182 LifetimePosition block_pos[RegisterConfiguration::kMaxFPRegisters]; |
| 3180 for (int i = 0; i < num_regs; i++) { | 3183 for (int i = 0; i < num_regs; i++) { |
| 3181 use_pos[i] = block_pos[i] = LifetimePosition::MaxPosition(); | 3184 use_pos[i] = block_pos[i] = LifetimePosition::MaxPosition(); |
| 3182 } | 3185 } |
| 3183 | 3186 |
| 3184 for (LiveRange* range : active_live_ranges()) { | 3187 for (LiveRange* range : active_live_ranges()) { |
| 3185 int cur_reg = range->assigned_register(); | 3188 int cur_reg = range->assigned_register(); |
| 3186 bool is_fixed_or_cant_spill = | 3189 bool is_fixed_or_cant_spill = |
| 3187 range->TopLevel()->IsFixed() || !range->CanBeSpilled(current->Start()); | 3190 range->TopLevel()->IsFixed() || !range->CanBeSpilled(current->Start()); |
| 3188 if (kSimpleFPAliasing || !check_fp_aliasing()) { | 3191 if (kSimpleFPAliasing || !check_fp_aliasing()) { |
| 3189 if (is_fixed_or_cant_spill) { | 3192 if (is_fixed_or_cant_spill) { |
| 3190 block_pos[cur_reg] = use_pos[cur_reg] = | 3193 block_pos[cur_reg] = use_pos[cur_reg] = |
| 3191 LifetimePosition::GapFromInstructionIndex(0); | 3194 LifetimePosition::GapFromInstructionIndex(0); |
| 3192 } else { | 3195 } else { |
| 3196 DCHECK_NE(LifetimePosition::GapFromInstructionIndex(0), |
| 3197 block_pos[cur_reg]); |
| 3193 use_pos[cur_reg] = | 3198 use_pos[cur_reg] = |
| 3194 range->NextLifetimePositionRegisterIsBeneficial(current->Start()); | 3199 range->NextLifetimePositionRegisterIsBeneficial(current->Start()); |
| 3195 } | 3200 } |
| 3196 } else { | 3201 } else { |
| 3197 int alias_base_index = -1; | 3202 int alias_base_index = -1; |
| 3198 int aliases = data()->config()->GetAliases( | 3203 int aliases = data()->config()->GetAliases( |
| 3199 range->representation(), cur_reg, rep, &alias_base_index); | 3204 range->representation(), cur_reg, rep, &alias_base_index); |
| 3200 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); | 3205 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); |
| 3201 while (aliases--) { | 3206 while (aliases--) { |
| 3202 int aliased_reg = alias_base_index + aliases; | 3207 int aliased_reg = alias_base_index + aliases; |
| 3203 if (is_fixed_or_cant_spill) { | 3208 if (is_fixed_or_cant_spill) { |
| 3204 block_pos[aliased_reg] = use_pos[aliased_reg] = | 3209 block_pos[aliased_reg] = use_pos[aliased_reg] = |
| 3205 LifetimePosition::GapFromInstructionIndex(0); | 3210 LifetimePosition::GapFromInstructionIndex(0); |
| 3206 } else { | 3211 } else { |
| 3207 use_pos[aliased_reg] = | 3212 use_pos[aliased_reg] = |
| 3208 range->NextLifetimePositionRegisterIsBeneficial(current->Start()); | 3213 Min(block_pos[aliased_reg], |
| 3214 range->NextLifetimePositionRegisterIsBeneficial( |
| 3215 current->Start())); |
| 3209 } | 3216 } |
| 3210 } | 3217 } |
| 3211 } | 3218 } |
| 3212 } | 3219 } |
| 3213 | 3220 |
| 3214 for (LiveRange* range : inactive_live_ranges()) { | 3221 for (LiveRange* range : inactive_live_ranges()) { |
| 3215 DCHECK(range->End() > current->Start()); | 3222 DCHECK(range->End() > current->Start()); |
| 3216 int cur_reg = range->assigned_register(); | 3223 int cur_reg = range->assigned_register(); |
| 3217 bool is_fixed = range->TopLevel()->IsFixed(); | 3224 bool is_fixed = range->TopLevel()->IsFixed(); |
| 3218 | 3225 |
| 3219 // Don't perform costly intersections if they are guaranteed to not update | 3226 // Don't perform costly intersections if they are guaranteed to not update |
| 3220 // block_pos or use_pos. | 3227 // block_pos or use_pos. |
| 3221 // TODO(mtrofin): extend to aliased ranges, too. | 3228 // TODO(mtrofin): extend to aliased ranges, too. |
| 3222 if ((kSimpleFPAliasing || !check_fp_aliasing()) && is_fixed) { | 3229 if ((kSimpleFPAliasing || !check_fp_aliasing())) { |
| 3223 if (block_pos[cur_reg] < range->Start()) continue; | 3230 if (is_fixed) { |
| 3224 } else { | 3231 if (block_pos[cur_reg] < range->Start()) continue; |
| 3225 if (use_pos[cur_reg] < range->Start()) continue; | 3232 } else { |
| 3233 if (use_pos[cur_reg] < range->Start()) continue; |
| 3234 } |
| 3226 } | 3235 } |
| 3227 | 3236 |
| 3228 LifetimePosition next_intersection = range->FirstIntersection(current); | 3237 LifetimePosition next_intersection = range->FirstIntersection(current); |
| 3229 if (!next_intersection.IsValid()) continue; | 3238 if (!next_intersection.IsValid()) continue; |
| 3230 | 3239 |
| 3231 if (kSimpleFPAliasing || !check_fp_aliasing()) { | 3240 if (kSimpleFPAliasing || !check_fp_aliasing()) { |
| 3232 if (is_fixed) { | 3241 if (is_fixed) { |
| 3233 block_pos[cur_reg] = Min(block_pos[cur_reg], next_intersection); | 3242 block_pos[cur_reg] = Min(block_pos[cur_reg], next_intersection); |
| 3234 use_pos[cur_reg] = Min(block_pos[cur_reg], use_pos[cur_reg]); | 3243 use_pos[cur_reg] = Min(block_pos[cur_reg], use_pos[cur_reg]); |
| 3235 } else { | 3244 } else { |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3998 } | 4007 } |
| 3999 } | 4008 } |
| 4000 } | 4009 } |
| 4001 } | 4010 } |
| 4002 } | 4011 } |
| 4003 | 4012 |
| 4004 | 4013 |
| 4005 } // namespace compiler | 4014 } // namespace compiler |
| 4006 } // namespace internal | 4015 } // namespace internal |
| 4007 } // namespace v8 | 4016 } // namespace v8 |
| OLD | NEW |