Bug 941652 - IonMonkey: Fix quadradic-time insertion into LiveInterval use lists. r=bhackett

This commit is contained in:
Dan Gohman 2013-11-23 10:38:24 -08:00
parent 8e29a45d88
commit 61d898be54
3 changed files with 15 additions and 7 deletions

View File

@ -784,7 +784,7 @@ BacktrackingAllocator::distributeUses(LiveInterval *interval,
addInterval = newInterval;
}
}
addInterval->addUse(new(alloc()) UsePosition(iter->use, iter->pos));
addInterval->addUseAtEnd(new(alloc()) UsePosition(iter->use, iter->pos));
}
}
@ -1622,7 +1622,7 @@ BacktrackingAllocator::splitAtAllRegisterUses(LiveInterval *interval)
{
LInstruction *ins = insData[iter->pos].ins();
if (iter->pos < spillStart) {
newIntervals.back()->addUse(new(alloc()) UsePosition(iter->use, iter->pos));
newIntervals.back()->addUseAtEnd(new(alloc()) UsePosition(iter->use, iter->pos));
} else if (isRegisterUse(iter->use, ins)) {
// For register uses which are not useRegisterAtStart, pick an
// interval that covers both the instruction's input and output, so
@ -1637,10 +1637,10 @@ BacktrackingAllocator::splitAtAllRegisterUses(LiveInterval *interval)
return false;
}
newIntervals.back()->addUse(new(alloc()) UsePosition(iter->use, iter->pos));
newIntervals.back()->addUseAtEnd(new(alloc()) UsePosition(iter->use, iter->pos));
} else {
JS_ASSERT(spillIntervalIsNew);
spillInterval->addUse(new(alloc()) UsePosition(iter->use, iter->pos));
spillInterval->addUseAtEnd(new(alloc()) UsePosition(iter->use, iter->pos));
}
}
@ -1724,7 +1724,7 @@ BacktrackingAllocator::splitAt(LiveInterval *interval,
for (UsePositionIterator iter(interval->usesBegin()); iter != interval->usesEnd(); iter++) {
LInstruction *ins = insData[iter->pos].ins();
if (iter->pos < spillStart) {
newIntervals.back()->addUse(new(alloc()) UsePosition(iter->use, iter->pos));
newIntervals.back()->addUseAtEnd(new(alloc()) UsePosition(iter->use, iter->pos));
activeSplitPosition = NextSplitPosition(activeSplitPosition, splitPositions, iter->pos);
} else if (isRegisterUse(iter->use, ins)) {
if (lastRegisterUse.pos() == 0 ||
@ -1740,11 +1740,11 @@ BacktrackingAllocator::splitAt(LiveInterval *interval,
splitPositions,
iter->pos);
}
newIntervals.back()->addUse(new(alloc()) UsePosition(iter->use, iter->pos));
newIntervals.back()->addUseAtEnd(new(alloc()) UsePosition(iter->use, iter->pos));
lastRegisterUse = iter->pos;
} else {
JS_ASSERT(spillIntervalIsNew);
spillInterval->addUse(new(alloc()) UsePosition(iter->use, iter->pos));
spillInterval->addUseAtEnd(new(alloc()) UsePosition(iter->use, iter->pos));
}
}

View File

@ -285,6 +285,13 @@ LiveInterval::addUse(UsePosition *use)
uses_.pushFront(use);
}
void
LiveInterval::addUseAtEnd(UsePosition *use)
{
JS_ASSERT(uses_.empty() || use->pos >= uses_.back()->pos);
uses_.pushBack(use);
}
UsePosition *
LiveInterval::nextUseAfter(CodePosition after)
{

View File

@ -356,6 +356,7 @@ class LiveInterval
bool splitFrom(CodePosition pos, LiveInterval *after);
void addUse(UsePosition *use);
void addUseAtEnd(UsePosition *use);
UsePosition *nextUseAfter(CodePosition pos);
CodePosition nextUsePosAfter(CodePosition pos);
CodePosition firstIncompatibleUse(LAllocation alloc);