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

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

Issue 2559733002: [turbofan] regalloc: avoid redundant range intersections (Closed)
Patch Set: [turbofan] regalloc: avoid redundant range intersections Created 4 years 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 2967 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 LiveRange* range, Vector<LifetimePosition> positions) { 2978 LiveRange* range, Vector<LifetimePosition> positions) {
2979 int num_regs = num_registers(); 2979 int num_regs = num_registers();
2980 int num_codes = num_allocatable_registers(); 2980 int num_codes = num_allocatable_registers();
2981 const int* codes = allocatable_register_codes(); 2981 const int* codes = allocatable_register_codes();
2982 MachineRepresentation rep = range->representation(); 2982 MachineRepresentation rep = range->representation();
2983 if (!kSimpleFPAliasing && (rep == MachineRepresentation::kFloat32 || 2983 if (!kSimpleFPAliasing && (rep == MachineRepresentation::kFloat32 ||
2984 rep == MachineRepresentation::kSimd128)) 2984 rep == MachineRepresentation::kSimd128))
2985 GetFPRegisterSet(rep, &num_regs, &num_codes, &codes); 2985 GetFPRegisterSet(rep, &num_regs, &num_codes, &codes);
2986 DCHECK_GE(positions.length(), num_regs); 2986 DCHECK_GE(positions.length(), num_regs);
2987 2987
2988 for (int i = 0; i < num_regs; i++) { 2988 for (int i = 0; i < num_regs; ++i) {
2989 positions[i] = LifetimePosition::MaxPosition(); 2989 positions[i] = LifetimePosition::MaxPosition();
2990 } 2990 }
2991 2991
2992 for (LiveRange* cur_active : active_live_ranges()) { 2992 for (LiveRange* cur_active : active_live_ranges()) {
2993 int cur_reg = cur_active->assigned_register(); 2993 int cur_reg = cur_active->assigned_register();
2994 if (kSimpleFPAliasing || !check_fp_aliasing()) { 2994 if (kSimpleFPAliasing || !check_fp_aliasing()) {
2995 positions[cur_reg] = LifetimePosition::GapFromInstructionIndex(0); 2995 positions[cur_reg] = LifetimePosition::GapFromInstructionIndex(0);
2996 TRACE("Register %s is free until pos %d (1)\n", RegisterName(cur_reg), 2996 TRACE("Register %s is free until pos %d (1)\n", RegisterName(cur_reg),
2997 LifetimePosition::GapFromInstructionIndex(0).value()); 2997 LifetimePosition::GapFromInstructionIndex(0).value());
2998 } else { 2998 } else {
2999 int alias_base_index = -1; 2999 int alias_base_index = -1;
3000 int aliases = data()->config()->GetAliases( 3000 int aliases = data()->config()->GetAliases(
3001 cur_active->representation(), cur_reg, rep, &alias_base_index); 3001 cur_active->representation(), cur_reg, rep, &alias_base_index);
3002 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); 3002 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1));
3003 while (aliases--) { 3003 while (aliases--) {
3004 int aliased_reg = alias_base_index + aliases; 3004 int aliased_reg = alias_base_index + aliases;
3005 positions[aliased_reg] = LifetimePosition::GapFromInstructionIndex(0); 3005 positions[aliased_reg] = LifetimePosition::GapFromInstructionIndex(0);
3006 } 3006 }
3007 } 3007 }
3008 } 3008 }
3009 3009
3010 for (LiveRange* cur_inactive : inactive_live_ranges()) { 3010 for (LiveRange* cur_inactive : inactive_live_ranges()) {
3011 DCHECK(cur_inactive->End() > range->Start()); 3011 DCHECK(cur_inactive->End() > range->Start());
3012 int cur_reg = cur_inactive->assigned_register();
3013 // No need to carry out intersections, when this register won't be
3014 // interesting to this range anyway.
3015 if (positions[cur_reg] < range->Start()) continue;
3016
3012 LifetimePosition next_intersection = cur_inactive->FirstIntersection(range); 3017 LifetimePosition next_intersection = cur_inactive->FirstIntersection(range);
3013 if (!next_intersection.IsValid()) continue; 3018 if (!next_intersection.IsValid()) continue;
3014 int cur_reg = cur_inactive->assigned_register();
3015 if (kSimpleFPAliasing || !check_fp_aliasing()) { 3019 if (kSimpleFPAliasing || !check_fp_aliasing()) {
3016 positions[cur_reg] = Min(positions[cur_reg], next_intersection); 3020 positions[cur_reg] = Min(positions[cur_reg], next_intersection);
3017 TRACE("Register %s is free until pos %d (2)\n", RegisterName(cur_reg), 3021 TRACE("Register %s is free until pos %d (2)\n", RegisterName(cur_reg),
3018 Min(positions[cur_reg], next_intersection).value()); 3022 Min(positions[cur_reg], next_intersection).value());
3019 } else { 3023 } else {
3020 int alias_base_index = -1; 3024 int alias_base_index = -1;
3021 int aliases = data()->config()->GetAliases( 3025 int aliases = data()->config()->GetAliases(
3022 cur_inactive->representation(), cur_reg, rep, &alias_base_index); 3026 cur_inactive->representation(), cur_reg, rep, &alias_base_index);
3023 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); 3027 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1));
3024 while (aliases--) { 3028 while (aliases--) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3104 return false; 3108 return false;
3105 } 3109 }
3106 3110
3107 bool LinearScanAllocator::TryAllocateFreeReg( 3111 bool LinearScanAllocator::TryAllocateFreeReg(
3108 LiveRange* current, const Vector<LifetimePosition>& free_until_pos) { 3112 LiveRange* current, const Vector<LifetimePosition>& free_until_pos) {
3109 int num_regs = 0; // used only for the call to GetFPRegisterSet. 3113 int num_regs = 0; // used only for the call to GetFPRegisterSet.
3110 int num_codes = num_allocatable_registers(); 3114 int num_codes = num_allocatable_registers();
3111 const int* codes = allocatable_register_codes(); 3115 const int* codes = allocatable_register_codes();
3112 MachineRepresentation rep = current->representation(); 3116 MachineRepresentation rep = current->representation();
3113 if (!kSimpleFPAliasing && (rep == MachineRepresentation::kFloat32 || 3117 if (!kSimpleFPAliasing && (rep == MachineRepresentation::kFloat32 ||
3114 rep == MachineRepresentation::kSimd128)) 3118 rep == MachineRepresentation::kSimd128)) {
3115 GetFPRegisterSet(rep, &num_regs, &num_codes, &codes); 3119 GetFPRegisterSet(rep, &num_regs, &num_codes, &codes);
3120 }
3116 3121
3117 DCHECK_GE(free_until_pos.length(), num_codes); 3122 DCHECK_GE(free_until_pos.length(), num_codes);
3118 3123
3119 // Find the register which stays free for the longest time. 3124 // Find the register which stays free for the longest time.
3120 int reg = codes[0]; 3125 int reg = codes[0];
3121 for (int i = 1; i < num_codes; ++i) { 3126 for (int i = 1; i < num_codes; ++i) {
3122 int code = codes[i]; 3127 int code = codes[i];
3123 if (free_until_pos[code] > free_until_pos[reg]) { 3128 if (free_until_pos[code] > free_until_pos[reg]) {
3124 reg = code; 3129 reg = code;
3125 } 3130 }
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
3978 } 3983 }
3979 } 3984 }
3980 } 3985 }
3981 } 3986 }
3982 } 3987 }
3983 3988
3984 3989
3985 } // namespace compiler 3990 } // namespace compiler
3986 } // namespace internal 3991 } // namespace internal
3987 } // namespace v8 3992 } // 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