Changeset 70736 in webkit


Ignore:
Timestamp:
Oct 27, 2010 6:30:09 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-10-27 Chao-ying Fu <fu@mips.com>

Reviewed by Oliver Hunt.

Support emit_op_mod() for MIPS on JSVALUE32_64
https://bugs.webkit.org/show_bug.cgi?id=46511

This patch uses MIPS div instructions for op_mod to improve performance.

  • jit/JITArithmetic32_64.cpp: (JSC::JIT::emit_op_mod):
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r70726 r70736  
     12010-10-27  Chao-ying Fu  <fu@mips.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Support emit_op_mod() for MIPS on JSVALUE32_64
     6        https://bugs.webkit.org/show_bug.cgi?id=46511
     7
     8        This patch uses MIPS div instructions for op_mod to improve performance.
     9
     10        * jit/JITArithmetic32_64.cpp:
     11        (JSC::JIT::emit_op_mod):
     12
    1132010-10-27  Brent Fulgham  <bfulgham@webkit.org>
    214
  • trunk/JavaScriptCore/jit/JITArithmetic32_64.cpp

    r70496 r70736  
    12941294/* ------------------------------ BEGIN: OP_MOD ------------------------------ */
    12951295
     1296#if CPU(X86) || CPU(X86_64) || CPU(MIPS)
     1297
     1298void JIT::emit_op_mod(Instruction* currentInstruction)
     1299{
     1300    unsigned dst = currentInstruction[1].u.operand;
     1301    unsigned op1 = currentInstruction[2].u.operand;
     1302    unsigned op2 = currentInstruction[3].u.operand;
     1303
    12961304#if CPU(X86) || CPU(X86_64)
    1297 
    1298 void JIT::emit_op_mod(Instruction* currentInstruction)
    1299 {
    1300     unsigned dst = currentInstruction[1].u.operand;
    1301     unsigned op1 = currentInstruction[2].u.operand;
    1302     unsigned op2 = currentInstruction[3].u.operand;
     1305    // Make sure registers are correct for x86 IDIV instructions.
     1306    ASSERT(regT0 == X86Registers::eax);
     1307    ASSERT(regT1 == X86Registers::edx);
     1308    ASSERT(regT2 == X86Registers::ecx);
     1309    ASSERT(regT3 == X86Registers::ebx);
     1310#endif
    13031311
    13041312    if (isOperandConstantImmediateInt(op2) && getConstantOperand(op2).asInt32() != 0) {
    1305         emitLoad(op1, X86Registers::edx, X86Registers::eax);
    1306         move(Imm32(getConstantOperand(op2).asInt32()), X86Registers::ecx);
    1307         addSlowCase(branch32(NotEqual, X86Registers::edx, Imm32(JSValue::Int32Tag)));
     1313        emitLoad(op1, regT1, regT0);
     1314        move(Imm32(getConstantOperand(op2).asInt32()), regT2);
     1315        addSlowCase(branch32(NotEqual, regT1, Imm32(JSValue::Int32Tag)));
    13081316        if (getConstantOperand(op2).asInt32() == -1)
    1309             addSlowCase(branch32(Equal, X86Registers::eax, Imm32(0x80000000))); // -2147483648 / -1 => EXC_ARITHMETIC
     1317            addSlowCase(branch32(Equal, regT0, Imm32(0x80000000))); // -2147483648 / -1 => EXC_ARITHMETIC
    13101318    } else {
    1311         emitLoad2(op1, X86Registers::edx, X86Registers::eax, op2, X86Registers::ebx, X86Registers::ecx);
    1312         addSlowCase(branch32(NotEqual, X86Registers::edx, Imm32(JSValue::Int32Tag)));
    1313         addSlowCase(branch32(NotEqual, X86Registers::ebx, Imm32(JSValue::Int32Tag)));
    1314 
    1315         addSlowCase(branch32(Equal, X86Registers::eax, Imm32(0x80000000))); // -2147483648 / -1 => EXC_ARITHMETIC
    1316         addSlowCase(branch32(Equal, X86Registers::ecx, Imm32(0))); // divide by 0
    1317     }
    1318 
    1319     move(X86Registers::eax, X86Registers::ebx); // Save dividend payload, in case of 0.
     1319        emitLoad2(op1, regT1, regT0, op2, regT3, regT2);
     1320        addSlowCase(branch32(NotEqual, regT1, Imm32(JSValue::Int32Tag)));
     1321        addSlowCase(branch32(NotEqual, regT3, Imm32(JSValue::Int32Tag)));
     1322
     1323        addSlowCase(branch32(Equal, regT0, Imm32(0x80000000))); // -2147483648 / -1 => EXC_ARITHMETIC
     1324        addSlowCase(branch32(Equal, regT2, Imm32(0))); // divide by 0
     1325    }
     1326
     1327    move(regT0, regT3); // Save dividend payload, in case of 0.
     1328#if CPU(X86) || CPU(X86_64)
    13201329    m_assembler.cdq();
    1321     m_assembler.idivl_r(X86Registers::ecx);
     1330    m_assembler.idivl_r(regT2);
     1331#elif CPU(MIPS)
     1332    m_assembler.div(regT0, regT2);
     1333    m_assembler.mfhi(regT1);
     1334#endif
    13221335
    13231336    // If the remainder is zero and the dividend is negative, the result is -0.
    1324     Jump storeResult1 = branchTest32(NonZero, X86Registers::edx);
    1325     Jump storeResult2 = branchTest32(Zero, X86Registers::ebx, Imm32(0x80000000)); // not negative
     1337    Jump storeResult1 = branchTest32(NonZero, regT1);
     1338    Jump storeResult2 = branchTest32(Zero, regT3, Imm32(0x80000000)); // not negative
    13261339    emitStore(dst, jsNumber(-0.0));
    13271340    Jump end = jump();
     
    13291342    storeResult1.link(this);
    13301343    storeResult2.link(this);
    1331     emitStoreInt32(dst, X86Registers::edx, (op1 == dst || op2 == dst));
     1344    emitStoreInt32(dst, regT1, (op1 == dst || op2 == dst));
    13321345    end.link(this);
    13331346}
     
    13561369}
    13571370
    1358 #else // CPU(X86) || CPU(X86_64)
     1371#else // CPU(X86) || CPU(X86_64) || CPU(MIPS)
    13591372
    13601373void JIT::emit_op_mod(Instruction* currentInstruction)
Note: See TracChangeset for help on using the changeset viewer.