Bug 930437 - Remove unnecessary compilation aborts from Lowering::visitToInt32. r=bhackett

This commit is contained in:
Jan de Mooij 2013-10-26 17:18:16 +02:00
parent 34f7a76bb1
commit 5f894602d4
4 changed files with 40 additions and 10 deletions

View File

@ -1732,17 +1732,10 @@ LIRGenerator::visitToInt32(MToInt32 *convert)
}
case MIRType_String:
// Strings are complicated - we don't handle them yet.
IonSpew(IonSpew_Abort, "String to Int32 not supported yet.");
return false;
case MIRType_Object:
// Objects might be effectful.
IonSpew(IonSpew_Abort, "Object to Int32 not supported yet.");
return false;
case MIRType_Undefined:
IonSpew(IonSpew_Abort, "Undefined coerces to NaN, not int32_t.");
// Objects might be effectful. Undefined coerces to NaN, not int32.
MOZ_ASSUME_UNREACHABLE("ToInt32 invalid input type");
return false;
default:

View File

@ -2919,7 +2919,9 @@ class MAsmJSUnsignedToFloat32
// Converts a primitive (either typed or untyped) to an int32. If the input is
// not primitive at runtime, a bailout occurs. If the input cannot be converted
// to an int32 without loss (i.e. "5.5" or undefined) then a bailout occurs.
class MToInt32 : public MUnaryInstruction
class MToInt32
: public MUnaryInstruction,
public ToInt32Policy
{
bool canBeNegativeZero_;
@ -2950,6 +2952,10 @@ class MToInt32 : public MUnaryInstruction
canBeNegativeZero_ = negativeZero;
}
TypePolicy *typePolicy() {
return this;
}
bool congruentTo(MDefinition *ins) const {
return congruentIfOperandsEqual(ins);
}

View File

@ -536,6 +536,27 @@ ToDoublePolicy::staticAdjustInputs(MInstruction *ins)
return true;
}
bool
ToInt32Policy::staticAdjustInputs(MInstruction *ins)
{
JS_ASSERT(ins->isToInt32());
MDefinition *in = ins->getOperand(0);
switch (in->type()) {
case MIRType_Object:
case MIRType_String:
case MIRType_Undefined:
// Objects might be effectful. Undefined coerces to NaN, not int32.
in = boxAt(ins, in);
ins->replaceOperand(0, in);
break;
default:
break;
}
return true;
}
template <unsigned Op>
bool
ObjectPolicy<Op>::staticAdjustInputs(MInstruction *ins)

View File

@ -194,6 +194,16 @@ class ToDoublePolicy : public BoxInputsPolicy
}
};
// Box objects, strings and undefined as input to a ToInt32 instruction.
class ToInt32Policy : public BoxInputsPolicy
{
public:
static bool staticAdjustInputs(MInstruction *def);
bool adjustInputs(MInstruction *def) {
return staticAdjustInputs(def);
}
};
template <unsigned Op>
class ObjectPolicy : public BoxInputsPolicy
{