[JAEGER] Convert result of division to integer if possible (bug 585272, r=dvander).

This commit is contained in:
Jan de Mooij 2010-08-09 10:18:29 -07:00
Родитель 68ccb5f8f9
Коммит 67cc55f592
4 изменённых файлов: 29 добавлений и 8 удалений

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

@ -389,7 +389,7 @@ public:
void link(AbstractMacroAssembler<AssemblerType>* masm)
{
size_t size = m_jumps.size();
size_t size = m_jumps.length();
for (size_t i = 0; i < size; ++i)
m_jumps[i].link(masm);
m_jumps.clear();
@ -397,7 +397,7 @@ public:
void linkTo(Label label, AbstractMacroAssembler<AssemblerType>* masm)
{
size_t size = m_jumps.size();
size_t size = m_jumps.length();
for (size_t i = 0; i < size; ++i)
m_jumps[i].linkTo(label, masm);
m_jumps.clear();

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

@ -1668,9 +1668,7 @@ public:
JmpSrc jne()
{
FIXME_INSN_PRINTING;
m_formatter.twoByteOp(jccRel32(ConditionNE));
return m_formatter.immediateRel32();
return jCC(ConditionNE);
}
JmpSrc jnz()
@ -1757,9 +1755,7 @@ public:
JmpSrc jp()
{
FIXME_INSN_PRINTING;
m_formatter.twoByteOp(jccRel32(ConditionP));
return m_formatter.immediateRel32();
return jCC(ConditionP);
}
JmpSrc js()

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

@ -62,6 +62,7 @@ class Compiler
typedef JSC::MacroAssembler::Address Address;
typedef JSC::MacroAssembler::BaseIndex BaseIndex;
typedef JSC::MacroAssembler::Jump Jump;
typedef JSC::MacroAssembler::JumpList JumpList;
typedef JSC::MacroAssembler::Call Call;
typedef JSC::MacroAssembler::DataLabelPtr DataLabelPtr;

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

@ -321,8 +321,32 @@ mjit::Compiler::jsop_binary_double(FrameEntry *lhs, FrameEntry *rhs, JSOp op, Vo
}
EmitDoubleOp(op, fpRight, fpLeft, masm);
MaybeJump done;
/*
* Try to convert result to integer. Skip this for 1/x or -1/x, as the
* result is unlikely to fit in an int.
*/
if (op == JSOP_DIV && !(lhs->isConstant() && lhs->isType(JSVAL_TYPE_INT32) &&
abs(lhs->getValue().toInt32()) == 1)) {
RegisterID reg = frame.allocReg();
JumpList isDouble;
masm.branchConvertDoubleToInt32(fpLeft, reg, isDouble, fpRight);
masm.storePayload(reg, frame.addressOf(lhs));
masm.storeTypeTag(ImmType(JSVAL_TYPE_INT32), frame.addressOf(lhs));
frame.freeReg(reg);
done.setJump(masm.jump());
isDouble.linkTo(masm.label(), &masm);
}
masm.storeDouble(fpLeft, frame.addressOf(lhs));
if (done.isSet())
done.getJump().linkTo(masm.label(), &masm);
if (lhsNotNumber.isSet() || rhsNotNumber.isSet()) {
stubcc.leave();
stubcc.call(stub);