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 3260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3271 } | 3271 } |
3272 } | 3272 } |
3273 | 3273 |
3274 LifetimePosition pos = use_pos[reg]; | 3274 LifetimePosition pos = use_pos[reg]; |
3275 | 3275 |
3276 if (pos < register_use->pos()) { | 3276 if (pos < register_use->pos()) { |
3277 if (LifetimePosition::ExistsGapPositionBetween(current->Start(), | 3277 if (LifetimePosition::ExistsGapPositionBetween(current->Start(), |
3278 register_use->pos())) { | 3278 register_use->pos())) { |
3279 SpillBetween(current, current->Start(), register_use->pos()); | 3279 SpillBetween(current, current->Start(), register_use->pos()); |
3280 } else { | 3280 } else { |
3281 // We can't spill up to the first register use, because there is no gap | |
3282 // where the fill before the register use may happen. This happens when | |
3283 // there is high register pressure, we are at the beginning of an | |
3284 // instruction, we are the input to that instruction, and we can't hold | |
3285 // on to the register past the instruction (we likely lose due to an | |
3286 // output or a temp). | |
3287 // We give the `reg` register to this range, but then we need to spill | |
3288 // until the next register use, if any. | |
3289 LifetimePosition after_this_reg_use = register_use->pos().NextFullStart(); | |
3290 DCHECK_LT(after_this_reg_use, current->End()); | |
3291 | |
3292 const UsePosition* next_reg_pos = register_use->next(); | |
3293 for (; next_reg_pos != nullptr; next_reg_pos = next_reg_pos->next()) { | |
3294 if (next_reg_pos->type() == UsePositionType::kRequiresRegister) break; | |
3295 } | |
3296 SetLiveRangeAssignedRegister(current, reg); | 3281 SetLiveRangeAssignedRegister(current, reg); |
3297 if (next_reg_pos == nullptr) { | 3282 SplitAndSpillIntersecting(current); |
3298 SpillAfter(current, after_this_reg_use); | |
3299 } else { | |
3300 SpillBetween(current, after_this_reg_use, next_reg_pos->pos()); | |
3301 } | |
3302 } | 3283 } |
3303 return; | 3284 return; |
3304 } | 3285 } |
3305 | 3286 |
3306 if (block_pos[reg] < current->End()) { | 3287 if (block_pos[reg] < current->End()) { |
3307 // Register becomes blocked before the current range end. Split before that | 3288 // Register becomes blocked before the current range end. Split before that |
3308 // position. | 3289 // position. |
3309 LiveRange* tail = | 3290 LiveRange* tail = |
3310 SplitBetween(current, current->Start(), block_pos[reg].Start()); | 3291 SplitBetween(current, current->Start(), block_pos[reg].Start()); |
3311 AddToUnhandledSorted(tail); | 3292 AddToUnhandledSorted(tail); |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4026 } | 4007 } |
4027 } | 4008 } |
4028 } | 4009 } |
4029 } | 4010 } |
4030 } | 4011 } |
4031 | 4012 |
4032 | 4013 |
4033 } // namespace compiler | 4014 } // namespace compiler |
4034 } // namespace internal | 4015 } // namespace internal |
4035 } // namespace v8 | 4016 } // namespace v8 |
OLD | NEW |