Bug 995166 - IonMonkey: Add type policy to MFilterTypeSet, r=jandem

This commit is contained in:
Hannes Verschore 2014-05-25 22:44:24 +02:00
parent 4ba994db93
commit 0d9bf57aa8
3 changed files with 42 additions and 1 deletions

View File

@ -9393,7 +9393,8 @@ class MGuardThreadExclusive
};
class MFilterTypeSet
: public MUnaryInstruction
: public MUnaryInstruction,
public FilterTypeSetPolicy
{
MFilterTypeSet(MDefinition *def, types::TemporaryTypeSet *types)
: MUnaryInstruction(def)
@ -9411,6 +9412,9 @@ class MFilterTypeSet
return new(alloc) MFilterTypeSet(def, types);
}
TypePolicy *typePolicy() {
return this;
}
bool congruentTo(const MDefinition *def) const {
return false;
}

View File

@ -824,3 +824,34 @@ ClampPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
return true;
}
bool
FilterTypeSetPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
{
MOZ_ASSERT(ins->numOperands() == 1);
// Do nothing if already same type.
if (ins->type() == ins->getOperand(0)->type())
return true;
// Box input if ouput type is MIRType_Value
if (ins->type() == MIRType_Value) {
ins->replaceOperand(0, boxAt(alloc, ins, ins->getOperand(0)));
return true;
}
// For simplicity just mark output type as MIRType_Value if input type
// is MIRType_Value. It should be possible to unbox, but we need to
// add extra code for Undefined/Null.
if (ins->getOperand(0)->type() == MIRType_Value) {
ins->setResultType(MIRType_Value);
return true;
}
// In all other cases we will definitely bail, since types don't
// correspond. Just box and mark output as MIRType_Value.
ins->replaceOperand(0, boxAt(alloc, ins, ins->getOperand(0)));
ins->setResultType(MIRType_Value);
return true;
}

View File

@ -327,6 +327,12 @@ class ClampPolicy : public BoxInputsPolicy
bool adjustInputs(TempAllocator &alloc, MInstruction *ins);
};
class FilterTypeSetPolicy : public BoxInputsPolicy
{
public:
bool adjustInputs(TempAllocator &alloc, MInstruction *ins);
};
static inline bool
CoercesToDouble(MIRType type)
{