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


Ignore:
Timestamp:
Jun 5, 2009, 12:55:38 AM (16 years ago)
Author:
[email protected]
Message:

2009-06-05 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Encapsulate many uses of void* in the assembler & jit with types that provide
more semantic information. The new types are:


  • MacroAssemblerCodePtr - this wraps a pointer into JIT generated code.
  • FunctionPtr - this wraps a pointer to a C/C++ function in JSC.
  • ReturnAddressPtr - this wraps a return address resulting from a 'call' instruction.

Wrapping these types allows for stronger type-checking than is possible with everything
represented a void*. For example, it is now enforced by the type system that near
calls can only be linked to JIT code and not to C functions in JSC (this was previously
required, but could not be enforced on the interface).

  • assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::CodeLocationCommon::CodeLocationCommon): (JSC::AbstractMacroAssembler::CodeLocationCommon::dataLocation): (JSC::AbstractMacroAssembler::CodeLocationCommon::executableAddress): (JSC::AbstractMacroAssembler::CodeLocationCommon::reset): (JSC::AbstractMacroAssembler::CodeLocationInstruction::repatchLoadToLEA): (JSC::AbstractMacroAssembler::CodeLocationInstruction::CodeLocationInstruction): (JSC::AbstractMacroAssembler::CodeLocationLabel::addressForSwitch): (JSC::AbstractMacroAssembler::CodeLocationLabel::addressForExceptionHandler): (JSC::AbstractMacroAssembler::CodeLocationLabel::addressForJSR): (JSC::AbstractMacroAssembler::CodeLocationLabel::operator!): (JSC::AbstractMacroAssembler::CodeLocationLabel::reset): (JSC::AbstractMacroAssembler::CodeLocationLabel::CodeLocationLabel): (JSC::AbstractMacroAssembler::CodeLocationLabel::getJumpDestination): (JSC::AbstractMacroAssembler::CodeLocationJump::relink): (JSC::AbstractMacroAssembler::CodeLocationJump::CodeLocationJump): (JSC::AbstractMacroAssembler::CodeLocationCall::relink): (JSC::AbstractMacroAssembler::CodeLocationCall::calleeReturnAddressValue): (JSC::AbstractMacroAssembler::CodeLocationCall::CodeLocationCall): (JSC::AbstractMacroAssembler::CodeLocationNearCall::relink): (JSC::AbstractMacroAssembler::CodeLocationNearCall::calleeReturnAddressValue): (JSC::AbstractMacroAssembler::CodeLocationNearCall::CodeLocationNearCall): (JSC::AbstractMacroAssembler::CodeLocationDataLabel32::repatch): (JSC::AbstractMacroAssembler::CodeLocationDataLabel32::CodeLocationDataLabel32): (JSC::AbstractMacroAssembler::CodeLocationDataLabelPtr::repatch): (JSC::AbstractMacroAssembler::CodeLocationDataLabelPtr::CodeLocationDataLabelPtr): (JSC::AbstractMacroAssembler::ProcessorReturnAddress::relinkCallerToTrampoline): (JSC::AbstractMacroAssembler::ProcessorReturnAddress::relinkCallerToFunction): (JSC::AbstractMacroAssembler::ProcessorReturnAddress::relinkNearCallerToTrampoline): (JSC::AbstractMacroAssembler::ProcessorReturnAddress::addressForLookup): (JSC::AbstractMacroAssembler::trampolineAt): (JSC::AbstractMacroAssembler::PatchBuffer::link): (JSC::AbstractMacroAssembler::PatchBuffer::performFinalization): (JSC::::CodeLocationCommon::instructionAtOffset): (JSC::::CodeLocationCommon::labelAtOffset): (JSC::::CodeLocationCommon::jumpAtOffset): (JSC::::CodeLocationCommon::callAtOffset): (JSC::::CodeLocationCommon::nearCallAtOffset): (JSC::::CodeLocationCommon::dataLabelPtrAtOffset): (JSC::::CodeLocationCommon::dataLabel32AtOffset):
  • assembler/MacroAssemblerCodeRef.h: (JSC::FunctionPtr::FunctionPtr): (JSC::FunctionPtr::value): (JSC::FunctionPtr::executableAddress): (JSC::ReturnAddressPtr::ReturnAddressPtr): (JSC::ReturnAddressPtr::value): (JSC::MacroAssemblerCodePtr::MacroAssemblerCodePtr): (JSC::MacroAssemblerCodePtr::executableAddress): (JSC::MacroAssemblerCodePtr::dataLocation): (JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef):
  • assembler/X86Assembler.h: (JSC::X86Assembler::patchPointerForCall):
  • jit/JIT.cpp: (JSC::ctiPatchNearCallByReturnAddress): (JSC::ctiPatchCallByReturnAddress): (JSC::JIT::privateCompile): (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JIT.h: (JSC::JIT::compileCTIMachineTrampolines):
  • jit/JITCall.cpp: (JSC::JIT::compileOpCall):
  • jit/JITCode.h: (JSC::JITCode::operator !): (JSC::JITCode::addressForCall): (JSC::JITCode::offsetOf): (JSC::JITCode::execute): (JSC::JITCode::size): (JSC::JITCode::HostFunction):
  • jit/JITInlineMethods.h: (JSC::JIT::emitNakedCall):
  • jit/JITPropertyAccess.cpp: (JSC::JIT::privateCompilePutByIdTransition): (JSC::JIT::patchGetByIdSelf): (JSC::JIT::patchPutByIdReplace): (JSC::JIT::privateCompilePatchGetArrayLength): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdChain):
  • jit/JITStubs.cpp: (JSC::JITThunks::JITThunks): (JSC::JITThunks::tryCachePutByID): (JSC::JITThunks::tryCacheGetByID): (JSC::JITStubs::DEFINE_STUB_FUNCTION):
  • jit/JITStubs.h: (JSC::JITThunks::ctiArrayLengthTrampoline): (JSC::JITThunks::ctiStringLengthTrampoline): (JSC::JITThunks::ctiVirtualCallPreLink): (JSC::JITThunks::ctiVirtualCallLink): (JSC::JITThunks::ctiVirtualCall): (JSC::JITThunks::ctiNativeCallThunk):
  • yarr/RegexJIT.h: (JSC::Yarr::RegexCodeBlock::operator!): (JSC::Yarr::RegexCodeBlock::execute):
