| 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 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 namespace compiler { | 12 namespace compiler { |
| 13 | 13 |
| 14 #define TRACE(...) \ | 14 #define TRACE(...) \ |
| 15 do { \ | 15 do { \ |
| 16 if (FLAG_trace_alloc) PrintF(__VA_ARGS__); \ | 16 if (FLAG_trace_alloc) PrintF(__VA_ARGS__); \ |
| 17 } while (false) | 17 } while (false) |
| 18 | 18 |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 static const int kFloatRepBit = |
| 23 1 << static_cast<int>(MachineRepresentation::kFloat32); |
| 24 static const int kSimd128RepBit = |
| 25 1 << static_cast<int>(MachineRepresentation::kSimd128); |
| 26 |
| 22 void RemoveElement(ZoneVector<LiveRange*>* v, LiveRange* range) { | 27 void RemoveElement(ZoneVector<LiveRange*>* v, LiveRange* range) { |
| 23 auto it = std::find(v->begin(), v->end(), range); | 28 auto it = std::find(v->begin(), v->end(), range); |
| 24 DCHECK(it != v->end()); | 29 DCHECK(it != v->end()); |
| 25 v->erase(it); | 30 v->erase(it); |
| 26 } | 31 } |
| 27 | 32 |
| 28 int GetRegisterCount(const RegisterConfiguration* cfg, RegisterKind kind) { | 33 int GetRegisterCount(const RegisterConfiguration* cfg, RegisterKind kind) { |
| 29 return kind == FP_REGISTERS ? cfg->num_double_registers() | 34 return kind == FP_REGISTERS ? cfg->num_double_registers() |
| 30 : cfg->num_general_registers(); | 35 : cfg->num_general_registers(); |
| 31 } | 36 } |
| (...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2015 range->AddUseInterval(block_start, position, allocation_zone()); | 2020 range->AddUseInterval(block_start, position, allocation_zone()); |
| 2016 return use_pos; | 2021 return use_pos; |
| 2017 } | 2022 } |
| 2018 | 2023 |
| 2019 | 2024 |
| 2020 void LiveRangeBuilder::ProcessInstructions(const InstructionBlock* block, | 2025 void LiveRangeBuilder::ProcessInstructions(const InstructionBlock* block, |
| 2021 BitVector* live) { | 2026 BitVector* live) { |
| 2022 int block_start = block->first_instruction_index(); | 2027 int block_start = block->first_instruction_index(); |
| 2023 LifetimePosition block_start_position = | 2028 LifetimePosition block_start_position = |
| 2024 LifetimePosition::GapFromInstructionIndex(block_start); | 2029 LifetimePosition::GapFromInstructionIndex(block_start); |
| 2030 bool fixed_float_live_ranges = false; |
| 2031 bool fixed_simd128_live_ranges = false; |
| 2032 if (!kSimpleFPAliasing) { |
| 2033 int mask = data()->code()->representation_mask(); |
| 2034 fixed_float_live_ranges = (mask & kFloatRepBit) != 0; |
| 2035 fixed_simd128_live_ranges = (mask & kSimd128RepBit) != 0; |
| 2036 } |
| 2025 | 2037 |
| 2026 for (int index = block->last_instruction_index(); index >= block_start; | 2038 for (int index = block->last_instruction_index(); index >= block_start; |
| 2027 index--) { | 2039 index--) { |
| 2028 LifetimePosition curr_position = | 2040 LifetimePosition curr_position = |
| 2029 LifetimePosition::InstructionFromInstructionIndex(index); | 2041 LifetimePosition::InstructionFromInstructionIndex(index); |
| 2030 Instruction* instr = code()->InstructionAt(index); | 2042 Instruction* instr = code()->InstructionAt(index); |
| 2031 DCHECK(instr != nullptr); | 2043 DCHECK(instr != nullptr); |
| 2032 DCHECK(curr_position.IsInstructionPosition()); | 2044 DCHECK(curr_position.IsInstructionPosition()); |
| 2033 // Process output, inputs, and temps of this instruction. | 2045 // Process output, inputs, and temps of this instruction. |
| 2034 for (size_t i = 0; i < instr->OutputCount(); i++) { | 2046 for (size_t i = 0; i < instr->OutputCount(); i++) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 // Add a UseInterval for all DoubleRegisters. See comment above for | 2086 // Add a UseInterval for all DoubleRegisters. See comment above for |
| 2075 // general registers. | 2087 // general registers. |
| 2076 int code = config()->GetAllocatableDoubleCode(i); | 2088 int code = config()->GetAllocatableDoubleCode(i); |
| 2077 TopLevelLiveRange* range = | 2089 TopLevelLiveRange* range = |
| 2078 FixedFPLiveRangeFor(code, MachineRepresentation::kFloat64); | 2090 FixedFPLiveRangeFor(code, MachineRepresentation::kFloat64); |
| 2079 range->AddUseInterval(curr_position, curr_position.End(), | 2091 range->AddUseInterval(curr_position, curr_position.End(), |
| 2080 allocation_zone()); | 2092 allocation_zone()); |
| 2081 } | 2093 } |
| 2082 // Clobber fixed float registers on archs with non-simple aliasing. | 2094 // Clobber fixed float registers on archs with non-simple aliasing. |
| 2083 if (!kSimpleFPAliasing) { | 2095 if (!kSimpleFPAliasing) { |
| 2084 for (int i = 0; i < config()->num_allocatable_float_registers(); ++i) { | 2096 if (fixed_float_live_ranges) { |
| 2085 // Add a UseInterval for all FloatRegisters. See comment above for | 2097 for (int i = 0; i < config()->num_allocatable_float_registers(); |
| 2086 // general registers. | 2098 ++i) { |
| 2087 int code = config()->GetAllocatableFloatCode(i); | 2099 // Add a UseInterval for all FloatRegisters. See comment above for |
| 2088 TopLevelLiveRange* range = | 2100 // general registers. |
| 2089 FixedFPLiveRangeFor(code, MachineRepresentation::kFloat32); | 2101 int code = config()->GetAllocatableFloatCode(i); |
| 2090 range->AddUseInterval(curr_position, curr_position.End(), | 2102 TopLevelLiveRange* range = |
| 2091 allocation_zone()); | 2103 FixedFPLiveRangeFor(code, MachineRepresentation::kFloat32); |
| 2104 range->AddUseInterval(curr_position, curr_position.End(), |
| 2105 allocation_zone()); |
| 2106 } |
| 2092 } | 2107 } |
| 2093 for (int i = 0; i < config()->num_allocatable_simd128_registers(); | 2108 if (fixed_simd128_live_ranges) { |
| 2094 ++i) { | 2109 for (int i = 0; i < config()->num_allocatable_simd128_registers(); |
| 2095 int code = config()->GetAllocatableSimd128Code(i); | 2110 ++i) { |
| 2096 TopLevelLiveRange* range = | 2111 int code = config()->GetAllocatableSimd128Code(i); |
| 2097 FixedFPLiveRangeFor(code, MachineRepresentation::kSimd128); | 2112 TopLevelLiveRange* range = |
| 2098 range->AddUseInterval(curr_position, curr_position.End(), | 2113 FixedFPLiveRangeFor(code, MachineRepresentation::kSimd128); |
| 2099 allocation_zone()); | 2114 range->AddUseInterval(curr_position, curr_position.End(), |
| 2115 allocation_zone()); |
| 2116 } |
| 2100 } | 2117 } |
| 2101 } | 2118 } |
| 2102 } | 2119 } |
| 2103 | 2120 |
| 2104 for (size_t i = 0; i < instr->InputCount(); i++) { | 2121 for (size_t i = 0; i < instr->InputCount(); i++) { |
| 2105 InstructionOperand* input = instr->InputAt(i); | 2122 InstructionOperand* input = instr->InputAt(i); |
| 2106 if (input->IsImmediate() || input->IsExplicit()) { | 2123 if (input->IsImmediate() || input->IsExplicit()) { |
| 2107 continue; // Ignore immediates and explicitly reserved registers. | 2124 continue; // Ignore immediates and explicitly reserved registers. |
| 2108 } | 2125 } |
| 2109 LifetimePosition use_pos; | 2126 LifetimePosition use_pos; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2203 } | 2220 } |
| 2204 DCHECK_IMPLIES(to_use != nullptr, to_use->IsResolved()); | 2221 DCHECK_IMPLIES(to_use != nullptr, to_use->IsResolved()); |
| 2205 DCHECK_IMPLIES(from_use != nullptr, from_use->IsResolved()); | 2222 DCHECK_IMPLIES(from_use != nullptr, from_use->IsResolved()); |
| 2206 // Potentially resolve phi hint. | 2223 // Potentially resolve phi hint. |
| 2207 if (phi_vreg != -1) ResolvePhiHint(&from, from_use); | 2224 if (phi_vreg != -1) ResolvePhiHint(&from, from_use); |
| 2208 } | 2225 } |
| 2209 } | 2226 } |
| 2210 } | 2227 } |
| 2211 } | 2228 } |
| 2212 | 2229 |
| 2213 | |
| 2214 void LiveRangeBuilder::ProcessPhis(const InstructionBlock* block, | 2230 void LiveRangeBuilder::ProcessPhis(const InstructionBlock* block, |
| 2215 BitVector* live) { | 2231 BitVector* live) { |
| 2216 for (PhiInstruction* phi : block->phis()) { | 2232 for (PhiInstruction* phi : block->phis()) { |
| 2217 // The live range interval already ends at the first instruction of the | 2233 // The live range interval already ends at the first instruction of the |
| 2218 // block. | 2234 // block. |
| 2219 int phi_vreg = phi->virtual_register(); | 2235 int phi_vreg = phi->virtual_register(); |
| 2220 live->Remove(phi_vreg); | 2236 live->Remove(phi_vreg); |
| 2221 // Select a hint from a predecessor block that preceeds this block in the | 2237 // Select a hint from a predecessor block that preceeds this block in the |
| 2222 // rpo order. In order of priority: | 2238 // rpo order. In order of priority: |
| 2223 // - Avoid hints from deferred blocks. | 2239 // - Avoid hints from deferred blocks. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2513 } | 2529 } |
| 2514 | 2530 |
| 2515 RegisterAllocator::RegisterAllocator(RegisterAllocationData* data, | 2531 RegisterAllocator::RegisterAllocator(RegisterAllocationData* data, |
| 2516 RegisterKind kind) | 2532 RegisterKind kind) |
| 2517 : data_(data), | 2533 : data_(data), |
| 2518 mode_(kind), | 2534 mode_(kind), |
| 2519 num_registers_(GetRegisterCount(data->config(), kind)), | 2535 num_registers_(GetRegisterCount(data->config(), kind)), |
| 2520 num_allocatable_registers_( | 2536 num_allocatable_registers_( |
| 2521 GetAllocatableRegisterCount(data->config(), kind)), | 2537 GetAllocatableRegisterCount(data->config(), kind)), |
| 2522 allocatable_register_codes_( | 2538 allocatable_register_codes_( |
| 2523 GetAllocatableRegisterCodes(data->config(), kind)) {} | 2539 GetAllocatableRegisterCodes(data->config(), kind)), |
| 2540 check_fp_aliasing_(false) { |
| 2541 if (!kSimpleFPAliasing && kind == FP_REGISTERS) { |
| 2542 check_fp_aliasing_ = (data->code()->representation_mask() & |
| 2543 (kFloatRepBit | kSimd128RepBit)) != 0; |
| 2544 } |
| 2545 } |
| 2524 | 2546 |
| 2525 LifetimePosition RegisterAllocator::GetSplitPositionForInstruction( | 2547 LifetimePosition RegisterAllocator::GetSplitPositionForInstruction( |
| 2526 const LiveRange* range, int instruction_index) { | 2548 const LiveRange* range, int instruction_index) { |
| 2527 LifetimePosition ret = LifetimePosition::Invalid(); | 2549 LifetimePosition ret = LifetimePosition::Invalid(); |
| 2528 | 2550 |
| 2529 ret = LifetimePosition::GapFromInstructionIndex(instruction_index); | 2551 ret = LifetimePosition::GapFromInstructionIndex(instruction_index); |
| 2530 if (range->Start() >= ret || ret >= range->End()) { | 2552 if (range->Start() >= ret || ret >= range->End()) { |
| 2531 return LifetimePosition::Invalid(); | 2553 return LifetimePosition::Invalid(); |
| 2532 } | 2554 } |
| 2533 return ret; | 2555 return ret; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 DCHECK(UnhandledIsSorted()); | 2762 DCHECK(UnhandledIsSorted()); |
| 2741 | 2763 |
| 2742 if (mode() == GENERAL_REGISTERS) { | 2764 if (mode() == GENERAL_REGISTERS) { |
| 2743 for (TopLevelLiveRange* current : data()->fixed_live_ranges()) { | 2765 for (TopLevelLiveRange* current : data()->fixed_live_ranges()) { |
| 2744 if (current != nullptr) AddToInactive(current); | 2766 if (current != nullptr) AddToInactive(current); |
| 2745 } | 2767 } |
| 2746 } else { | 2768 } else { |
| 2747 for (TopLevelLiveRange* current : data()->fixed_double_live_ranges()) { | 2769 for (TopLevelLiveRange* current : data()->fixed_double_live_ranges()) { |
| 2748 if (current != nullptr) AddToInactive(current); | 2770 if (current != nullptr) AddToInactive(current); |
| 2749 } | 2771 } |
| 2750 if (!kSimpleFPAliasing) { | 2772 if (!kSimpleFPAliasing && check_fp_aliasing()) { |
| 2751 for (TopLevelLiveRange* current : data()->fixed_float_live_ranges()) { | 2773 for (TopLevelLiveRange* current : data()->fixed_float_live_ranges()) { |
| 2752 if (current != nullptr) AddToInactive(current); | 2774 if (current != nullptr) AddToInactive(current); |
| 2753 } | 2775 } |
| 2754 for (TopLevelLiveRange* current : data()->fixed_simd128_live_ranges()) { | 2776 for (TopLevelLiveRange* current : data()->fixed_simd128_live_ranges()) { |
| 2755 if (current != nullptr) AddToInactive(current); | 2777 if (current != nullptr) AddToInactive(current); |
| 2756 } | 2778 } |
| 2757 } | 2779 } |
| 2758 } | 2780 } |
| 2759 | 2781 |
| 2760 while (!unhandled_live_ranges().empty()) { | 2782 while (!unhandled_live_ranges().empty()) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2962 rep == MachineRepresentation::kSimd128)) | 2984 rep == MachineRepresentation::kSimd128)) |
| 2963 GetFPRegisterSet(rep, &num_regs, &num_codes, &codes); | 2985 GetFPRegisterSet(rep, &num_regs, &num_codes, &codes); |
| 2964 DCHECK_GE(positions.length(), num_regs); | 2986 DCHECK_GE(positions.length(), num_regs); |
| 2965 | 2987 |
| 2966 for (int i = 0; i < num_regs; i++) { | 2988 for (int i = 0; i < num_regs; i++) { |
| 2967 positions[i] = LifetimePosition::MaxPosition(); | 2989 positions[i] = LifetimePosition::MaxPosition(); |
| 2968 } | 2990 } |
| 2969 | 2991 |
| 2970 for (LiveRange* cur_active : active_live_ranges()) { | 2992 for (LiveRange* cur_active : active_live_ranges()) { |
| 2971 int cur_reg = cur_active->assigned_register(); | 2993 int cur_reg = cur_active->assigned_register(); |
| 2972 if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { | 2994 if (kSimpleFPAliasing || !check_fp_aliasing()) { |
| 2973 positions[cur_reg] = LifetimePosition::GapFromInstructionIndex(0); | 2995 positions[cur_reg] = LifetimePosition::GapFromInstructionIndex(0); |
| 2974 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), |
| 2975 LifetimePosition::GapFromInstructionIndex(0).value()); | 2997 LifetimePosition::GapFromInstructionIndex(0).value()); |
| 2976 } else { | 2998 } else { |
| 2977 int alias_base_index = -1; | 2999 int alias_base_index = -1; |
| 2978 int aliases = data()->config()->GetAliases( | 3000 int aliases = data()->config()->GetAliases( |
| 2979 cur_active->representation(), cur_reg, rep, &alias_base_index); | 3001 cur_active->representation(), cur_reg, rep, &alias_base_index); |
| 2980 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); | 3002 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); |
| 2981 while (aliases--) { | 3003 while (aliases--) { |
| 2982 int aliased_reg = alias_base_index + aliases; | 3004 int aliased_reg = alias_base_index + aliases; |
| 2983 positions[aliased_reg] = LifetimePosition::GapFromInstructionIndex(0); | 3005 positions[aliased_reg] = LifetimePosition::GapFromInstructionIndex(0); |
| 2984 } | 3006 } |
| 2985 } | 3007 } |
| 2986 } | 3008 } |
| 2987 | 3009 |
| 2988 for (LiveRange* cur_inactive : inactive_live_ranges()) { | 3010 for (LiveRange* cur_inactive : inactive_live_ranges()) { |
| 2989 DCHECK(cur_inactive->End() > range->Start()); | 3011 DCHECK(cur_inactive->End() > range->Start()); |
| 2990 LifetimePosition next_intersection = cur_inactive->FirstIntersection(range); | 3012 LifetimePosition next_intersection = cur_inactive->FirstIntersection(range); |
| 2991 if (!next_intersection.IsValid()) continue; | 3013 if (!next_intersection.IsValid()) continue; |
| 2992 int cur_reg = cur_inactive->assigned_register(); | 3014 int cur_reg = cur_inactive->assigned_register(); |
| 2993 if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { | 3015 if (kSimpleFPAliasing || !check_fp_aliasing()) { |
| 2994 positions[cur_reg] = Min(positions[cur_reg], next_intersection); | 3016 positions[cur_reg] = Min(positions[cur_reg], next_intersection); |
| 2995 TRACE("Register %s is free until pos %d (2)\n", RegisterName(cur_reg), | 3017 TRACE("Register %s is free until pos %d (2)\n", RegisterName(cur_reg), |
| 2996 Min(positions[cur_reg], next_intersection).value()); | 3018 Min(positions[cur_reg], next_intersection).value()); |
| 2997 } else { | 3019 } else { |
| 2998 int alias_base_index = -1; | 3020 int alias_base_index = -1; |
| 2999 int aliases = data()->config()->GetAliases( | 3021 int aliases = data()->config()->GetAliases( |
| 3000 cur_inactive->representation(), cur_reg, rep, &alias_base_index); | 3022 cur_inactive->representation(), cur_reg, rep, &alias_base_index); |
| 3001 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); | 3023 DCHECK(aliases > 0 || (aliases == 0 && alias_base_index == -1)); |
| 3002 while (aliases--) { | 3024 while (aliases--) { |
| 3003 int aliased_reg = alias_base_index + aliases; | 3025 int aliased_reg = alias_base_index + aliases; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3147 LifetimePosition use_pos[RegisterConfiguration::kMaxFPRegisters]; | 3169 LifetimePosition use_pos[RegisterConfiguration::kMaxFPRegisters]; |
| 3148 LifetimePosition block_pos[RegisterConfiguration::kMaxFPRegisters]; | 3170 LifetimePosition block_pos[RegisterConfiguration::kMaxFPRegisters]; |
| 3149 for (int i = 0; i < num_regs; i++) { | 3171 for (int i = 0; i < num_regs; i++) { |
| 3150 use_pos[i] = block_pos[i] = LifetimePosition::MaxPosition(); | 3172 use_pos[i] = block_pos[i] = LifetimePosition::MaxPosition(); |
| 3151 } | 3173 } |
| 3152 | 3174 |
| 3153 for (LiveRange* range : active_live_ranges()) { | 3175 for (LiveRange* range : active_live_ranges()) { |
| 3154 int cur_reg = range->assigned_register(); | 3176 int cur_reg = range->assigned_register(); |
| 3155 bool is_fixed_or_cant_spill = | 3177 bool is_fixed_or_cant_spill = |
| 3156 range->TopLevel()->IsFixed() || !range->CanBeSpilled(current->Start()); | 3178 range->TopLevel()->IsFixed() || !range->CanBeSpilled(current->Start()); |
| 3157 if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { | 3179 if (kSimpleFPAliasing || !check_fp_aliasing()) { |
| 3158 if (is_fixed_or_cant_spill) { | 3180 if (is_fixed_or_cant_spill) { |
| 3159 block_pos[cur_reg] = use_pos[cur_reg] = | 3181 block_pos[cur_reg] = use_pos[cur_reg] = |
| 3160 LifetimePosition::GapFromInstructionIndex(0); | 3182 LifetimePosition::GapFromInstructionIndex(0); |
| 3161 } else { | 3183 } else { |
| 3162 use_pos[cur_reg] = | 3184 use_pos[cur_reg] = |
| 3163 range->NextLifetimePositionRegisterIsBeneficial(current->Start()); | 3185 range->NextLifetimePositionRegisterIsBeneficial(current->Start()); |
| 3164 } | 3186 } |
| 3165 } else { | 3187 } else { |
| 3166 int alias_base_index = -1; | 3188 int alias_base_index = -1; |
| 3167 int aliases = data()->config()->GetAliases( | 3189 int aliases = data()->config()->GetAliases( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3179 } | 3201 } |
| 3180 } | 3202 } |
| 3181 } | 3203 } |
| 3182 | 3204 |
| 3183 for (LiveRange* range : inactive_live_ranges()) { | 3205 for (LiveRange* range : inactive_live_ranges()) { |
| 3184 DCHECK(range->End() > current->Start()); | 3206 DCHECK(range->End() > current->Start()); |
| 3185 LifetimePosition next_intersection = range->FirstIntersection(current); | 3207 LifetimePosition next_intersection = range->FirstIntersection(current); |
| 3186 if (!next_intersection.IsValid()) continue; | 3208 if (!next_intersection.IsValid()) continue; |
| 3187 int cur_reg = range->assigned_register(); | 3209 int cur_reg = range->assigned_register(); |
| 3188 bool is_fixed = range->TopLevel()->IsFixed(); | 3210 bool is_fixed = range->TopLevel()->IsFixed(); |
| 3189 if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { | 3211 if (kSimpleFPAliasing || !check_fp_aliasing()) { |
| 3190 if (is_fixed) { | 3212 if (is_fixed) { |
| 3191 block_pos[cur_reg] = Min(block_pos[cur_reg], next_intersection); | 3213 block_pos[cur_reg] = Min(block_pos[cur_reg], next_intersection); |
| 3192 use_pos[cur_reg] = Min(block_pos[cur_reg], use_pos[cur_reg]); | 3214 use_pos[cur_reg] = Min(block_pos[cur_reg], use_pos[cur_reg]); |
| 3193 } else { | 3215 } else { |
| 3194 use_pos[cur_reg] = Min(use_pos[cur_reg], next_intersection); | 3216 use_pos[cur_reg] = Min(use_pos[cur_reg], next_intersection); |
| 3195 } | 3217 } |
| 3196 } else { | 3218 } else { |
| 3197 int alias_base_index = -1; | 3219 int alias_base_index = -1; |
| 3198 int aliases = data()->config()->GetAliases( | 3220 int aliases = data()->config()->GetAliases( |
| 3199 range->representation(), cur_reg, rep, &alias_base_index); | 3221 range->representation(), cur_reg, rep, &alias_base_index); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3253 SplitAndSpillIntersecting(current); | 3275 SplitAndSpillIntersecting(current); |
| 3254 } | 3276 } |
| 3255 | 3277 |
| 3256 | 3278 |
| 3257 void LinearScanAllocator::SplitAndSpillIntersecting(LiveRange* current) { | 3279 void LinearScanAllocator::SplitAndSpillIntersecting(LiveRange* current) { |
| 3258 DCHECK(current->HasRegisterAssigned()); | 3280 DCHECK(current->HasRegisterAssigned()); |
| 3259 int reg = current->assigned_register(); | 3281 int reg = current->assigned_register(); |
| 3260 LifetimePosition split_pos = current->Start(); | 3282 LifetimePosition split_pos = current->Start(); |
| 3261 for (size_t i = 0; i < active_live_ranges().size(); ++i) { | 3283 for (size_t i = 0; i < active_live_ranges().size(); ++i) { |
| 3262 LiveRange* range = active_live_ranges()[i]; | 3284 LiveRange* range = active_live_ranges()[i]; |
| 3263 if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { | 3285 if (kSimpleFPAliasing || !check_fp_aliasing()) { |
| 3264 if (range->assigned_register() != reg) continue; | 3286 if (range->assigned_register() != reg) continue; |
| 3265 } else { | 3287 } else { |
| 3266 if (!data()->config()->AreAliases(current->representation(), reg, | 3288 if (!data()->config()->AreAliases(current->representation(), reg, |
| 3267 range->representation(), | 3289 range->representation(), |
| 3268 range->assigned_register())) { | 3290 range->assigned_register())) { |
| 3269 continue; | 3291 continue; |
| 3270 } | 3292 } |
| 3271 } | 3293 } |
| 3272 | 3294 |
| 3273 UsePosition* next_pos = range->NextRegisterPosition(current->Start()); | 3295 UsePosition* next_pos = range->NextRegisterPosition(current->Start()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3288 SpillBetweenUntil(range, spill_pos, current->Start(), next_pos->pos()); | 3310 SpillBetweenUntil(range, spill_pos, current->Start(), next_pos->pos()); |
| 3289 } | 3311 } |
| 3290 ActiveToHandled(range); | 3312 ActiveToHandled(range); |
| 3291 --i; | 3313 --i; |
| 3292 } | 3314 } |
| 3293 | 3315 |
| 3294 for (size_t i = 0; i < inactive_live_ranges().size(); ++i) { | 3316 for (size_t i = 0; i < inactive_live_ranges().size(); ++i) { |
| 3295 LiveRange* range = inactive_live_ranges()[i]; | 3317 LiveRange* range = inactive_live_ranges()[i]; |
| 3296 DCHECK(range->End() > current->Start()); | 3318 DCHECK(range->End() > current->Start()); |
| 3297 if (range->TopLevel()->IsFixed()) continue; | 3319 if (range->TopLevel()->IsFixed()) continue; |
| 3298 if (kSimpleFPAliasing || mode() == GENERAL_REGISTERS) { | 3320 if (kSimpleFPAliasing || !check_fp_aliasing()) { |
| 3299 if (range->assigned_register() != reg) continue; | 3321 if (range->assigned_register() != reg) continue; |
| 3300 } else { | 3322 } else { |
| 3301 if (!data()->config()->AreAliases(current->representation(), reg, | 3323 if (!data()->config()->AreAliases(current->representation(), reg, |
| 3302 range->representation(), | 3324 range->representation(), |
| 3303 range->assigned_register())) | 3325 range->assigned_register())) |
| 3304 continue; | 3326 continue; |
| 3305 } | 3327 } |
| 3306 | 3328 |
| 3307 LifetimePosition next_intersection = range->FirstIntersection(current); | 3329 LifetimePosition next_intersection = range->FirstIntersection(current); |
| 3308 if (next_intersection.IsValid()) { | 3330 if (next_intersection.IsValid()) { |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3956 } | 3978 } |
| 3957 } | 3979 } |
| 3958 } | 3980 } |
| 3959 } | 3981 } |
| 3960 } | 3982 } |
| 3961 | 3983 |
| 3962 | 3984 |
| 3963 } // namespace compiler | 3985 } // namespace compiler |
| 3964 } // namespace internal | 3986 } // namespace internal |
| 3965 } // namespace v8 | 3987 } // namespace v8 |
| OLD | NEW |