зеркало из https://github.com/mozilla/gecko-dev.git
Micro-optimize a hot spot in LinearScan; this partially addresses Bug 741317. r=jandem
This commit is contained in:
Родитель
4b9e8c3302
Коммит
a25460eaeb
|
@ -164,6 +164,9 @@ class LAllocation : public TempObject
|
|||
bool isRegister() const {
|
||||
return isGeneralReg() || isFloatReg();
|
||||
}
|
||||
bool isRegister(bool needFloat) const {
|
||||
return needFloat ? isFloatReg() : isGeneralReg();
|
||||
}
|
||||
bool isMemory() const {
|
||||
return isStackSlot() || isArgument();
|
||||
}
|
||||
|
|
|
@ -906,21 +906,22 @@ LinearScanAllocator::findBestFreeRegister(CodePosition *freeUntil)
|
|||
// Compute free-until positions for all registers
|
||||
CodePosition freeUntilPos[AnyRegister::Total];
|
||||
bool needFloat = vregs[current->vreg()].isDouble();
|
||||
for (AnyRegisterIterator regs(allRegisters_); regs.more(); regs++) {
|
||||
AnyRegister reg = *regs;
|
||||
if (reg.isFloat() == needFloat)
|
||||
freeUntilPos[reg.code()] = CodePosition::MAX;
|
||||
for (RegisterSet regs(allRegisters_); !regs.empty(needFloat); ) {
|
||||
AnyRegister reg = regs.takeAny(needFloat);
|
||||
freeUntilPos[reg.code()] = CodePosition::MAX;
|
||||
}
|
||||
for (IntervalIterator i(active.begin()); i != active.end(); i++) {
|
||||
if (i->getAllocation()->isRegister()) {
|
||||
AnyRegister reg = i->getAllocation()->toRegister();
|
||||
LAllocation *alloc = i->getAllocation();
|
||||
if (alloc->isRegister(needFloat)) {
|
||||
AnyRegister reg = alloc->toRegister();
|
||||
IonSpew(IonSpew_RegAlloc, " Register %s not free", reg.name());
|
||||
freeUntilPos[reg.code()] = CodePosition::MIN;
|
||||
}
|
||||
}
|
||||
for (IntervalIterator i(inactive.begin()); i != inactive.end(); i++) {
|
||||
if (i->getAllocation()->isRegister()) {
|
||||
AnyRegister reg = i->getAllocation()->toRegister();
|
||||
LAllocation *alloc = i->getAllocation();
|
||||
if (alloc->isRegister(needFloat)) {
|
||||
AnyRegister reg = alloc->toRegister();
|
||||
CodePosition pos = current->intersect(*i);
|
||||
if (pos != CodePosition::MIN && pos < freeUntilPos[reg.code()]) {
|
||||
freeUntilPos[reg.code()] = pos;
|
||||
|
@ -948,8 +949,9 @@ LinearScanAllocator::findBestFreeRegister(CodePosition *freeUntil)
|
|||
// As an optimization, use the allocation from the previous interval if
|
||||
// it is available.
|
||||
LiveInterval *previous = vregs[current->vreg()].getInterval(current->index() - 1);
|
||||
if (previous->getAllocation()->isRegister()) {
|
||||
AnyRegister prevReg = previous->getAllocation()->toRegister();
|
||||
LAllocation *alloc = previous->getAllocation();
|
||||
if (alloc->isRegister(needFloat)) {
|
||||
AnyRegister prevReg = alloc->toRegister();
|
||||
if (freeUntilPos[prevReg.code()] != CodePosition::MIN)
|
||||
bestCode = prevReg.code();
|
||||
}
|
||||
|
@ -999,14 +1001,14 @@ LinearScanAllocator::findBestBlockedRegister(CodePosition *nextUsed)
|
|||
// Compute next-used positions for all registers
|
||||
CodePosition nextUsePos[AnyRegister::Total];
|
||||
bool needFloat = vregs[current->vreg()].isDouble();
|
||||
for (AnyRegisterIterator regs(allRegisters_); regs.more(); regs++) {
|
||||
AnyRegister reg = *regs;
|
||||
if (reg.isFloat() == needFloat)
|
||||
nextUsePos[reg.code()] = CodePosition::MAX;
|
||||
for (RegisterSet regs(allRegisters_); !regs.empty(needFloat); ) {
|
||||
AnyRegister reg = regs.takeAny(needFloat);
|
||||
nextUsePos[reg.code()] = CodePosition::MAX;
|
||||
}
|
||||
for (IntervalIterator i(active.begin()); i != active.end(); i++) {
|
||||
if (i->getAllocation()->isRegister()) {
|
||||
AnyRegister reg = i->getAllocation()->toRegister();
|
||||
LAllocation *alloc = i->getAllocation();
|
||||
if (alloc->isRegister(needFloat)) {
|
||||
AnyRegister reg = alloc->toRegister();
|
||||
if (i->start().ins() == current->start().ins()) {
|
||||
nextUsePos[reg.code()] = CodePosition::MIN;
|
||||
IonSpew(IonSpew_RegAlloc, " Disqualifying %s due to recency", reg.name());
|
||||
|
@ -1018,8 +1020,9 @@ LinearScanAllocator::findBestBlockedRegister(CodePosition *nextUsed)
|
|||
}
|
||||
}
|
||||
for (IntervalIterator i(inactive.begin()); i != inactive.end(); i++) {
|
||||
if (i->getAllocation()->isRegister()) {
|
||||
AnyRegister reg = i->getAllocation()->toRegister();
|
||||
LAllocation *alloc = i->getAllocation();
|
||||
if (alloc->isRegister(needFloat)) {
|
||||
AnyRegister reg = alloc->toRegister();
|
||||
CodePosition pos = i->nextUsePosAfter(current->start());
|
||||
if (pos < nextUsePos[reg.code()]) {
|
||||
nextUsePos[reg.code()] = pos;
|
||||
|
|
Загрузка…
Ссылка в новой задаче