Changeset 39058 in webkit for trunk/JavaScriptCore/jit/JIT.cpp


Ignore:
Timestamp:
Dec 5, 2008, 5:36:16 PM (16 years ago)
Author:
[email protected]
Message:

2008-12-05 Gavin Barraclough <[email protected]>

Reviewed by Geoff Garen.

Second tranche of porting JIT.cpp to MacroAssembler interface.

  • assembler/MacroAssembler.h: (JSC::MacroAssembler::mul32): (JSC::MacroAssembler::jl32): (JSC::MacroAssembler::jnzSub32): (JSC::MacroAssembler::joAdd32): (JSC::MacroAssembler::joMul32): (JSC::MacroAssembler::jzSub32):
  • jit/JIT.cpp: (JSC::JIT::emitSlowScriptCheck): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JIT.h:
  • jit/JITInlineMethods.h: (JSC::JIT::emitJumpIfNotJSCell): (JSC::JIT::emitJumpSlowCaseIfNotJSCell):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JIT.cpp

    r39055 r39058  
    256256void JIT::emitSlowScriptCheck(unsigned bytecodeIndex)
    257257{
    258     __ subl_i8r(1, X86::esi);
    259     JmpSrc skipTimeout = __ jne();
     258    Jump skipTimeout = jnzSub32(Imm32(1), X86::esi);
    260259    emitCTICall(bytecodeIndex, Interpreter::cti_timeout_check);
    261     __ movl_rr(X86::eax, X86::esi);
    262     __ link(skipTimeout, __ label());
     260    move(X86::eax, X86::esi);
     261    skipTimeout.link(this);
    263262
    264263    killLastResultRegister();
     
    278277#if ENABLE(OPCODE_SAMPLING)
    279278        if (i > 0) // Avoid the overhead of sampling op_enter twice.
    280             __ movl_i32m(m_interpreter->sampler()->encodeSample(instruction + i), m_interpreter->sampler()->sampleSlot());
     279            store32(m_interpreter->sampler()->encodeSample(instruction + i), m_interpreter->sampler()->sampleSlot());
    281280#endif
    282281
     
    285284        switch (opcodeID) {
    286285        case op_mov: {
    287             unsigned src = instruction[i + 2].u.operand;
    288             if (m_codeBlock->isConstantRegisterIndex(src))
    289                 __ movl_i32r(asInteger(m_codeBlock->getConstant(src)), X86::eax);
    290             else
    291                 emitGetVirtualRegister(src, X86::eax, i);
     286            emitGetVirtualRegister(instruction[i + 2].u.operand, X86::eax, i);
    292287            emitPutVirtualRegister(instruction[i + 1].u.operand);
    293288            i += 3;
     
    302297                emitGetVirtualRegister(src2, X86::eax, i);
    303298                emitJumpSlowCaseIfNotImmNum(X86::eax, i);
    304                 __ addl_i32r(getDeTaggedConstantImmediate(value), X86::eax);
    305                 m_slowCases.append(SlowCaseEntry(__ jo(), i));
     299                m_slowCases.append(SlowCaseEntry(joAdd32(Imm32(getDeTaggedConstantImmediate(value)), X86::eax), i));
    306300                emitPutVirtualRegister(dst);
    307301            } else if (JSValue* value = getConstantImmediateNumericArg(src2)) {
    308302                emitGetVirtualRegister(src1, X86::eax, i);
    309303                emitJumpSlowCaseIfNotImmNum(X86::eax, i);
    310                 __ addl_i32r(getDeTaggedConstantImmediate(value), X86::eax);
    311                 m_slowCases.append(SlowCaseEntry(__ jo(), i));
     304                m_slowCases.append(SlowCaseEntry(joAdd32(Imm32(getDeTaggedConstantImmediate(value)), X86::eax), i));
    312305                emitPutVirtualRegister(dst);
    313306            } else {
     
    337330        case op_jmp: {
    338331            unsigned target = instruction[i + 1].u.operand;
    339             m_jmpTable.append(JmpTable(__ jmp(), i + 1 + target));
     332            m_jmpTable.append(JmpTable(jump(), i + 1 + target));
    340333            i += 2;
    341334            break;
     
    345338            emitGetVirtualRegister(srcDst, X86::eax, i);
    346339            emitJumpSlowCaseIfNotImmNum(X86::eax, i);
    347             __ addl_i8r(getDeTaggedConstantImmediate(JSImmediate::oneImmediate()), X86::eax);
    348             m_slowCases.append(SlowCaseEntry(__ jo(), i));
     340            m_slowCases.append(SlowCaseEntry(joAdd32(Imm32(getDeTaggedConstantImmediate(JSImmediate::oneImmediate())), X86::eax), i));
    349341            emitPutVirtualRegister(srcDst);
    350342            i += 2;
     
    355347
    356348            unsigned target = instruction[i + 1].u.operand;
    357             m_jmpTable.append(JmpTable(__ jmp(), i + 1 + target));
     349            m_jmpTable.append(JmpTable(jump(), i + 1 + target));
    358350            i += 2;
    359351            break;
     
    365357            JSValue* src2imm = getConstantImmediateNumericArg(instruction[i + 2].u.operand);
    366358            if (src2imm) {
    367                 emitGetVirtualRegister(instruction[i + 1].u.operand, X86::edx, i);
    368                 emitJumpSlowCaseIfNotImmNum(X86::edx, i);
    369                 __ cmpl_i32r(asInteger(src2imm), X86::edx);
    370                 m_jmpTable.append(JmpTable(__ jl(), i + 3 + target));
     359                emitGetVirtualRegister(instruction[i + 1].u.operand, X86::eax, i);
     360                emitJumpSlowCaseIfNotImmNum(X86::eax, i);
     361                m_jmpTable.append(JmpTable(jl32(X86::eax, Imm32(asInteger(src2imm))), i + 3 + target));
    371362            } else {
    372363                emitGetVirtualRegisters(instruction[i + 1].u.operand, X86::eax, instruction[i + 2].u.operand, X86::edx, i);
    373364                emitJumpSlowCaseIfNotImmNum(X86::eax, i);
    374365                emitJumpSlowCaseIfNotImmNum(X86::edx, i);
    375                 __ cmpl_rr(X86::edx, X86::eax);
    376                 m_jmpTable.append(JmpTable(__ jl(), i + 3 + target));
     366                m_jmpTable.append(JmpTable(jl32(X86::eax, X86::edx), i + 3 + target));
    377367            }
    378368            i += 4;
     
    385375            JSValue* src2imm = getConstantImmediateNumericArg(instruction[i + 2].u.operand);
    386376            if (src2imm) {
    387                 emitGetVirtualRegister(instruction[i + 1].u.operand, X86::edx, i);
    388                 emitJumpSlowCaseIfNotImmNum(X86::edx, i);
    389                 __ cmpl_i32r(asInteger(src2imm), X86::edx);
    390                 m_jmpTable.append(JmpTable(__ jle(), i + 3 + target));
     377                emitGetVirtualRegister(instruction[i + 1].u.operand, X86::eax, i);
     378                emitJumpSlowCaseIfNotImmNum(X86::eax, i);
     379                m_jmpTable.append(JmpTable(jle32(X86::eax, Imm32(asInteger(src2imm))), i + 3 + target));
    391380            } else {
    392381                emitGetVirtualRegisters(instruction[i + 1].u.operand, X86::eax, instruction[i + 2].u.operand, X86::edx, i);
    393382                emitJumpSlowCaseIfNotImmNum(X86::eax, i);
    394383                emitJumpSlowCaseIfNotImmNum(X86::edx, i);
    395                 __ cmpl_rr(X86::edx, X86::eax);
    396                 m_jmpTable.append(JmpTable(__ jle(), i + 3 + target));
     384                m_jmpTable.append(JmpTable(jle32(X86::eax, X86::edx), i + 3 + target));
    397385            }
    398386            i += 4;
     
    423411            __ orl_rr(X86::eax, X86::ecx);
    424412            __ orl_rr(X86::edx, X86::ecx);
    425             __ testl_i32r(JSImmediate::TagMask, X86::ecx);
    426 
    427             m_slowCases.append(SlowCaseEntry(__ jnz(), i));
     413            emitJumpSlowCaseIfNotJSCell(X86::ecx, i);
    428414
    429415            // check that all are object type - this is a bit of a bithack to avoid excess branching;
     
    498484                emitJumpSlowCaseIfNotImmNum(X86::eax, i);
    499485                emitFastArithDeTagImmediate(X86::eax);
    500                 __ imull_i32r(X86::eax, value, X86::eax);
    501                 m_slowCases.append(SlowCaseEntry(__ jo(), i));
     486                m_slowCases.append(SlowCaseEntry(joMul32(Imm32(value), X86::eax, X86::eax), i));
    502487                emitFastArithReTagImmediate(X86::eax);
    503488                emitPutVirtualRegister(dst);
     
    506491                emitJumpSlowCaseIfNotImmNum(X86::eax, i);
    507492                emitFastArithDeTagImmediate(X86::eax);
    508                 __ imull_i32r(X86::eax, value, X86::eax);
    509                 m_slowCases.append(SlowCaseEntry(__ jo(), i));
     493                m_slowCases.append(SlowCaseEntry(joMul32(Imm32(value), X86::eax, X86::eax), i));
    510494                emitFastArithReTagImmediate(X86::eax);
    511495                emitPutVirtualRegister(dst);
     
    533517        case op_get_global_var: {
    534518            JSVariableObject* globalObject = static_cast<JSVariableObject*>(instruction[i + 2].u.jsCell);
    535             __ movl_i32r(asInteger(globalObject), X86::eax);
     519            move(globalObject, X86::eax);
    536520            emitGetVariableObjectRegister(X86::eax, instruction[i + 3].u.operand, X86::eax);
    537521            emitPutVirtualRegister(instruction[i + 1].u.operand);
     
    542526            emitGetVirtualRegister(instruction[i + 3].u.operand, X86::edx, i);
    543527            JSVariableObject* globalObject = static_cast<JSVariableObject*>(instruction[i + 1].u.jsCell);
    544             __ movl_i32r(asInteger(globalObject), X86::eax);
     528            move(globalObject, X86::eax);
    545529            emitPutVariableObjectRegister(X86::edx, X86::eax, instruction[i + 2].u.operand);
    546530            i += 4;
     
    552536            emitGetFromCallFrameHeader(RegisterFile::ScopeChain, X86::eax);
    553537            while (skip--)
    554                 __ movl_mr(FIELD_OFFSET(ScopeChainNode, next), X86::eax, X86::eax);
    555 
    556             __ movl_mr(FIELD_OFFSET(ScopeChainNode, object), X86::eax, X86::eax);
     538                loadPtr(Address(X86::eax, FIELD_OFFSET(ScopeChainNode, next)), X86::eax);
     539
     540            loadPtr(Address(X86::eax, FIELD_OFFSET(ScopeChainNode, object)), X86::eax);
    557541            emitGetVariableObjectRegister(X86::eax, instruction[i + 2].u.operand, X86::eax);
    558542            emitPutVirtualRegister(instruction[i + 1].u.operand);
     
    566550            emitGetVirtualRegister(instruction[i + 3].u.operand, X86::eax, i);
    567551            while (skip--)
    568                 __ movl_mr(FIELD_OFFSET(ScopeChainNode, next), X86::edx, X86::edx);
    569 
    570             __ movl_mr(FIELD_OFFSET(ScopeChainNode, object), X86::edx, X86::edx);
     552                loadPtr(Address(X86::edx, FIELD_OFFSET(ScopeChainNode, next)), X86::edx);
     553
     554            loadPtr(Address(X86::edx, FIELD_OFFSET(ScopeChainNode, object)), X86::edx);
    571555            emitPutVariableObjectRegister(X86::eax, X86::edx, instruction[i + 1].u.operand);
    572556            i += 4;
     
    625609            emitGetVirtualRegister(instruction[i + 1].u.operand, X86::eax, i);
    626610
    627             __ testl_i32r(JSImmediate::TagMask, X86::eax);
    628             JmpSrc isImmediate = __ jne();
     611            JmpSrc isImmediate = emitJumpIfNotJSCell(X86::eax);
    629612            __ movl_mr(FIELD_OFFSET(JSCell, m_structure), X86::eax, X86::ecx);
    630613            __ cmpl_i32m(ObjectType, FIELD_OFFSET(Structure, m_typeInfo) + FIELD_OFFSET(TypeInfo, m_type), X86::ecx);
     
    643626            emitJumpSlowCaseIfNotImmNum(X86::edx, i);
    644627            emitFastArithImmToInt(X86::edx);
    645             __ testl_i32r(JSImmediate::TagMask, X86::eax);
    646             m_slowCases.append(SlowCaseEntry(__ jne(), i));
     628            emitJumpSlowCaseIfNotJSCell(X86::eax, i);
    647629            __ cmpl_i32m(reinterpret_cast<unsigned>(m_interpreter->m_jsArrayVptr), X86::eax);
    648630            m_slowCases.append(SlowCaseEntry(__ jne(), i));
     
    677659            emitJumpSlowCaseIfNotImmNum(X86::edx, i);
    678660            emitFastArithImmToInt(X86::edx);
    679             __ testl_i32r(JSImmediate::TagMask, X86::eax);
    680             m_slowCases.append(SlowCaseEntry(__ jne(), i));
     661            emitJumpSlowCaseIfNotJSCell(X86::eax, i);
    681662            __ cmpl_i32m(reinterpret_cast<unsigned>(m_interpreter->m_jsArrayVptr), X86::eax);
    682663            m_slowCases.append(SlowCaseEntry(__ jne(), i));
     
    840821
    841822            emitGetVirtualRegister(src, X86::eax, i);
    842             __ testl_i32r(JSImmediate::TagMask, X86::eax);
    843             JmpSrc isImmediate = __ jnz();
     823            JmpSrc isImmediate = emitJumpIfNotJSCell(X86::eax);
    844824
    845825            __ movl_mr(FIELD_OFFSET(JSCell, m_structure), X86::eax, X86::ecx);
     
    870850
    871851            emitGetVirtualRegister(src, X86::eax, i);
    872             __ testl_i32r(JSImmediate::TagMask, X86::eax);
    873             JmpSrc isImmediate = __ jnz();
     852            JmpSrc isImmediate = emitJumpIfNotJSCell(X86::eax);
    874853
    875854            __ movl_mr(FIELD_OFFSET(JSCell, m_structure), X86::eax, X86::ecx);
     
    13231302
    13241303            emitGetVirtualRegister(src1, X86::eax, i);
    1325             __ testl_i32r(JSImmediate::TagMask, X86::eax);
    1326             JmpSrc isImmediate = __ jnz();
     1304            JmpSrc isImmediate = emitJumpIfNotJSCell(X86::eax);
    13271305
    13281306            __ movl_mr(FIELD_OFFSET(JSCell, m_structure), X86::eax, X86::ecx);
     
    13531331
    13541332            emitGetVirtualRegister(src1, X86::eax, i);
    1355             __ testl_i32r(JSImmediate::TagMask, X86::eax);
    1356             JmpSrc isImmediate = __ jnz();
     1333            JmpSrc isImmediate = emitJumpIfNotJSCell(X86::eax);
    13571334
    13581335            __ movl_mr(FIELD_OFFSET(JSCell, m_structure), X86::eax, X86::ecx);
     
    16101587            if (src2imm) {
    16111588                __ link(iter->from, __ label());
    1612                 emitPutCTIArg(X86::edx, 0);
     1589                emitPutCTIArg(X86::eax, 0);
    16131590                emitPutCTIArgFromVirtualRegister(instruction[i + 2].u.operand, 4, X86::ecx);
    16141591                emitCTICall(i, Interpreter::cti_op_loop_if_less);
     
    16421619            if (src2imm) {
    16431620                __ link(iter->from, __ label());
    1644                 emitPutCTIArg(X86::edx, 0);
     1621                emitPutCTIArg(X86::eax, 0);
    16451622                emitPutCTIArgFromVirtualRegister(instruction[i + 2].u.operand, 4, X86::ecx);
    16461623                emitCTICall(i, Interpreter::cti_op_loop_if_lesseq);
     
    20782055   
    20792056    // Check eax is an array
    2080     __ testl_i32r(JSImmediate::TagMask, X86::eax);
    2081     JmpSrc array_failureCases1 = __ jne();
     2057    JmpSrc array_failureCases1 = emitJumpIfNotJSCell(X86::eax);
    20822058    __ cmpl_i32m(reinterpret_cast<unsigned>(m_interpreter->m_jsArrayVptr), X86::eax);
    20832059    JmpSrc array_failureCases2 = __ jne();
     
    21002076
    21012077    // Check eax is a string
    2102     __ testl_i32r(JSImmediate::TagMask, X86::eax);
    2103     JmpSrc string_failureCases1 = __ jne();
     2078    JmpSrc string_failureCases1 = emitJumpIfNotJSCell(X86::eax);
    21042079    __ cmpl_i32m(reinterpret_cast<unsigned>(m_interpreter->m_jsStringVptr), X86::eax);
    21052080    JmpSrc string_failureCases2 = __ jne();
Note: See TracChangeset for help on using the changeset viewer.