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


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

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

Reviewed by Oliver Hunt & Cameron Zwarich.

Add support for call and property access repatching on x86-64.

No change in performance on current configurations (2x impovement on v8-tests with JIT enabled on x86-64).

  • assembler/MacroAssembler.h: (JSC::MacroAssembler::DataLabelPtr::repatch): (JSC::MacroAssembler::DataLabelPtr::operator X86Assembler::JmpDst): (JSC::MacroAssembler::DataLabel32::repatch): (JSC::MacroAssembler::RepatchBuffer::addressOf): (JSC::MacroAssembler::add32): (JSC::MacroAssembler::sub32): (JSC::MacroAssembler::loadPtrWithAddressOffsetRepatch): (JSC::MacroAssembler::storePtrWithAddressOffsetRepatch): (JSC::MacroAssembler::jePtr): (JSC::MacroAssembler::jnePtr): (JSC::MacroAssembler::jnePtrWithRepatch): (JSC::MacroAssembler::differenceBetween):
  • assembler/X86Assembler.h: (JSC::X86Assembler::addl_im): (JSC::X86Assembler::subl_im): (JSC::X86Assembler::cmpl_rm): (JSC::X86Assembler::movq_rm_disp32): (JSC::X86Assembler::movq_mr_disp32): (JSC::X86Assembler::repatchPointer): (JSC::X86Assembler::X86InstructionFormatter::oneByteOp64_disp32):
  • jit/JIT.cpp: (JSC::JIT::privateCompile): (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JIT.h:
  • jit/JITCall.cpp: (JSC::JIT::unlinkCall): (JSC::JIT::linkCall): (JSC::JIT::compileOpCall): (JSC::JIT::compileOpCallSlowCase):
  • jit/JITInlineMethods.h: (JSC::JIT::restoreArgumentReferenceForTrampoline):
  • jit/JITPropertyAccess.cpp: (JSC::JIT::compileGetByIdHotPath): (JSC::JIT::compileGetByIdSlowCase): (JSC::JIT::compilePutByIdHotPath): (JSC::JIT::compilePutByIdSlowCase): (JSC::resizePropertyStorage): (JSC::JIT::privateCompilePutByIdTransition): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdProtoList): (JSC::JIT::privateCompileGetByIdChainList): (JSC::JIT::privateCompileGetByIdChain):
  • wtf/Platform.h:
File:
1 edited