File:
1 edited

Legend:

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

    r44412 r44455  
    4747namespace JSC {
    4848
    49 void ctiPatchCallByReturnAddress(MacroAssembler::ProcessorReturnAddress returnAddress, void* newCalleeFunction)
     49void ctiPatchNearCallByReturnAddress(MacroAssembler::ProcessorReturnAddress returnAddress, MacroAssemblerCodePtr newCalleeFunction)
     50{
     51    returnAddress.relinkNearCallerToTrampoline(newCalleeFunction);
     52}
     53
     54void ctiPatchCallByReturnAddress(MacroAssembler::ProcessorReturnAddress returnAddress, MacroAssemblerCodePtr newCalleeFunction)
     55{
     56    returnAddress.relinkCallerToTrampoline(newCalleeFunction);
     57}
     58
     59void ctiPatchCallByReturnAddress(MacroAssembler::ProcessorReturnAddress returnAddress, FunctionPtr newCalleeFunction)
    5060{
    5161    returnAddress.relinkCallerToFunction(newCalleeFunction);
    52 }
    53 
    54 void ctiPatchNearCallByReturnAddress(MacroAssembler::ProcessorReturnAddress returnAddress, void* newCalleeFunction)
    55 {
    56     returnAddress.relinkNearCallerToFunction(newCalleeFunction);
    5762}
    5863
     
    459464    for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) {
    460465        if (iter->to)
    461             patchBuffer.link(iter->from, iter->to);
     466            patchBuffer.link(iter->from, FunctionPtr(iter->to));
    462467    }
    463468
     
    499504}
    500505
    501 void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* globalData, void** ctiArrayLengthTrampoline, void** ctiStringLengthTrampoline, void** ctiVirtualCallPreLink, void** ctiVirtualCallLink, void** ctiVirtualCall, void** ctiNativeCallThunk)
     506void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* globalData, CodePtr* ctiArrayLengthTrampoline, CodePtr* ctiStringLengthTrampoline, CodePtr* ctiVirtualCallPreLink, CodePtr* ctiVirtualCallLink, CodePtr* ctiVirtualCall, CodePtr* ctiNativeCallThunk)
    502507{
    503508#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
     
    844849
    845850#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
    846     patchBuffer.link(array_failureCases1Call, JITStubs::cti_op_get_by_id_array_fail);
    847     patchBuffer.link(array_failureCases2Call, JITStubs::cti_op_get_by_id_array_fail);
    848     patchBuffer.link(array_failureCases3Call, JITStubs::cti_op_get_by_id_array_fail);
    849     patchBuffer.link(string_failureCases1Call, JITStubs::cti_op_get_by_id_string_fail);
    850     patchBuffer.link(string_failureCases2Call, JITStubs::cti_op_get_by_id_string_fail);
    851     patchBuffer.link(string_failureCases3Call, JITStubs::cti_op_get_by_id_string_fail);
    852 #endif
    853     patchBuffer.link(callArityCheck1, JITStubs::cti_op_call_arityCheck);
    854     patchBuffer.link(callArityCheck2, JITStubs::cti_op_call_arityCheck);
    855     patchBuffer.link(callArityCheck3, JITStubs::cti_op_call_arityCheck);
    856     patchBuffer.link(callJSFunction1, JITStubs::cti_op_call_JSFunction);
    857     patchBuffer.link(callJSFunction2, JITStubs::cti_op_call_JSFunction);
    858     patchBuffer.link(callJSFunction3, JITStubs::cti_op_call_JSFunction);
    859     patchBuffer.link(callDontLazyLinkCall, JITStubs::cti_vm_dontLazyLinkCall);
    860     patchBuffer.link(callLazyLinkCall, JITStubs::cti_vm_lazyLinkCall);
     851    patchBuffer.link(array_failureCases1Call, FunctionPtr(JITStubs::cti_op_get_by_id_array_fail));
     852    patchBuffer.link(array_failureCases2Call, FunctionPtr(JITStubs::cti_op_get_by_id_array_fail));
     853    patchBuffer.link(array_failureCases3Call, FunctionPtr(JITStubs::cti_op_get_by_id_array_fail));
     854    patchBuffer.link(string_failureCases1Call, FunctionPtr(JITStubs::cti_op_get_by_id_string_fail));
     855    patchBuffer.link(string_failureCases2Call, FunctionPtr(JITStubs::cti_op_get_by_id_string_fail));
     856    patchBuffer.link(string_failureCases3Call, FunctionPtr(JITStubs::cti_op_get_by_id_string_fail));
     857#endif
     858    patchBuffer.link(callArityCheck1, FunctionPtr(JITStubs::cti_op_call_arityCheck));
     859    patchBuffer.link(callArityCheck2, FunctionPtr(JITStubs::cti_op_call_arityCheck));
     860    patchBuffer.link(callArityCheck3, FunctionPtr(JITStubs::cti_op_call_arityCheck));
     861    patchBuffer.link(callJSFunction1, FunctionPtr(JITStubs::cti_op_call_JSFunction));
     862    patchBuffer.link(callJSFunction2, FunctionPtr(JITStubs::cti_op_call_JSFunction));
     863    patchBuffer.link(callJSFunction3, FunctionPtr(JITStubs::cti_op_call_JSFunction));
     864    patchBuffer.link(callDontLazyLinkCall, FunctionPtr(JITStubs::cti_vm_dontLazyLinkCall));
     865    patchBuffer.link(callLazyLinkCall, FunctionPtr(JITStubs::cti_vm_lazyLinkCall));
    861866
    862867    CodeRef finalCode = patchBuffer.finalizeCode();
Note: See TracChangeset for help on using the changeset viewer.