diff --git a/js/src/assembler/assembler/AbstractMacroAssembler.h b/js/src/assembler/assembler/AbstractMacroAssembler.h index 91475f86cd8d..bacfc94de9ca 100644 --- a/js/src/assembler/assembler/AbstractMacroAssembler.h +++ b/js/src/assembler/assembler/AbstractMacroAssembler.h @@ -389,7 +389,7 @@ public: void link(AbstractMacroAssembler* 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* 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(); diff --git a/js/src/assembler/assembler/X86Assembler.h b/js/src/assembler/assembler/X86Assembler.h index 9ae094e4c034..da53f27c71a0 100644 --- a/js/src/assembler/assembler/X86Assembler.h +++ b/js/src/assembler/assembler/X86Assembler.h @@ -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() diff --git a/js/src/methodjit/Compiler.h b/js/src/methodjit/Compiler.h index 82147db1fe2c..f1d235982e30 100644 --- a/js/src/methodjit/Compiler.h +++ b/js/src/methodjit/Compiler.h @@ -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; diff --git a/js/src/methodjit/FastArithmetic.cpp b/js/src/methodjit/FastArithmetic.cpp index c06d37522def..12de85024a13 100644 --- a/js/src/methodjit/FastArithmetic.cpp +++ b/js/src/methodjit/FastArithmetic.cpp @@ -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);