| Index: src/compiler/greedy-allocator.cc
|
| diff --git a/src/compiler/greedy-allocator.cc b/src/compiler/greedy-allocator.cc
|
| index 63a2e436ee42e82390cc867dd473dfae5815beb6..aad322e3588eb90823fd05d51a09699fc20b78f5 100644
|
| --- a/src/compiler/greedy-allocator.cc
|
| +++ b/src/compiler/greedy-allocator.cc
|
| @@ -21,11 +21,12 @@
|
|
|
| namespace {
|
|
|
| -void UpdateOperands(LiveRange* range, RegisterAllocationData* data) {
|
| +
|
| +void UpdateOperands(TopLevelLiveRange* range, RegisterAllocationData* data) {
|
| int reg_id = range->assigned_register();
|
| range->SetUseHints(reg_id);
|
| - if (range->IsTopLevel() && range->TopLevel()->is_phi()) {
|
| - data->GetPhiMapValueFor(range->TopLevel())->set_assigned_register(reg_id);
|
| + if (range->is_phi()) {
|
| + data->GetPhiMapValueFor(range)->set_assigned_register(reg_id);
|
| }
|
| }
|
|
|
| @@ -139,7 +140,6 @@
|
| TRACE("Assigning %s to range %d%d.\n", RegisterName(reg_id),
|
| range->TopLevel()->vreg(), range->relative_id());
|
| range->set_assigned_register(reg_id);
|
| - UpdateOperands(range, data());
|
| }
|
|
|
|
|
| @@ -189,42 +189,24 @@
|
| range->relative_id());
|
| int free_reg = -1;
|
| int evictable_reg = -1;
|
| - int hinted_reg = -1;
|
| -
|
| EnsureValidRangeWeight(range);
|
| DCHECK(range->weight() != LiveRange::kInvalidWeight);
|
|
|
| - // Can we allocate at the hinted register?
|
| - if (range->FirstHintPosition(&hinted_reg) != nullptr) {
|
| - DCHECK(hinted_reg >= 0);
|
| - float max_conflict_weight = GetMaximumConflictingWeight(hinted_reg, range);
|
| + float smallest_weight = LiveRange::kMaxWeight;
|
| +
|
| + // Seek either the first free register, or, from the set of registers
|
| + // where the maximum conflict is lower than the candidate's weight, the one
|
| + // with the smallest such weight.
|
| + for (int i = 0; i < num_registers(); i++) {
|
| + float max_conflict_weight = GetMaximumConflictingWeight(i, range);
|
| if (max_conflict_weight == LiveRange::kInvalidWeight) {
|
| - free_reg = hinted_reg;
|
| - } else if (max_conflict_weight < range->weight()) {
|
| - evictable_reg = hinted_reg;
|
| - }
|
| - }
|
| -
|
| - if (free_reg < 0 && evictable_reg < 0) {
|
| - // There was no hinted reg, or we cannot allocate there.
|
| - float smallest_weight = LiveRange::kMaxWeight;
|
| -
|
| - // Seek either the first free register, or, from the set of registers
|
| - // where the maximum conflict is lower than the candidate's weight, the one
|
| - // with the smallest such weight.
|
| - for (int i = 0; i < num_registers(); i++) {
|
| - // Skip unnecessarily re-visiting the hinted register, if any.
|
| - if (i == hinted_reg) continue;
|
| - float max_conflict_weight = GetMaximumConflictingWeight(i, range);
|
| - if (max_conflict_weight == LiveRange::kInvalidWeight) {
|
| - free_reg = i;
|
| - break;
|
| - }
|
| - if (max_conflict_weight < range->weight() &&
|
| - max_conflict_weight < smallest_weight) {
|
| - smallest_weight = max_conflict_weight;
|
| - evictable_reg = i;
|
| - }
|
| + free_reg = i;
|
| + break;
|
| + }
|
| + if (max_conflict_weight < range->weight() &&
|
| + max_conflict_weight < smallest_weight) {
|
| + smallest_weight = max_conflict_weight;
|
| + evictable_reg = i;
|
| }
|
| }
|
|
|
| @@ -322,6 +304,15 @@
|
| TryAllocateCandidate(candidate);
|
| }
|
|
|
| +
|
| + // We do not rely on the hint mechanism used by LinearScan, so no need to
|
| + // actively update/reset operands until the end.
|
| + for (auto range : data()->live_ranges()) {
|
| + if (CanProcessRange(range) && range->HasRegisterAssigned()) {
|
| + UpdateOperands(range, data());
|
| + }
|
| + }
|
| +
|
| for (size_t i = 0; i < allocations_.size(); ++i) {
|
| if (!allocations_[i]->empty()) {
|
| data()->MarkAllocated(mode(), static_cast<int>(i));
|
|
|