Ignore:
Timestamp:
Jul 30, 2009, 7:20:11 PM (16 years ago)
Author:
[email protected]
Message:

2009-07-23 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Make get_by_id/put_by_id/method_check/call defer optimization using a data flag rather than a code modification.
( https://bugs.webkit.org/show_bug.cgi?id=27635 )

This improves performance of ENABLE(ASSEMBLER_WX_EXCLUSIVE) builds by 2-2.5%, reducing the overhead to about 2.5%.
(No performance impact with ASSEMBLER_WX_EXCLUSIVE disabled).

  • bytecode/CodeBlock.cpp: (JSC::printStructureStubInfo):
    • Make StructureStubInfo store the type as an integer, rather than an OpcodeID.
  • bytecode/CodeBlock.h: (JSC::): (JSC::CallLinkInfo::seenOnce): (JSC::CallLinkInfo::setSeen): (JSC::MethodCallLinkInfo::seenOnce): (JSC::MethodCallLinkInfo::setSeen):
    • Change a pointer in CallLinkInfo/MethodCallLinkInfo to use a PtrAndFlags, use a flag to track when an op has been executed once.
  • bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::deref):
    • Make StructureStubInfo store the type as an integer, rather than an OpcodeID.
  • bytecode/StructureStubInfo.h: (JSC::StructureStubInfo::StructureStubInfo): (JSC::StructureStubInfo::initGetByIdSelf): (JSC::StructureStubInfo::initGetByIdProto): (JSC::StructureStubInfo::initGetByIdChain): (JSC::StructureStubInfo::initGetByIdSelfList): (JSC::StructureStubInfo::initGetByIdProtoList): (JSC::StructureStubInfo::initPutByIdTransition): (JSC::StructureStubInfo::initPutByIdReplace): (JSC::StructureStubInfo::seenOnce): (JSC::StructureStubInfo::setSeen):
    • Make StructureStubInfo store the type as an integer, rather than an OpcodeID, add a flag to track when an op has been executed once.
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitGetById): (JSC::BytecodeGenerator::emitPutById):
    • Make StructureStubInfo store the type as an integer, rather than an OpcodeID.
  • jit/JIT.cpp: (JSC::JIT::privateCompileCTIMachineTrampolines): (JSC::JIT::unlinkCall):
    • Remove the "don't lazy link" stage of calls.
  • jit/JIT.h: (JSC::JIT::compileCTIMachineTrampolines):
    • Remove the "don't lazy link" stage of calls.
  • jit/JITCall.cpp: (JSC::JIT::compileOpCallSlowCase):
    • Remove the "don't lazy link" stage of calls.
  • jit/JITStubs.cpp: (JSC::JITThunks::JITThunks): (JSC::JITThunks::tryCachePutByID): (JSC::JITThunks::tryCacheGetByID): (JSC::JITStubs::DEFINE_STUB_FUNCTION): (JSC::JITStubs::getPolymorphicAccessStructureListSlot):
    • Remove the "don't lazy link" stage of calls, and the "_second" stage of get_by_id/put_by_id/method_check.
  • jit/JITStubs.h: (JSC::JITThunks::ctiStringLengthTrampoline): (JSC::JITStubs::):
    • Remove the "don't lazy link" stage of calls, and the "_second" stage of get_by_id/put_by_id/method_check.
  • wtf/PtrAndFlags.h: (WTF::PtrAndFlags::PtrAndFlags): (WTF::PtrAndFlags::operator!): (WTF::PtrAndFlags::operator->):
    • Add ! and -> operators, add constuctor with pointer argument.
File:
1 edited

