OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/greedy-allocator.h" | 5 #include "src/compiler/greedy-allocator.h" |
6 #include "src/compiler/register-allocator.h" | 6 #include "src/compiler/register-allocator.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 UsePosition* next_use = range->NextRegisterPosition(after_call); | 469 UsePosition* next_use = range->NextRegisterPosition(after_call); |
470 if (!next_use) return LifetimePosition::Invalid(); | 470 if (!next_use) return LifetimePosition::Invalid(); |
471 | 471 |
472 LifetimePosition split_pos = FindOptimalSplitPos(after_call, next_use->pos()); | 472 LifetimePosition split_pos = FindOptimalSplitPos(after_call, next_use->pos()); |
473 split_pos = | 473 split_pos = |
474 GetSplitPositionForInstruction(range, split_pos.ToInstructionIndex()); | 474 GetSplitPositionForInstruction(range, split_pos.ToInstructionIndex()); |
475 return split_pos; | 475 return split_pos; |
476 } | 476 } |
477 | 477 |
478 | 478 |
| 479 LifetimePosition GreedyAllocator::FindSplitPositionBeforeLoops( |
| 480 LiveRange* range) { |
| 481 LifetimePosition end = range->End(); |
| 482 if (end.ToInstructionIndex() >= code()->LastInstructionIndex()) { |
| 483 end = |
| 484 LifetimePosition::GapFromInstructionIndex(end.ToInstructionIndex() - 1); |
| 485 } |
| 486 LifetimePosition pos = FindOptimalSplitPos(range->Start(), end); |
| 487 pos = GetSplitPositionForInstruction(range, pos.ToInstructionIndex()); |
| 488 return pos; |
| 489 } |
| 490 |
| 491 |
479 void GreedyAllocator::SplitOrSpillBlockedRange(LiveRange* range) { | 492 void GreedyAllocator::SplitOrSpillBlockedRange(LiveRange* range) { |
480 if (TrySplitAroundCalls(range)) return; | 493 if (TrySplitAroundCalls(range)) return; |
481 auto pos = GetLastResortSplitPosition(range, code()); | 494 |
| 495 LifetimePosition pos = FindSplitPositionBeforeLoops(range); |
| 496 |
| 497 if (!pos.IsValid()) pos = GetLastResortSplitPosition(range, code()); |
482 if (pos.IsValid()) { | 498 if (pos.IsValid()) { |
483 LiveRange* tail = Split(range, data(), pos); | 499 LiveRange* tail = Split(range, data(), pos); |
484 DCHECK(tail != range); | 500 DCHECK(tail != range); |
485 scheduler().Schedule(tail); | 501 scheduler().Schedule(tail); |
486 scheduler().Schedule(range); | 502 scheduler().Schedule(range); |
487 return; | 503 return; |
488 } | 504 } |
489 SpillRangeAsLastResort(range); | 505 SpillRangeAsLastResort(range); |
490 } | 506 } |
491 | 507 |
492 | 508 |
493 } // namespace compiler | 509 } // namespace compiler |
494 } // namespace internal | 510 } // namespace internal |
495 } // namespace v8 | 511 } // namespace v8 |
OLD | NEW |