Legend:

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

    r39422 r39428  
    18911891        StructureStubInfo& info = m_codeBlock->structureStubInfo(i);
    18921892#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
    1893         info.callReturnLocation = X86Assembler::getRelocatedAddress(code, m_propertyAccessCompilationInfo[i].callReturnLocation);
    1894         info.hotPathBegin = X86Assembler::getRelocatedAddress(code, m_propertyAccessCompilationInfo[i].hotPathBegin);
     1893        info.callReturnLocation = repatchBuffer.addressOf(m_propertyAccessCompilationInfo[i].callReturnLocation);
     1894        info.hotPathBegin = repatchBuffer.addressOf(m_propertyAccessCompilationInfo[i].hotPathBegin);
    18951895#else
    18961896        info.callReturnLocation = 0;
     
    19011901        CallLinkInfo& info = m_codeBlock->callLinkInfo(i);
    19021902#if ENABLE(JIT_OPTIMIZE_CALL)
    1903         info.callReturnLocation = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].callReturnLocation);
    1904         info.hotPathBegin = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].hotPathBegin);
    1905         info.hotPathOther = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].hotPathOther);
    1906         info.coldPathOther = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].coldPathOther);
     1903        info.callReturnLocation = repatchBuffer.addressOf(m_callStructureStubCompilationInfo[i].callReturnLocation);
     1904        info.hotPathBegin = repatchBuffer.addressOf(m_callStructureStubCompilationInfo[i].hotPathBegin);
     1905        info.hotPathOther = repatchBuffer.addressOf(m_callStructureStubCompilationInfo[i].hotPathOther);
     1906        info.coldPathOther = repatchBuffer.addressOf(m_callStructureStubCompilationInfo[i].coldPathOther);
    19071907#else
    19081908        info.callReturnLocation = 0;
     
    19601960    Label virtualCallPreLinkBegin = align();
    19611961
    1962 #define __ m_assembler.
    19631962    // Load the callee CodeBlock* into eax
    1964     __ movl_mr(FIELD_OFFSET(JSFunction, m_body), X86::ecx, X86::eax);
    1965     __ movl_mr(FIELD_OFFSET(FunctionBodyNode, m_code), X86::eax, X86::eax);
    1966     __ testl_rr(X86::eax, X86::eax);
    1967     X86Assembler::JmpSrc hasCodeBlock1 = __ jne();
    1968     __ pop_r(X86::ebx);
     1963    loadPtr(Address(X86::ecx, FIELD_OFFSET(JSFunction, m_body)), X86::eax);
     1964    loadPtr(Address(X86::eax, FIELD_OFFSET(FunctionBodyNode, m_code)), X86::eax);
     1965    Jump hasCodeBlock1 = jnzPtr(X86::eax);
     1966    pop(X86::ebx);
    19691967    restoreArgumentReference();
    1970     X86Assembler::JmpSrc callJSFunction1 = __ call();
     1968    Jump callJSFunction1 = call();
    19711969    emitGetJITStubArg(1, X86::ecx);
    19721970    emitGetJITStubArg(3, X86::edx);
    1973     __ push_r(X86::ebx);
    1974     __ link(hasCodeBlock1, __ label());
     1971    push(X86::ebx);
     1972    hasCodeBlock1.link(this);
    19751973
    19761974    // Check argCount matches callee arity.
    1977     __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax);
    1978     X86Assembler::JmpSrc arityCheckOkay1 = __ je();
    1979     __ pop_r(X86::ebx);
     1975    Jump arityCheckOkay1 = je32(Address(X86::eax, FIELD_OFFSET(CodeBlock, m_numParameters)), X86::edx);
     1976    pop(X86::ebx);
    19801977    emitPutJITStubArg(X86::ebx, 2);
    19811978    emitPutJITStubArg(X86::eax, 4);
    19821979    restoreArgumentReference();
    1983     X86Assembler::JmpSrc callArityCheck1 = __ call();
    1984     __ movl_rr(X86::edx, callFrameRegister);
     1980    Jump callArityCheck1 = call();
     1981    move(X86::edx, callFrameRegister);
    19851982    emitGetJITStubArg(1, X86::ecx);
    19861983    emitGetJITStubArg(3, X86::edx);
    1987     __ push_r(X86::ebx);
    1988     __ link(arityCheckOkay1, __ label());
    1989 
     1984    push(X86::ebx);
     1985    arityCheckOkay1.link(this);
     1986   
    19901987    compileOpCallInitializeCallFrame();
    19911988
    1992     __ pop_r(X86::ebx);
     1989    pop(X86::ebx);
    19931990    emitPutJITStubArg(X86::ebx, 2);
    19941991    restoreArgumentReference();
    1995     X86Assembler::JmpSrc callDontLazyLinkCall = __ call();
    1996     __ push_r(X86::ebx);
    1997 
    1998     __ jmp_r(X86::eax);
     1992    Jump callDontLazyLinkCall = call();
     1993    push(X86::ebx);
     1994
     1995    jump(X86::eax);
    19991996
    20001997    Label virtualCallLinkBegin = align();
    20011998
    20021999    // Load the callee CodeBlock* into eax
    2003     __ movl_mr(FIELD_OFFSET(JSFunction, m_body), X86::ecx, X86::eax);
    2004     __ movl_mr(FIELD_OFFSET(FunctionBodyNode, m_code), X86::eax, X86::eax);
    2005     __ testl_rr(X86::eax, X86::eax);
    2006     X86Assembler::JmpSrc hasCodeBlock2 = __ jne();
    2007     __ pop_r(X86::ebx);
     2000    loadPtr(Address(X86::ecx, FIELD_OFFSET(JSFunction, m_body)), X86::eax);
     2001    loadPtr(Address(X86::eax, FIELD_OFFSET(FunctionBodyNode, m_code)), X86::eax);
     2002    Jump hasCodeBlock2 = jnzPtr(X86::eax);
     2003    pop(X86::ebx);
    20082004    restoreArgumentReference();
    2009     X86Assembler::JmpSrc callJSFunction2 = __ call();
     2005    Jump callJSFunction2 = call();
    20102006    emitGetJITStubArg(1, X86::ecx);
    20112007    emitGetJITStubArg(3, X86::edx);
    2012     __ push_r(X86::ebx);
    2013     __ link(hasCodeBlock2, __ label());
     2008    push(X86::ebx);
     2009    hasCodeBlock2.link(this);
    20142010
    20152011    // Check argCount matches callee arity.
    2016     __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax);
    2017     X86Assembler::JmpSrc arityCheckOkay2 = __ je();
    2018     __ pop_r(X86::ebx);
     2012    Jump arityCheckOkay2 = je32(Address(X86::eax, FIELD_OFFSET(CodeBlock, m_numParameters)), X86::edx);
     2013    pop(X86::ebx);
    20192014    emitPutJITStubArg(X86::ebx, 2);
    20202015    emitPutJITStubArg(X86::eax, 4);
    20212016    restoreArgumentReference();
    2022     X86Assembler::JmpSrc callArityCheck2 = __ call();
    2023     __ movl_rr(X86::edx, callFrameRegister);
     2017    Jump callArityCheck2 = call();
     2018    move(X86::edx, callFrameRegister);
    20242019    emitGetJITStubArg(1, X86::ecx);
    20252020    emitGetJITStubArg(3, X86::edx);
    2026     __ push_r(X86::ebx);
    2027     __ link(arityCheckOkay2, __ label());
     2021    push(X86::ebx);
     2022    arityCheckOkay2.link(this);
    20282023
    20292024    compileOpCallInitializeCallFrame();
    20302025
    2031     __ pop_r(X86::ebx);
     2026    pop(X86::ebx);
    20322027    emitPutJITStubArg(X86::ebx, 2);
    20332028    restoreArgumentReference();
    2034     X86Assembler::JmpSrc callLazyLinkCall = __ call();
    2035     __ push_r(X86::ebx);
    2036 
    2037     __ jmp_r(X86::eax);
     2029    Jump callLazyLinkCall = call();
     2030    push(X86::ebx);
     2031
     2032    jump(X86::eax);
    20382033
    20392034    Label virtualCallBegin = align();
     
    20452040    pop(X86::ebx);
    20462041    restoreArgumentReference();
    2047     X86Assembler::JmpSrc callJSFunction3 = call();
     2042    Jump callJSFunction3 = call();
    20482043    emitGetJITStubArg(1, X86::ecx);
    20492044    emitGetJITStubArg(3, X86::edx);
     
    20572052    emitPutJITStubArg(X86::eax, 4);
    20582053    restoreArgumentReference();
    2059     X86Assembler::JmpSrc callArityCheck3 = call();
     2054    Jump callArityCheck3 = call();
    20602055    move(X86::edx, callFrameRegister);
    20612056    emitGetJITStubArg(1, X86::ecx);
     
    20872082    m_interpreter->m_ctiStringLengthTrampoline = repatchBuffer.addressOf(stringLengthBegin);
    20882083#endif
    2089     X86Assembler::link(code, callArityCheck1, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
    2090     X86Assembler::link(code, callArityCheck2, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
    2091     X86Assembler::link(code, callArityCheck3, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
    2092     X86Assembler::link(code, callJSFunction1, reinterpret_cast<void*>(Interpreter::cti_op_call_JSFunction));
    2093     X86Assembler::link(code, callJSFunction2, reinterpret_cast<void*>(Interpreter::cti_op_call_JSFunction));
    2094     X86Assembler::link(code, callJSFunction3, reinterpret_cast<void*>(Interpreter::cti_op_call_JSFunction));
    2095     X86Assembler::link(code, callDontLazyLinkCall, reinterpret_cast<void*>(Interpreter::cti_vm_dontLazyLinkCall));
    2096     X86Assembler::link(code, callLazyLinkCall, reinterpret_cast<void*>(Interpreter::cti_vm_lazyLinkCall));
     2084    repatchBuffer.link(callArityCheck1, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
     2085    repatchBuffer.link(callArityCheck2, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
     2086    repatchBuffer.link(callArityCheck3, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
     2087    repatchBuffer.link(callJSFunction1, reinterpret_cast<void*>(Interpreter::cti_op_call_JSFunction));
     2088    repatchBuffer.link(callJSFunction2, reinterpret_cast<void*>(Interpreter::cti_op_call_JSFunction));
     2089    repatchBuffer.link(callJSFunction3, reinterpret_cast<void*>(Interpreter::cti_op_call_JSFunction));
     2090    repatchBuffer.link(callDontLazyLinkCall, reinterpret_cast<void*>(Interpreter::cti_vm_dontLazyLinkCall));
     2091    repatchBuffer.link(callLazyLinkCall, reinterpret_cast<void*>(Interpreter::cti_vm_lazyLinkCall));
    20972092
    20982093    m_interpreter->m_ctiVirtualCallPreLink = repatchBuffer.addressOf(virtualCallPreLinkBegin);
Note: See TracChangeset for help on using the changeset viewer.