diff options
| author | 2015-03-05 14:29:48 +0000 | |
|---|---|---|
| committer | 2015-03-05 14:29:48 +0000 | |
| commit | ea19b3696f90e07c72acb383f84305ace9b16097 (patch) | |
| tree | 2b1ddc995cba6ab9fa9fce2b04463dd9b504307e | |
| parent | af8db2ea18135588b267fe9a0b2f7af734b906cc (diff) | |
| parent | 9a9ab61ca425298f161872ed8efcf0a89b158ab2 (diff) | |
Merge "ART: Optimize iteration of safepoints"
| -rw-r--r-- | compiler/optimizing/register_allocator.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/compiler/optimizing/register_allocator.cc b/compiler/optimizing/register_allocator.cc index 54e62a5b2c..0e9c4d6f63 100644 --- a/compiler/optimizing/register_allocator.cc +++ b/compiler/optimizing/register_allocator.cc @@ -1381,6 +1381,7 @@ void RegisterAllocator::ConnectSiblings(LiveInterval* interval) { : Location::StackSlot(interval->GetParent()->GetSpillSlot())); } UsePosition* use = current->GetFirstUse(); + size_t safepoint_index = safepoints_.Size(); // Walk over all siblings, updating locations of use positions, and // connecting them when they are adjacent. @@ -1422,19 +1423,27 @@ void RegisterAllocator::ConnectSiblings(LiveInterval* interval) { } // At each safepoint, we record stack and register information. - for (size_t i = 0, e = safepoints_.Size(); i < e; ++i) { - HInstruction* safepoint = safepoints_.Get(i); + // We iterate backwards to test safepoints in ascending order of positions, + // which is what LiveInterval::Covers is optimized for. + while (safepoint_index > 0) { + HInstruction* safepoint = safepoints_.Get(--safepoint_index); size_t position = safepoint->GetLifetimePosition(); - LocationSummary* locations = safepoint->GetLocations(); - if (!current->Covers(position)) { + + // Test that safepoints are ordered in the optimal way. + DCHECK(safepoint_index == 0 + || safepoints_.Get(safepoint_index - 1)->GetLifetimePosition() >= position); + + if (current->IsDeadAt(position)) { + break; + } else if (!current->Covers(position)) { continue; - } - if (interval->GetStart() == position) { + } else if (interval->GetStart() == position) { // The safepoint is for this instruction, so the location of the instruction // does not need to be saved. continue; } + LocationSummary* locations = safepoint->GetLocations(); if ((current->GetType() == Primitive::kPrimNot) && current->GetParent()->HasSpillSlot()) { locations->SetStackBit(current->GetParent()->GetSpillSlot() / kVRegSize); } |