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/JITPropertyAccess.cpp

    r44412 r44455  
    492492    PatchBuffer patchBuffer(this, m_codeBlock->executablePool());
    493493
    494     patchBuffer.link(failureCall, JITStubs::cti_op_put_by_id_fail);
     494    patchBuffer.link(failureCall, FunctionPtr(JITStubs::cti_op_put_by_id_fail));
    495495
    496496    if (willNeedStorageRealloc) {
    497497        ASSERT(m_calls.size() == 1);
    498         patchBuffer.link(m_calls[0].from, JITStubs::cti_op_put_by_id_transition_realloc);
     498        patchBuffer.link(m_calls[0].from, FunctionPtr(JITStubs::cti_op_put_by_id_transition_realloc));
    499499    }
    500500   
     
    508508    // We don't want to patch more than once - in future go to cti_op_get_by_id_generic.
    509509    // Should probably go to JITStubs::cti_op_get_by_id_fail, but that doesn't do anything interesting right now.
    510     returnAddress.relinkCallerToFunction(JITStubs::cti_op_get_by_id_self_fail);
     510    returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_get_by_id_self_fail));
    511511
    512512    int offset = sizeof(JSValue) * cachedOffset;
     
    538538    // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
    539539    // Should probably go to JITStubs::cti_op_put_by_id_fail, but that doesn't do anything interesting right now.
    540     returnAddress.relinkCallerToFunction(JITStubs::cti_op_put_by_id_generic);
     540    returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_put_by_id_generic));
    541541
    542542    int offset = sizeof(JSValue) * cachedOffset;
     
    554554void JIT::privateCompilePatchGetArrayLength(ProcessorReturnAddress returnAddress)
    555555{
    556     StructureStubInfo* stubInfo = &m_codeBlock->getStubInfo(returnAddress);
     556    StructureStubInfo* stubInfo = &m_codeBlock->getStubInfo(returnAddress.addressForLookup());
    557557
    558558    // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
    559     returnAddress.relinkCallerToFunction(JITStubs::cti_op_get_by_id_array_fail);
     559    returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_get_by_id_array_fail));
    560560
    561561    // Check eax is an array
     
    593593{
    594594    // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
    595     returnAddress.relinkCallerToFunction(JITStubs::cti_op_get_by_id_proto_list);
     595    returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_get_by_id_proto_list));
    596596
    597597    // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a Structure that is
     
    763763{
    764764    // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
    765     returnAddress.relinkCallerToFunction(JITStubs::cti_op_get_by_id_proto_list);
     765    returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_get_by_id_proto_list));
    766766
    767767    ASSERT(count);
Note: See TracChangeset for help on using the changeset viewer.