Bug 933369 part 2 - Fix Load/Store TypedArrayElementStatic type policy. r=bhackett

This commit is contained in:
Jan de Mooij 2013-11-06 17:18:15 +01:00
parent af5718205b
commit 6be5261be5
3 changed files with 29 additions and 2 deletions

View File

@ -5816,7 +5816,7 @@ class MLoadTypedArrayElementHole
// Load a value fallibly or infallibly from a statically known typed array.
class MLoadTypedArrayElementStatic
: public MUnaryInstruction,
public IntPolicy<0>
public ConvertToInt32Policy<0>
{
MLoadTypedArrayElementStatic(TypedArrayObject *typedArray, MDefinition *ptr)
: MUnaryInstruction(ptr), typedArray_(typedArray), fallible_(true)

View File

@ -425,6 +425,22 @@ template bool IntPolicy<0>::staticAdjustInputs(MInstruction *def);
template bool IntPolicy<1>::staticAdjustInputs(MInstruction *def);
template bool IntPolicy<2>::staticAdjustInputs(MInstruction *def);
template <unsigned Op>
bool
ConvertToInt32Policy<Op>::staticAdjustInputs(MInstruction *def)
{
MDefinition *in = def->getOperand(Op);
if (in->type() == MIRType_Int32)
return true;
MToInt32 *replace = MToInt32::New(in);
def->block()->insertBefore(def, replace);
def->replaceOperand(Op, replace);
return true;
}
template bool ConvertToInt32Policy<0>::staticAdjustInputs(MInstruction *def);
template <unsigned Op>
bool
DoublePolicy<Op>::staticAdjustInputs(MInstruction *def)
@ -742,7 +758,7 @@ StoreTypedArrayElementStaticPolicy::adjustInputs(MInstruction *ins)
{
MStoreTypedArrayElementStatic *store = ins->toStoreTypedArrayElementStatic();
return IntPolicy<0>::staticAdjustInputs(ins) &&
return ConvertToInt32Policy<0>::staticAdjustInputs(ins) &&
adjustValueInput(ins, store->viewType(), store->value(), 1);
}

View File

@ -134,6 +134,17 @@ class IntPolicy : public BoxInputsPolicy
}
};
// Expect an Int for operand Op. Else a ToInt32 instruction is inserted.
template <unsigned Op>
class ConvertToInt32Policy : public BoxInputsPolicy
{
public:
static bool staticAdjustInputs(MInstruction *def);
bool adjustInputs(MInstruction *def) {
return staticAdjustInputs(def);
}
};
// Expect a double for operand Op. If the input is a Value, it is unboxed.
template <unsigned Op>
class DoublePolicy : public BoxInputsPolicy