Changeset 36324 in webkit for trunk/JavaScriptCore/VM/CTI.cpp


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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();
Note: See TracChangeset for help on using the changeset viewer.