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 3079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3090 if (range->HasSpillOperand()) { | 3090 if (range->HasSpillOperand()) { |
3091 spill_operand = *range->GetSpillOperand(); | 3091 spill_operand = *range->GetSpillOperand(); |
3092 } else { | 3092 } else { |
3093 spill_operand = range->GetSpillRangeOperand(); | 3093 spill_operand = range->GetSpillRangeOperand(); |
3094 } | 3094 } |
3095 DCHECK(spill_operand.IsStackSlot()); | 3095 DCHECK(spill_operand.IsStackSlot()); |
3096 DCHECK_EQ(MachineRepresentation::kTagged, | 3096 DCHECK_EQ(MachineRepresentation::kTagged, |
3097 AllocatedOperand::cast(spill_operand).representation()); | 3097 AllocatedOperand::cast(spill_operand).representation()); |
3098 } | 3098 } |
3099 | 3099 |
| 3100 LiveRange* cur = range; |
3100 // Step through the safe points to see whether they are in the range. | 3101 // Step through the safe points to see whether they are in the range. |
3101 for (auto it = first_it; it != reference_maps->end(); ++it) { | 3102 for (auto it = first_it; it != reference_maps->end(); ++it) { |
3102 auto map = *it; | 3103 auto map = *it; |
3103 int safe_point = map->instruction_position(); | 3104 int safe_point = map->instruction_position(); |
3104 | 3105 |
3105 // The safe points are sorted so we can stop searching here. | 3106 // The safe points are sorted so we can stop searching here. |
3106 if (safe_point - 1 > end) break; | 3107 if (safe_point - 1 > end) break; |
3107 | 3108 |
3108 // Advance to the next active range that covers the current | 3109 // Advance to the next active range that covers the current |
3109 // safe point position. | 3110 // safe point position. |
3110 auto safe_point_pos = | 3111 auto safe_point_pos = |
3111 LifetimePosition::InstructionFromInstructionIndex(safe_point); | 3112 LifetimePosition::InstructionFromInstructionIndex(safe_point); |
3112 LiveRange* cur = range; | 3113 |
3113 while (cur != nullptr && !cur->Covers(safe_point_pos)) { | 3114 // Search for the child range (cur) that covers safe_point_pos. If we |
3114 cur = cur->next(); | 3115 // don't find it before the children pass safe_point_pos, keep cur at |
| 3116 // the last child, because the next safe_point_pos may be covered by cur. |
| 3117 // This may happen if cur has more than one interval, and the current |
| 3118 // safe_point_pos is in between intervals. |
| 3119 // For that reason, cur may be at most the last child. |
| 3120 DCHECK_NOT_NULL(cur); |
| 3121 DCHECK(safe_point_pos >= cur->Start() || range == cur); |
| 3122 bool found = false; |
| 3123 while (!found) { |
| 3124 if (cur->Covers(safe_point_pos)) { |
| 3125 found = true; |
| 3126 } else { |
| 3127 LiveRange* next = cur->next(); |
| 3128 if (next == nullptr || next->Start() > safe_point_pos) { |
| 3129 break; |
| 3130 } |
| 3131 cur = next; |
| 3132 } |
3115 } | 3133 } |
3116 if (cur == nullptr) continue; | 3134 |
| 3135 if (!found) { |
| 3136 continue; |
| 3137 } |
3117 | 3138 |
3118 // Check if the live range is spilled and the safe point is after | 3139 // Check if the live range is spilled and the safe point is after |
3119 // the spill position. | 3140 // the spill position. |
3120 int spill_index = range->IsSpilledOnlyInDeferredBlocks() | 3141 int spill_index = range->IsSpilledOnlyInDeferredBlocks() |
3121 ? cur->Start().ToInstructionIndex() | 3142 ? cur->Start().ToInstructionIndex() |
3122 : range->spill_start_index(); | 3143 : range->spill_start_index(); |
3123 | 3144 |
3124 if (!spill_operand.IsInvalid() && safe_point >= spill_index) { | 3145 if (!spill_operand.IsInvalid() && safe_point >= spill_index) { |
3125 TRACE("Pointer for range %d (spilled at %d) at safe point %d\n", | 3146 TRACE("Pointer for range %d (spilled at %d) at safe point %d\n", |
3126 range->vreg(), spill_index, safe_point); | 3147 range->vreg(), spill_index, safe_point); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3439 auto eliminate = moves->PrepareInsertAfter(move); | 3460 auto eliminate = moves->PrepareInsertAfter(move); |
3440 to_insert.push_back(move); | 3461 to_insert.push_back(move); |
3441 if (eliminate != nullptr) to_eliminate.push_back(eliminate); | 3462 if (eliminate != nullptr) to_eliminate.push_back(eliminate); |
3442 } | 3463 } |
3443 } | 3464 } |
3444 | 3465 |
3445 | 3466 |
3446 } // namespace compiler | 3467 } // namespace compiler |
3447 } // namespace internal | 3468 } // namespace internal |
3448 } // namespace v8 | 3469 } // namespace v8 |
OLD | NEW |