Bug 898576 - Ignore cold phi inputs when specializing phi types. (r=jandem)

This commit is contained in:
Shu-yu Guo 2013-08-02 08:24:56 -07:00
parent a0524f193c
commit fc8f2bd575

View File

@ -416,6 +416,10 @@ GuessPhiType(MPhi *phi)
continue;
}
if (type != in->type()) {
// Ignore operands which we've never observed.
if (in->resultTypeSet() && in->resultTypeSet()->empty())
continue;
// Specialize phis with int32 and double operands as double.
if (IsNumberType(type) && IsNumberType(in->type()))
type = MIRType_Double;
@ -520,6 +524,10 @@ TypeAnalyzer::adjustPhiInputs(MPhi *phi)
MToDouble *toDouble = MToDouble::New(in);
in->block()->insertBefore(in->block()->lastIns(), toDouble);
phi->replaceOperand(i, toDouble);
} else if (in->type() == MIRType_Value) {
MUnbox *unbox = MUnbox::New(in, MIRType_Double, MUnbox::Fallible);
in->block()->insertBefore(in->block()->lastIns(), unbox);
phi->replaceOperand(i, unbox);
} else {
JS_ASSERT(in->type() == MIRType_Double);
}
@ -527,8 +535,26 @@ TypeAnalyzer::adjustPhiInputs(MPhi *phi)
return;
}
if (phiType != MIRType_Value)
// If we specialized a type that's not Value, either every input is of
// that type or the input's typeset was unobserved (i.e. the opcode hasn't
// been executed yet.) Be optimistic and insert unboxes.
if (phiType != MIRType_Value) {
for (size_t i = 0, e = phi->numOperands(); i < e; i++) {
MDefinition *in = phi->getOperand(i);
if (in->type() == phiType)
continue;
if (in->isBox() && in->toBox()->input()->type() == phiType) {
phi->replaceOperand(i, in->toBox()->input());
} else {
MUnbox *unbox = MUnbox::New(in, phiType, MUnbox::Fallible);
in->block()->insertBefore(in->block()->lastIns(), unbox);
phi->replaceOperand(i, unbox);
}
}
return;
}
// Box every typed input.
for (size_t i = 0, e = phi->numOperands(); i < e; i++) {