Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Side by Side Diff: src/compiler/register-allocator.cc

Issue 2632373004: [turbofan] Regalloc was assuming "blocked" register can't be "used" (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 {
3193 use_pos[cur_reg] = 3196 use_pos[cur_reg] = Min(
3194 range->NextLifetimePositionRegisterIsBeneficial(current->Start()); 3197 block_pos[cur_reg],
3198 range->NextLifetimePositionRegisterIsBeneficial(current->Start()));
bbudge 2017/01/18 00:45:13 Is this necessary here, since there is either simp
Mircea Trofin 2017/01/18 01:10:12 It's not, but I'd prefer it be there for consisten
bbudge 2017/01/18 01:14:51 DCHECK seems clearer to me than calling Min which
Mircea Trofin 2017/01/18 06:51:25 Done.
3195 } 3199 }
3196 } else { 3200 } else {
3197 int alias_base_index = -1; 3201 int alias_base_index = -1;
3198 int aliases = data()->config()->GetAliases( 3202 int aliases = data()->config()->GetAliases(
3199 range->representation(), cur_reg, rep, &alias_base_index); 3203 range->representation(), cur_reg, rep, &alias_base_index);
3200 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); 3204 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1));
3201 while (aliases--) { 3205 while (aliases--) {
3202 int aliased_reg = alias_base_index + aliases; 3206 int aliased_reg = alias_base_index + aliases;
3203 if (is_fixed_or_cant_spill) { 3207 if (is_fixed_or_cant_spill) {
3204 block_pos[aliased_reg] = use_pos[aliased_reg] = 3208 block_pos[aliased_reg] = use_pos[aliased_reg] =
3205 LifetimePosition::GapFromInstructionIndex(0); 3209 LifetimePosition::GapFromInstructionIndex(0);
3206 } else { 3210 } else {
3207 use_pos[aliased_reg] = 3211 use_pos[aliased_reg] =
3208 range->NextLifetimePositionRegisterIsBeneficial(current->Start()); 3212 Min(block_pos[aliased_reg],
3213 range->NextLifetimePositionRegisterIsBeneficial(
3214 current->Start()));
3209 } 3215 }
3210 } 3216 }
3211 } 3217 }
3212 } 3218 }
3213 3219
3214 for (LiveRange* range : inactive_live_ranges()) { 3220 for (LiveRange* range : inactive_live_ranges()) {
3215 DCHECK(range->End() > current->Start()); 3221 DCHECK(range->End() > current->Start());
3216 int cur_reg = range->assigned_register(); 3222 int cur_reg = range->assigned_register();
3217 bool is_fixed = range->TopLevel()->IsFixed(); 3223 bool is_fixed = range->TopLevel()->IsFixed();
3218 3224
3219 // Don't perform costly intersections if they are guaranteed to not update 3225 // Don't perform costly intersections if they are guaranteed to not update
3220 // block_pos or use_pos. 3226 // block_pos or use_pos.
3221 // TODO(mtrofin): extend to aliased ranges, too. 3227 // TODO(mtrofin): extend to aliased ranges, too.
3222 if ((kSimpleFPAliasing || !check_fp_aliasing()) && is_fixed) { 3228 if ((kSimpleFPAliasing || !check_fp_aliasing())) {
3223 if (block_pos[cur_reg] < range->Start()) continue; 3229 if (is_fixed) {
3224 } else { 3230 if (block_pos[cur_reg] < range->Start()) continue;
3225 if (use_pos[cur_reg] < range->Start()) continue; 3231 } else {
3232 if (use_pos[cur_reg] < range->Start()) continue;
3233 }
3226 } 3234 }
3227 3235
3228 LifetimePosition next_intersection = range->FirstIntersection(current); 3236 LifetimePosition next_intersection = range->FirstIntersection(current);
3229 if (!next_intersection.IsValid()) continue; 3237 if (!next_intersection.IsValid()) continue;
3230 3238
3231 if (kSimpleFPAliasing || !check_fp_aliasing()) { 3239 if (kSimpleFPAliasing || !check_fp_aliasing()) {
3232 if (is_fixed) { 3240 if (is_fixed) {
3233 block_pos[cur_reg] = Min(block_pos[cur_reg], next_intersection); 3241 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]); 3242 use_pos[cur_reg] = Min(block_pos[cur_reg], use_pos[cur_reg]);
3235 } else { 3243 } else {
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
3998 } 4006 }
3999 } 4007 }
4000 } 4008 }
4001 } 4009 }
4002 } 4010 }
4003 4011
4004 4012
4005 } // namespace compiler 4013 } // namespace compiler
4006 } // namespace internal 4014 } // namespace internal
4007 } // namespace v8 4015 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698