Bug 910796 - SpiderMonkey: Micro-optimize clampIntToUint8. r=mjrosenb

This commit is contained in:
Dan Gohman 2013-09-11 08:35:38 -07:00
Родитель 4a41e9a51b
Коммит 4048e68e3a
6 изменённых файлов: 16 добавлений и 28 удалений

Просмотреть файл

@ -5183,7 +5183,7 @@ ICSetElem_TypedArray::Compiler::generateStubCode(MacroAssembler &masm)
Label notInt32; Label notInt32;
masm.branchTestInt32(Assembler::NotEqual, value, &notInt32); masm.branchTestInt32(Assembler::NotEqual, value, &notInt32);
masm.unboxInt32(value, secondScratch); masm.unboxInt32(value, secondScratch);
masm.clampIntToUint8(secondScratch, secondScratch); masm.clampIntToUint8(secondScratch);
Label clamped; Label clamped;
masm.bind(&clamped); masm.bind(&clamped);

Просмотреть файл

@ -6756,9 +6756,9 @@ CodeGenerator::visitStoreTypedArrayElementHole(LStoreTypedArrayElementHole *lir)
bool bool
CodeGenerator::visitClampIToUint8(LClampIToUint8 *lir) CodeGenerator::visitClampIToUint8(LClampIToUint8 *lir)
{ {
Register input = ToRegister(lir->input());
Register output = ToRegister(lir->output()); Register output = ToRegister(lir->output());
masm.clampIntToUint8(input, output); JS_ASSERT(output == ToRegister(lir->input()));
masm.clampIntToUint8(output);
return true; return true;
} }

Просмотреть файл

@ -1629,7 +1629,7 @@ MacroAssembler::convertValueToInt(ValueOperand value, MDefinition *maybeInput,
bind(&isInt32); bind(&isInt32);
unboxInt32(value, output); unboxInt32(value, output);
if (behavior == IntConversion_ClampToUint8) if (behavior == IntConversion_ClampToUint8)
clampIntToUint8(output, output); clampIntToUint8(output);
} }
bind(&done); bind(&done);

Просмотреть файл

@ -2386,7 +2386,7 @@ LIRGenerator::visitClampToUint8(MClampToUint8 *ins)
return redefine(ins, in); return redefine(ins, in);
case MIRType_Int32: case MIRType_Int32:
return define(new LClampIToUint8(useRegisterAtStart(in)), ins); return defineReuseInput(new LClampIToUint8(useRegisterAtStart(in)), ins, 0);
case MIRType_Double: case MIRType_Double:
return define(new LClampDToUint8(useRegisterAtStart(in), tempCopy(in, 0)), ins); return define(new LClampDToUint8(useRegisterAtStart(in), tempCopy(in, 0)), ins);

Просмотреть файл

@ -1264,13 +1264,12 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
ma_vstr(VFPRegister(src).singleOverlay(), addr.base, addr.index, scale); ma_vstr(VFPRegister(src).singleOverlay(), addr.base, addr.index, scale);
} }
void clampIntToUint8(Register src, Register dest) { void clampIntToUint8(Register reg) {
// look at (src >> 8) if it is 0, then src shouldn't be clamped // look at (reg >> 8) if it is 0, then reg shouldn't be clamped
// if it is <0, then we want to clamp to 0, otherwise, we wish to clamp to 255 // if it is <0, then we want to clamp to 0, otherwise, we wish to clamp to 255
as_mov(ScratchRegister, asr(src, 8), SetCond); as_mov(ScratchRegister, asr(reg, 8), SetCond);
ma_mov(src, dest); ma_mov(Imm32(0xff), reg, NoSetCond, NotEqual);
ma_mov(Imm32(0xff), dest, NoSetCond, NotEqual); ma_mov(Imm32(0), reg, NoSetCond, Signed);
ma_mov(Imm32(0), dest, NoSetCond, Signed);
} }
void cmp32(const Register &lhs, const Imm32 &rhs); void cmp32(const Register &lhs, const Imm32 &rhs);

Просмотреть файл

@ -423,26 +423,15 @@ class MacroAssemblerX86Shared : public Assembler
} }
} }
void clampIntToUint8(Register src, Register dest) { void clampIntToUint8(Register reg) {
Label inRange, done; Label inRange;
branchTest32(Assembler::Zero, src, Imm32(0xffffff00), &inRange); branchTest32(Assembler::Zero, reg, Imm32(0xffffff00), &inRange);
{ {
Label negative; sarl(Imm32(31), reg);
branchTest32(Assembler::Signed, src, src, &negative); notl(reg);
{ andl(Imm32(255), reg);
movl(Imm32(255), dest);
jump(&done);
}
bind(&negative);
{
xorl(dest, dest);
jump(&done);
}
} }
bind(&inRange); bind(&inRange);
if (src != dest)
movl(src, dest);
bind(&done);
} }
bool maybeInlineDouble(double d, const FloatRegister &dest) { bool maybeInlineDouble(double d, const FloatRegister &dest) {