Bug 836000 - IonMonkey: Don't clobber out register in loadFromTypedArray. r=h4writer

This commit is contained in:
Tom Schuster 2013-01-30 13:45:24 +01:00
parent 8f268eec26
commit cba8004ad4
3 changed files with 14 additions and 11 deletions

View File

@ -4533,10 +4533,12 @@ CodeGenerator::visitLoadTypedArrayElementHole(LLoadTypedArrayElementHole *lir)
Label fail;
if (key.isConstant()) {
Address source(scratch, key.constant() * width);
masm.loadFromTypedArray(arrayType, source, out, lir->mir()->allowDouble(), &fail);
masm.loadFromTypedArray(arrayType, source, out, lir->mir()->allowDouble(),
out.scratchReg(), &fail);
} else {
BaseIndex source(scratch, key.reg(), ScaleFromElemWidth(width));
masm.loadFromTypedArray(arrayType, source, out, lir->mir()->allowDouble(), &fail);
masm.loadFromTypedArray(arrayType, source, out, lir->mir()->allowDouble(),
out.scratchReg(), &fail);
}
if (fail.used() && !bailoutFrom(&fail, lir->snapshot()))

View File

@ -172,7 +172,7 @@ template void MacroAssembler::loadFromTypedArray(int arrayType, const BaseIndex
template<typename T>
void
MacroAssembler::loadFromTypedArray(int arrayType, const T &src, const ValueOperand &dest,
bool allowDouble, Label *fail)
bool allowDouble, Register temp, Label *fail)
{
switch (arrayType) {
case TypedArray::TYPE_INT8:
@ -185,27 +185,28 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, const ValueOpera
tagValue(JSVAL_TYPE_INT32, dest.scratchReg(), dest);
break;
case TypedArray::TYPE_UINT32:
load32(src, dest.scratchReg());
test32(dest.scratchReg(), dest.scratchReg());
// Don't clobber dest when we could fail, instead use temp.
load32(src, temp);
test32(temp, temp);
if (allowDouble) {
// If the value fits in an int32, store an int32 type tag.
// Else, convert the value to double and box it.
Label done, isDouble;
j(Assembler::Signed, &isDouble);
{
tagValue(JSVAL_TYPE_INT32, dest.scratchReg(), dest);
tagValue(JSVAL_TYPE_INT32, temp, dest);
jump(&done);
}
bind(&isDouble);
{
convertUInt32ToDouble(dest.scratchReg(), ScratchFloatReg);
convertUInt32ToDouble(temp, ScratchFloatReg);
boxDouble(ScratchFloatReg, dest);
}
bind(&done);
} else {
// Bailout if the value does not fit in an int32.
j(Assembler::Signed, fail);
tagValue(JSVAL_TYPE_INT32, dest.scratchReg(), dest);
tagValue(JSVAL_TYPE_INT32, temp, dest);
}
break;
case TypedArray::TYPE_FLOAT32:
@ -220,9 +221,9 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, const ValueOpera
}
template void MacroAssembler::loadFromTypedArray(int arrayType, const Address &src, const ValueOperand &dest,
bool allowDouble, Label *fail);
bool allowDouble, Register temp, Label *fail);
template void MacroAssembler::loadFromTypedArray(int arrayType, const BaseIndex &src, const ValueOperand &dest,
bool allowDouble, Label *fail);
bool allowDouble, Register temp, Label *fail);
// Note: this function clobbers the input register.
void

View File

@ -436,7 +436,7 @@ class MacroAssembler : public MacroAssemblerSpecific
template<typename T>
void loadFromTypedArray(int arrayType, const T &src, const ValueOperand &dest, bool allowDouble,
Label *fail);
Register temp, Label *fail);
template<typename S, typename T>
void storeToTypedIntArray(int arrayType, const S &value, const T &dest) {