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 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2436 auto current = unhandled_live_ranges().back(); | 2436 auto current = unhandled_live_ranges().back(); |
2437 unhandled_live_ranges().pop_back(); | 2437 unhandled_live_ranges().pop_back(); |
2438 DCHECK(UnhandledIsSorted()); | 2438 DCHECK(UnhandledIsSorted()); |
2439 auto position = current->Start(); | 2439 auto position = current->Start(); |
2440 #ifdef DEBUG | 2440 #ifdef DEBUG |
2441 allocation_finger_ = position; | 2441 allocation_finger_ = position; |
2442 #endif | 2442 #endif |
2443 TRACE("Processing interval %d:%d start=%d\n", current->TopLevel()->vreg(), | 2443 TRACE("Processing interval %d:%d start=%d\n", current->TopLevel()->vreg(), |
2444 current->relative_id(), position.value()); | 2444 current->relative_id(), position.value()); |
2445 | 2445 |
| 2446 if (current->IsTopLevel() && !current->TopLevel()->HasNoSpillType()) { |
| 2447 TRACE("Live range %d:%d already has a spill operand\n", |
| 2448 current->TopLevel()->vreg(), current->relative_id()); |
| 2449 auto next_pos = position; |
| 2450 if (next_pos.IsGapPosition()) { |
| 2451 next_pos = next_pos.NextStart(); |
| 2452 } |
| 2453 auto pos = current->NextUsePositionRegisterIsBeneficial(next_pos); |
| 2454 // If the range already has a spill operand and it doesn't need a |
| 2455 // register immediately, split it and spill the first part of the range. |
| 2456 if (pos == nullptr) { |
| 2457 Spill(current); |
| 2458 continue; |
| 2459 } else if (pos->pos() > current->Start().NextStart()) { |
| 2460 // Do not spill live range eagerly if use position that can benefit from |
| 2461 // the register is too close to the start of live range. |
| 2462 SpillBetween(current, current->Start(), pos->pos()); |
| 2463 DCHECK(UnhandledIsSorted()); |
| 2464 continue; |
| 2465 } |
| 2466 } |
| 2467 |
2446 if (current->IsTopLevel() && TryReuseSpillForPhi(current->TopLevel())) | 2468 if (current->IsTopLevel() && TryReuseSpillForPhi(current->TopLevel())) |
2447 continue; | 2469 continue; |
2448 | 2470 |
2449 for (size_t i = 0; i < active_live_ranges().size(); ++i) { | 2471 for (size_t i = 0; i < active_live_ranges().size(); ++i) { |
2450 auto cur_active = active_live_ranges()[i]; | 2472 auto cur_active = active_live_ranges()[i]; |
2451 if (cur_active->End() <= position) { | 2473 if (cur_active->End() <= position) { |
2452 ActiveToHandled(cur_active); | 2474 ActiveToHandled(cur_active); |
2453 --i; // The live range was removed from the list of active live ranges. | 2475 --i; // The live range was removed from the list of active live ranges. |
2454 } else if (!cur_active->Covers(position)) { | 2476 } else if (!cur_active->Covers(position)) { |
2455 ActiveToInactive(cur_active); | 2477 ActiveToInactive(cur_active); |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3421 auto eliminate = moves->PrepareInsertAfter(move); | 3443 auto eliminate = moves->PrepareInsertAfter(move); |
3422 to_insert.push_back(move); | 3444 to_insert.push_back(move); |
3423 if (eliminate != nullptr) to_eliminate.push_back(eliminate); | 3445 if (eliminate != nullptr) to_eliminate.push_back(eliminate); |
3424 } | 3446 } |
3425 } | 3447 } |
3426 | 3448 |
3427 | 3449 |
3428 } // namespace compiler | 3450 } // namespace compiler |
3429 } // namespace internal | 3451 } // namespace internal |
3430 } // namespace v8 | 3452 } // namespace v8 |
OLD | NEW |