Legend:

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

    r46598 r46618  
    4040#if USE(JSVALUE32_64)
    4141
    42 void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* globalData, CodePtr* ctiStringLengthTrampoline, CodePtr* ctiVirtualCallPreLink, CodePtr* ctiVirtualCallLink, CodePtr* ctiVirtualCall, CodePtr* ctiNativeCallThunk)
     42void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* globalData, CodePtr* ctiStringLengthTrampoline, CodePtr* ctiVirtualCallLink, CodePtr* ctiVirtualCall, CodePtr* ctiNativeCallThunk)
    4343{
    4444#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
     
    6262#endif
    6363
    64     // (2) Trampolines for the slow cases of op_call / op_call_eval / op_construct.
     64    // (2) Trampoline for the slow cases of op_call / op_call_eval / op_construct.
    6565
    6666#if ENABLE(JIT_OPTIMIZE_CALL)
    67     /* VirtualCallPreLink Trampoline */
    68     Label virtualCallPreLinkBegin = align();
    69 
    70     // regT0 holds callee, regT1 holds argCount.
    71     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_body)), regT2);
    72     loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionBodyNode, m_code)), regT2);
    73     Jump hasCodeBlock1 = branchTestPtr(NonZero, regT2);
    74 
    75     // Lazily generate a CodeBlock.
    76     preserveReturnAddressAfterCall(regT3); // return address
    77     restoreArgumentReference();
    78     Call callJSFunction1 = call();
    79     move(regT0, regT2);
    80     emitGetJITStubArg(1, regT0); // callee
    81     emitGetJITStubArg(5, regT1); // argCount
    82     restoreReturnAddressBeforeReturn(regT3); // return address
    83     hasCodeBlock1.link(this);
    84 
    85     // regT2 holds codeBlock.
    86     Jump isNativeFunc1 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(CodeBlock, m_codeType)), Imm32(NativeCode));
    87 
    88     // Check argCount matches callee arity.
    89     Jump arityCheckOkay1 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(CodeBlock, m_numParameters)), regT1);
    90     preserveReturnAddressAfterCall(regT3);
    91     emitPutJITStubArg(regT3, 3); // return address
    92     emitPutJITStubArg(regT2, 7); // codeBlock
    93     restoreArgumentReference();
    94     Call callArityCheck1 = call();
    95     move(regT1, callFrameRegister);
    96     emitGetJITStubArg(1, regT0); // callee
    97     emitGetJITStubArg(5, regT1); // argCount
    98     restoreReturnAddressBeforeReturn(regT3); // return address
    99 
    100     arityCheckOkay1.link(this);
    101     isNativeFunc1.link(this);
    102    
    103     compileOpCallInitializeCallFrame();
    104 
    105     preserveReturnAddressAfterCall(regT3);
    106     emitPutJITStubArg(regT3, 3);
    107     restoreArgumentReference();
    108     Call callDontLazyLinkCall = call();
    109     restoreReturnAddressBeforeReturn(regT3);
    110     jump(regT0);
    111 
    11267    /* VirtualCallLink Trampoline */
    11368    Label virtualCallLinkBegin = align();
     
    356311#endif
    357312#if ENABLE(JIT_OPTIMIZE_CALL)
    358     patchBuffer.link(callArityCheck1, FunctionPtr(cti_op_call_arityCheck));
    359     patchBuffer.link(callJSFunction1, FunctionPtr(cti_op_call_JSFunction));
    360313    patchBuffer.link(callArityCheck2, FunctionPtr(cti_op_call_arityCheck));
    361314    patchBuffer.link(callJSFunction2, FunctionPtr(cti_op_call_JSFunction));
    362     patchBuffer.link(callDontLazyLinkCall, FunctionPtr(cti_vm_dontLazyLinkCall));
    363315    patchBuffer.link(callLazyLinkCall, FunctionPtr(cti_vm_lazyLinkCall));
    364316#endif
     
    377329#endif
    378330#if ENABLE(JIT_OPTIMIZE_CALL)
    379     *ctiVirtualCallPreLink = trampolineAt(finalCode, virtualCallPreLinkBegin);
    380331    *ctiVirtualCallLink = trampolineAt(finalCode, virtualCallLinkBegin);
    381332#else
     
    15101461   do { m_labels[m_bytecodeIndex + (targetOffset)].used(); } while (false)
    15111462
    1512 void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* globalData, CodePtr* ctiStringLengthTrampoline, CodePtr* ctiVirtualCallPreLink, CodePtr* ctiVirtualCallLink, CodePtr* ctiVirtualCall, CodePtr* ctiNativeCallThunk)
     1463void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* globalData, CodePtr* ctiStringLengthTrampoline, CodePtr* ctiVirtualCallLink, CodePtr* ctiVirtualCall, CodePtr* ctiNativeCallThunk)
    15131464{
    15141465#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
     
    15321483#endif
    15331484
    1534     // (3) Trampolines for the slow cases of op_call / op_call_eval / op_construct.
     1485    // (3) Trampoline for the slow cases of op_call / op_call_eval / op_construct.
    15351486    COMPILE_ASSERT(sizeof(CodeType) == 4, CodeTypeEnumMustBe32Bit);
    1536 
    1537     Label virtualCallPreLinkBegin = align();
    1538 
    1539     // Load the callee CodeBlock* into eax
    1540     loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_body)), regT3);
    1541     loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionBodyNode, m_code)), regT0);
    1542     Jump hasCodeBlock1 = branchTestPtr(NonZero, regT0);
    1543     preserveReturnAddressAfterCall(regT3);
    1544     restoreArgumentReference();
    1545     Call callJSFunction1 = call();
    1546     emitGetJITStubArg(1, regT2);
    1547     emitGetJITStubArg(3, regT1);
    1548     restoreReturnAddressBeforeReturn(regT3);
    1549     hasCodeBlock1.link(this);
    1550 
    1551     Jump isNativeFunc1 = branch32(Equal, Address(regT0, OBJECT_OFFSETOF(CodeBlock, m_codeType)), Imm32(NativeCode));
    1552 
    1553     // Check argCount matches callee arity.
    1554     Jump arityCheckOkay1 = branch32(Equal, Address(regT0, OBJECT_OFFSETOF(CodeBlock, m_numParameters)), regT1);
    1555     preserveReturnAddressAfterCall(regT3);
    1556     emitPutJITStubArg(regT3, 2);
    1557     emitPutJITStubArg(regT0, 4);
    1558     restoreArgumentReference();
    1559     Call callArityCheck1 = call();
    1560     move(regT1, callFrameRegister);
    1561     emitGetJITStubArg(1, regT2);
    1562     emitGetJITStubArg(3, regT1);
    1563     restoreReturnAddressBeforeReturn(regT3);
    1564     arityCheckOkay1.link(this);
    1565     isNativeFunc1.link(this);
    1566    
    1567     compileOpCallInitializeCallFrame();
    1568 
    1569     preserveReturnAddressAfterCall(regT3);
    1570     emitPutJITStubArg(regT3, 2);
    1571     restoreArgumentReference();
    1572     Call callDontLazyLinkCall = call();
    1573     emitGetJITStubArg(1, regT2);
    1574     restoreReturnAddressBeforeReturn(regT3);
    1575 
    1576     jump(regT0);
    15771487
    15781488    Label virtualCallLinkBegin = align();
     
    18411751    patchBuffer.link(string_failureCases3Call, FunctionPtr(cti_op_get_by_id_string_fail));
    18421752#endif
    1843     patchBuffer.link(callArityCheck1, FunctionPtr(cti_op_call_arityCheck));
    18441753    patchBuffer.link(callArityCheck2, FunctionPtr(cti_op_call_arityCheck));
    18451754    patchBuffer.link(callArityCheck3, FunctionPtr(cti_op_call_arityCheck));
    1846     patchBuffer.link(callJSFunction1, FunctionPtr(cti_op_call_JSFunction));
    18471755    patchBuffer.link(callJSFunction2, FunctionPtr(cti_op_call_JSFunction));
    18481756    patchBuffer.link(callJSFunction3, FunctionPtr(cti_op_call_JSFunction));
    1849     patchBuffer.link(callDontLazyLinkCall, FunctionPtr(cti_vm_dontLazyLinkCall));
    18501757    patchBuffer.link(callLazyLinkCall, FunctionPtr(cti_vm_lazyLinkCall));
    18511758
     
    18531760    *executablePool = finalCode.m_executablePool;
    18541761
    1855     *ctiVirtualCallPreLink = trampolineAt(finalCode, virtualCallPreLinkBegin);
    18561762    *ctiVirtualCallLink = trampolineAt(finalCode, virtualCallLinkBegin);
    18571763    *ctiVirtualCall = trampolineAt(finalCode, virtualCallBegin);
Note: See TracChangeset for help on using the changeset viewer.