| 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 2929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2940 for (int i = 1; i < num_allocatable_registers(); ++i) { | 2940 for (int i = 1; i < num_allocatable_registers(); ++i) { |
| 2941 int code = allocatable_register_code(i); | 2941 int code = allocatable_register_code(i); |
| 2942 if (use_pos[code] > use_pos[reg]) { | 2942 if (use_pos[code] > use_pos[reg]) { |
| 2943 reg = code; | 2943 reg = code; |
| 2944 } | 2944 } |
| 2945 } | 2945 } |
| 2946 | 2946 |
| 2947 LifetimePosition pos = use_pos[reg]; | 2947 LifetimePosition pos = use_pos[reg]; |
| 2948 | 2948 |
| 2949 if (pos < register_use->pos()) { | 2949 if (pos < register_use->pos()) { |
| 2950 // All registers are blocked before the first use that requires a register. | 2950 if (LifetimePosition::ExistsGapPositionBetween(current->Start(), |
| 2951 // Spill starting part of live range up to that use. | 2951 register_use->pos())) { |
| 2952 SpillBetween(current, current->Start(), register_use->pos()); | 2952 SpillBetween(current, current->Start(), register_use->pos()); |
| 2953 } else { |
| 2954 SetLiveRangeAssignedRegister(current, reg); |
| 2955 SplitAndSpillIntersecting(current); |
| 2956 } |
| 2953 return; | 2957 return; |
| 2954 } | 2958 } |
| 2955 | 2959 |
| 2956 if (block_pos[reg] < current->End()) { | 2960 if (block_pos[reg] < current->End()) { |
| 2957 // Register becomes blocked before the current range end. Split before that | 2961 // Register becomes blocked before the current range end. Split before that |
| 2958 // position. | 2962 // position. |
| 2959 LiveRange* tail = | 2963 LiveRange* tail = |
| 2960 SplitBetween(current, current->Start(), block_pos[reg].Start()); | 2964 SplitBetween(current, current->Start(), block_pos[reg].Start()); |
| 2961 AddToUnhandledSorted(tail); | 2965 AddToUnhandledSorted(tail); |
| 2962 } | 2966 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2987 SpillAfter(range, spill_pos); | 2991 SpillAfter(range, spill_pos); |
| 2988 } else { | 2992 } else { |
| 2989 // When spilling between spill_pos and next_pos ensure that the range | 2993 // When spilling between spill_pos and next_pos ensure that the range |
| 2990 // remains spilled at least until the start of the current live range. | 2994 // remains spilled at least until the start of the current live range. |
| 2991 // This guarantees that we will not introduce new unhandled ranges that | 2995 // This guarantees that we will not introduce new unhandled ranges that |
| 2992 // start before the current range as this violates allocation invariant | 2996 // start before the current range as this violates allocation invariant |
| 2993 // and will lead to an inconsistent state of active and inactive | 2997 // and will lead to an inconsistent state of active and inactive |
| 2994 // live-ranges: ranges are allocated in order of their start positions, | 2998 // live-ranges: ranges are allocated in order of their start positions, |
| 2995 // ranges are retired from active/inactive when the start of the | 2999 // ranges are retired from active/inactive when the start of the |
| 2996 // current live-range is larger than their end. | 3000 // current live-range is larger than their end. |
| 3001 DCHECK(LifetimePosition::ExistsGapPositionBetween(current->Start(), |
| 3002 next_pos->pos())); |
| 2997 SpillBetweenUntil(range, spill_pos, current->Start(), next_pos->pos()); | 3003 SpillBetweenUntil(range, spill_pos, current->Start(), next_pos->pos()); |
| 2998 } | 3004 } |
| 2999 ActiveToHandled(range); | 3005 ActiveToHandled(range); |
| 3000 --i; | 3006 --i; |
| 3001 } | 3007 } |
| 3002 } | 3008 } |
| 3003 | 3009 |
| 3004 for (size_t i = 0; i < inactive_live_ranges().size(); ++i) { | 3010 for (size_t i = 0; i < inactive_live_ranges().size(); ++i) { |
| 3005 LiveRange* range = inactive_live_ranges()[i]; | 3011 LiveRange* range = inactive_live_ranges()[i]; |
| 3006 DCHECK(range->End() > current->Start()); | 3012 DCHECK(range->End() > current->Start()); |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3654 spill_block->mark_needs_frame(); | 3660 spill_block->mark_needs_frame(); |
| 3655 } | 3661 } |
| 3656 } | 3662 } |
| 3657 } | 3663 } |
| 3658 } | 3664 } |
| 3659 | 3665 |
| 3660 | 3666 |
| 3661 } // namespace compiler | 3667 } // namespace compiler |
| 3662 } // namespace internal | 3668 } // namespace internal |
| 3663 } // namespace v8 | 3669 } // namespace v8 |
| OLD | NEW |