Changeset 36324 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Sep 10, 2008, 7:10:47 PM (17 years ago)
Author:
[email protected]
Message:

Inline immediate number version of op_mul.

Reviewed by Geoff Garen

Renamed mull_rr to imull_rr as that's what it's
actually doing, and added imull_i32r for the constant
case immediate multiply.

1.1% improvement to SunSpider.

Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r36318 r36324  
     12008-09-10  Oliver Hunt  <[email protected]>
     2
     3        Reviewed by Geoff Garen.
     4
     5        Inline immediate number version of op_mul.
     6
     7        Renamed mull_rr to imull_rr as that's what it's
     8        actually doing, and added imull_i32r for the constant
     9        case immediate multiply.
     10
     11        1.1% improvement to SunSpider.
     12
     13        * VM/CTI.cpp:
     14        (JSC::CTI::privateCompileMainPass):
     15        (JSC::CTI::privateCompileSlowCases):
     16        * masm/X86Assembler.h:
     17        (JSC::X86Assembler::):
     18        (JSC::X86Assembler::imull_rr):
     19        (JSC::X86Assembler::imull_i32r):
     20
    1212008-09-10  Cameron Zwarich  <[email protected]>
    222
  • trunk/JavaScriptCore/VM/CTI.cpp

    r36317 r36324  
    615615            break;
    616616        }
    617         CTI_COMPILE_BINARY_OP(op_mul);
     617        case op_mul: {
     618            unsigned dst = instruction[i + 1].u.operand;
     619            unsigned src1 = instruction[i + 2].u.operand;
     620            unsigned src2 = instruction[i + 3].u.operand;
     621            if (src1 < m_codeBlock->constantRegisters.size() || src2 < m_codeBlock->constantRegisters.size()) {
     622                unsigned constant = src1;
     623                unsigned nonconstant = src2;
     624                if (!(src1 < m_codeBlock->constantRegisters.size())) {
     625                    constant = src2;
     626                    nonconstant = src1;
     627                }
     628                JSValue* value = m_codeBlock->constantRegisters[constant].jsValue(m_exec);
     629                if (JSImmediate::isNumber(value)) {
     630                    emitGetArg(nonconstant, X86::eax);
     631                    emitJumpSlowCaseIfNotImm(X86::eax, i);
     632                    emitFastArithImmToInt(X86::eax);
     633                    m_jit.imull_i32r( X86::eax, getDeTaggedConstantImmediate(value), X86::eax);
     634                    m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJo(), i));
     635                    emitFastArithPotentiallyReTagImmediate(X86::eax);
     636                    emitPutResult(dst);
     637                    i += 4;
     638                    break;
     639                }
     640            }
     641
     642            emitGetArg(src1, X86::eax);
     643            emitGetArg(src2, X86::edx);
     644            emitJumpSlowCaseIfNotImms(X86::eax, X86::edx, i);
     645            emitFastArithDeTagImmediate(X86::eax);
     646            emitFastArithImmToInt(X86::edx);
     647            m_jit.imull_rr(X86::edx, X86::eax);
     648            m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJo(), i));
     649            emitFastArithPotentiallyReTagImmediate(X86::eax);
     650            emitPutResult(dst);
     651            i += 4;
     652            break;
     653        }
    618654        case op_new_func: {
    619655            FuncDeclNode* func = (m_codeBlock->functions[instruction[i + 2].u.operand]).get();
     
    12831319}
    12841320
     1321#define CTI_COMPILE_BINARY_OP_SLOW_CASE(name) \
     1322    case name: { \
     1323        m_jit.link(iter->from, m_jit.label()); \
     1324        emitGetPutArg(instruction[i + 2].u.operand, 0, X86::ecx); \
     1325        emitGetPutArg(instruction[i + 3].u.operand, 4, X86::ecx); \
     1326        emitCall(i, Machine::cti_##name); \
     1327        emitPutResult(instruction[i + 1].u.operand); \
     1328        i += 4; \
     1329        break; \
     1330    }
     1331   
    12851332void CTI::privateCompileSlowCases()
    12861333{
     
    12881335    for (Vector<SlowCaseEntry>::iterator iter = m_slowCases.begin(); iter != m_slowCases.end(); ++iter) {
    12891336        int i = iter->to;
    1290        m_jit.emitRestoreArgumentReference();
     1337        m_jit.emitRestoreArgumentReference();
    12911338        switch (m_machine->getOpcodeID(instruction[i].u.opcode)) {
    12921339        case op_add: {
     
    15901637            break;
    15911638        }
     1639        CTI_COMPILE_BINARY_OP_SLOW_CASE(op_mul);
    15921640        default:
    15931641            ASSERT_NOT_REACHED();
  • trunk/JavaScriptCore/masm/X86Assembler.h

    r36311 r36324  
    183183        OP_POP_EAX                      = 0x58,
    184184        PRE_OPERAND_SIZE                = 0x66,
     185        OP_IMUL_GvEvIz                  = 0x69,
    185186        OP_GROUP1_EvIz                  = 0x81,
    186187        OP_GROUP1_EvIb                  = 0x83,
     
    212213        OP2_JGE_rel32   = 0x8D,
    213214        OP2_JLE_rel32   = 0x8E,
    214         OP2_MUL_GvEv    = 0xAF,
     215        OP2_IMUL_GvEv   = 0xAF,
    215216        OP2_MOVZX_GvEw  = 0xB7,
    216217
     
    473474    }
    474475
    475     void mull_rr(RegisterID src, RegisterID dst)
    476     {
    477         m_buffer->putByte(OP_2BYTE_ESCAPE);
    478         m_buffer->putByte(OP2_MUL_GvEv);
     476    void imull_rr(RegisterID src, RegisterID dst)
     477    {
     478        m_buffer->putByte(OP_2BYTE_ESCAPE);
     479        m_buffer->putByte(OP2_IMUL_GvEv);
    479480        emitModRm_rr(dst, src);
     481    }
     482   
     483    void imull_i32r(RegisterID src, int32_t value, RegisterID dst)
     484    {
     485        m_buffer->putByte(OP_IMUL_GvEvIz);
     486        emitModRm_rr(dst, src);
     487        m_buffer->putInt(value);
    480488    }
    481489
Note: See TracChangeset for help on using the changeset viewer.