Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Side by Side Diff: src/compiler/greedy-allocator.cc

Issue 1353023003: [turbofan] Merge group spill ranges. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/greedy-allocator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 TryAllocateCandidate(candidate); 472 TryAllocateCandidate(candidate);
473 } 473 }
474 474
475 for (size_t i = 0; i < allocations_.size(); ++i) { 475 for (size_t i = 0; i < allocations_.size(); ++i) {
476 if (!allocations_[i]->empty()) { 476 if (!allocations_[i]->empty()) {
477 data()->MarkAllocated(mode(), static_cast<int>(i)); 477 data()->MarkAllocated(mode(), static_cast<int>(i));
478 } 478 }
479 } 479 }
480 allocations_.clear(); 480 allocations_.clear();
481 481
482 TryReuseSpillRangesForGroups();
483
482 TRACE("End allocating function %s with the Greedy Allocator\n", 484 TRACE("End allocating function %s with the Greedy Allocator\n",
483 data()->debug_name()); 485 data()->debug_name());
484 } 486 }
485 487
486 488
489 void GreedyAllocator::TryReuseSpillRangesForGroups() {
490 for (TopLevelLiveRange* top : data()->live_ranges()) {
491 if (!CanProcessRange(top) || !top->is_phi() || top->group() == nullptr) {
492 continue;
493 }
494
495 SpillRange* spill_range = nullptr;
496 for (LiveRange* member : top->group()->ranges()) {
497 if (!member->TopLevel()->HasSpillRange()) continue;
498 SpillRange* member_range = member->TopLevel()->GetSpillRange();
499 if (spill_range == nullptr) {
500 spill_range = member_range;
501 } else {
502 // This may not always succeed, because we group non-conflicting ranges
503 // that may have been splintered, and the splinters may cause conflicts
504 // in the spill ranges.
505 // TODO(mtrofin): should the splinters own their own spill ranges?
506 spill_range->TryMerge(member_range);
507 }
508 }
509 }
510 }
511
512
487 float GreedyAllocator::GetMaximumConflictingWeight( 513 float GreedyAllocator::GetMaximumConflictingWeight(
488 unsigned reg_id, const LiveRange* range, float competing_weight) const { 514 unsigned reg_id, const LiveRange* range, float competing_weight) const {
489 float ret = LiveRange::kInvalidWeight; 515 float ret = LiveRange::kInvalidWeight;
490 516
491 auto conflicts = current_allocations(reg_id)->GetConflicts(range); 517 auto conflicts = current_allocations(reg_id)->GetConflicts(range);
492 for (LiveRange* conflict = conflicts.Current(); conflict != nullptr; 518 for (LiveRange* conflict = conflicts.Current(); conflict != nullptr;
493 conflict = conflicts.GetNext()) { 519 conflict = conflicts.GetNext()) {
494 DCHECK_NE(conflict->weight(), LiveRange::kInvalidWeight); 520 DCHECK_NE(conflict->weight(), LiveRange::kInvalidWeight);
495 if (competing_weight <= conflict->weight()) return LiveRange::kMaxWeight; 521 if (competing_weight <= conflict->weight()) return LiveRange::kMaxWeight;
496 ret = Max(ret, conflict->weight()); 522 ret = Max(ret, conflict->weight());
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 scheduler().Schedule(range); 690 scheduler().Schedule(range);
665 return; 691 return;
666 } 692 }
667 SpillRangeAsLastResort(range); 693 SpillRangeAsLastResort(range);
668 } 694 }
669 695
670 696
671 } // namespace compiler 697 } // namespace compiler
672 } // namespace internal 698 } // namespace internal
673 } // namespace v8 699 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/greedy-allocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698