Bug 652321 - Enable fast path for jsop_mod on 64-bit. r=dvander
authorJan de Mooij <jandemooij@gmail.com>
Tue, 17 May 2011 13:58:29 +0200
changeset 69905 e6c5fbc0b542b8ee11b1a1259d137b46f410a9cc
parent 69904 e0288c977846001e84b7db001e623cdeff5cb645
child 69906 ab172b4ca00d973e842ed5d2cf4d174f55f7811c
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdvander
bugs652321
milestone6.0a1
Bug 652321 - Enable fast path for jsop_mod on 64-bit. r=dvander
js/src/assembler/assembler/MacroAssemblerX86Common.h
js/src/methodjit/BaseAssembler.h
js/src/methodjit/FastArithmetic.cpp
--- a/js/src/assembler/assembler/MacroAssemblerX86Common.h
+++ b/js/src/assembler/assembler/MacroAssemblerX86Common.h
@@ -198,16 +198,22 @@ public:
         m_assembler.imull_mr(src.offset, src.base, dest);
     }
     
     void mul32(Imm32 imm, RegisterID src, RegisterID dest)
     {
         m_assembler.imull_i32r(src, imm.m_value, dest);
     }
 
+    void idiv(RegisterID reg)
+    {
+        m_assembler.cdq();
+        m_assembler.idivl_r(reg);
+    }
+
     void neg32(RegisterID srcDest)
     {
         m_assembler.negl_r(srcDest);
     }
 
     void neg32(Address srcDest)
     {
         m_assembler.negl_m(srcDest.offset, srcDest.base);
--- a/js/src/methodjit/BaseAssembler.h
+++ b/js/src/methodjit/BaseAssembler.h
@@ -259,23 +259,16 @@ static const JSC::MacroAssembler::Regist
      * Finds and returns the address of a known object and slot.
      */
     Address objSlotRef(JSObject *obj, RegisterID reg, uint32 slot) {
         move(ImmPtr(&obj->slots), reg);
         loadPtr(reg, reg);
         return Address(reg, slot * sizeof(Value));
     }
 
-#ifdef JS_CPU_X86
-    void idiv(RegisterID reg) {
-        m_assembler.cdq();
-        m_assembler.idivl_r(reg);
-    }
-#endif
-
     /* Prepare for a call that might THROW. */
     void *getFallibleCallTarget(void *fun) {
 #ifdef JS_CPU_ARM
         /*
          * Insert a veneer for ARM to allow it to catch exceptions. There is no
          * reliable way to determine the location of the return address on the
          * stack, so a typical C(++) return address cannot be hijacked.
          *
--- a/js/src/methodjit/FastArithmetic.cpp
+++ b/js/src/methodjit/FastArithmetic.cpp
@@ -826,17 +826,17 @@ mjit::Compiler::jsop_neg()
         stubcc.crossJump(jmpIntRejoin.getJump(), masm.label());
 
     stubcc.rejoin(Changes(1));
 }
 
 void
 mjit::Compiler::jsop_mod()
 {
-#if defined(JS_CPU_X86)
+#if defined(JS_CPU_X86) || defined(JS_CPU_X64)
     FrameEntry *lhs = frame.peek(-2);
     FrameEntry *rhs = frame.peek(-1);
 
     if (tryBinaryConstantFold(cx, frame, JSOP_MOD, lhs, rhs))
         return;
 
     if ((lhs->isTypeKnown() && lhs->getKnownType() != JSVAL_TYPE_INT32) ||
         (rhs->isTypeKnown() && rhs->getKnownType() != JSVAL_TYPE_INT32))
@@ -844,17 +844,17 @@ mjit::Compiler::jsop_mod()
     {
         prepareStubCall(Uses(2));
         INLINE_STUBCALL(stubs::Mod);
         frame.popn(2);
         frame.pushSynced();
         return;
     }
 
-#if defined(JS_CPU_X86)
+#if defined(JS_CPU_X86) || defined(JS_CPU_X64)
     if (!lhs->isTypeKnown()) {
         Jump j = frame.testInt32(Assembler::NotEqual, lhs);
         stubcc.linkExit(j, Uses(2));
     }
     if (!rhs->isTypeKnown()) {
         Jump j = frame.testInt32(Assembler::NotEqual, rhs);
         stubcc.linkExit(j, Uses(2));
     }