Ignore:
Timestamp:
Jun 15, 2009, 5:26:53 PM (16 years ago)
Author:
[email protected]
Message:

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

Reviewed by Oliver Hunt.

Move repatching methods into a set of methods on a class. This will allow us to
coallesce memory reprotection calls. Really, we want this class to be called
PatchBuffer, we want the class PatchBuffer to be called LinkBuffer, we want both
to be memblers of MacroAssembler rather then AbstractMacroAssembler, we don't
want the CodeLocationFoo types anymore (they are now only really there to provide
type safety, and that is completely undermined by the way we use offsets). Then
the link & patch buffers should delegate the actual patching calls to the
architecture-specific layer of the MacroAssembler. Landing all these changes as a
sequence of patches.

No performance impact.

  • assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::CodeLocationCall::CodeLocationCall): (JSC::AbstractMacroAssembler::CodeLocationNearCall::CodeLocationNearCall): (JSC::AbstractMacroAssembler::CodeLocationNearCall::calleeReturnAddressValue): (JSC::AbstractMacroAssembler::RepatchBuffer::RepatchBuffer): (JSC::AbstractMacroAssembler::RepatchBuffer::relink): (JSC::AbstractMacroAssembler::RepatchBuffer::repatch): (JSC::AbstractMacroAssembler::RepatchBuffer::relinkCallerToTrampoline): (JSC::AbstractMacroAssembler::RepatchBuffer::relinkCallerToFunction): (JSC::AbstractMacroAssembler::RepatchBuffer::relinkNearCallerToTrampoline): (JSC::AbstractMacroAssembler::RepatchBuffer::repatchLoadPtrToLEA):
  • jit/JIT.cpp: (JSC::ctiPatchNearCallByReturnAddress): (JSC::ctiPatchCallByReturnAddress): (JSC::JIT::unlinkCall): (JSC::JIT::linkCall):
  • jit/JITPropertyAccess.cpp: (JSC::JIT::privateCompilePutByIdTransition): (JSC::JIT::patchGetByIdSelf): (JSC::JIT::patchMethodCallProto): (JSC::JIT::patchPutByIdReplace): (JSC::JIT::privateCompilePatchGetArrayLength): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdSelfList): (JSC::JIT::privateCompileGetByIdProtoList): (JSC::JIT::privateCompileGetByIdChainList): (JSC::JIT::privateCompileGetByIdChain):
File:
1 edited

Legend:

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

    r44525 r44700  
    499499    CodeLocationLabel entryLabel = patchBuffer.finalizeCodeAddendum();
    500500    stubInfo->stubRoutine = entryLabel;
    501     returnAddress.relinkCallerToTrampoline(entryLabel);
     501    RepatchBuffer repatchBuffer;
     502    repatchBuffer.relinkCallerToTrampoline(returnAddress, entryLabel);
    502503}
    503504
    504505void JIT::patchGetByIdSelf(StructureStubInfo* stubInfo, Structure* structure, size_t cachedOffset, ProcessorReturnAddress returnAddress)
    505506{
     507    RepatchBuffer repatchBuffer;
     508
    506509    // We don't want to patch more than once - in future go to cti_op_get_by_id_generic.
    507510    // Should probably go to JITStubs::cti_op_get_by_id_fail, but that doesn't do anything interesting right now.
    508     returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_get_by_id_self_fail));
     511    repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(JITStubs::cti_op_get_by_id_self_fail));
    509512
    510513    int offset = sizeof(JSValue) * cachedOffset;
     
    513516    // and makes the subsequent load's offset automatically correct
    514517    if (structure->isUsingInlineStorage())
    515         stubInfo->hotPathBegin.instructionAtOffset(patchOffsetGetByIdExternalLoad).repatchLoadPtrToLEA();
     518        repatchBuffer.repatchLoadPtrToLEA(stubInfo->hotPathBegin.instructionAtOffset(patchOffsetGetByIdExternalLoad));
    516519
    517520    // Patch the offset into the propoerty map to load from, then patch the Structure to look for.
    518     stubInfo->hotPathBegin.dataLabelPtrAtOffset(patchOffsetGetByIdStructure).repatch(structure);
    519     stubInfo->hotPathBegin.dataLabel32AtOffset(patchOffsetGetByIdPropertyMapOffset).repatch(offset);
     521    repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelPtrAtOffset(patchOffsetGetByIdStructure), structure);
     522    repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabel32AtOffset(patchOffsetGetByIdPropertyMapOffset), offset);
    520523}
    521524
    522525void JIT::patchMethodCallProto(MethodCallLinkInfo& methodCallLinkInfo, JSFunction* callee, Structure* structure, JSObject* proto)
    523526{
     527    RepatchBuffer repatchBuffer;
     528
    524529    ASSERT(!methodCallLinkInfo.cachedStructure);
    525530    methodCallLinkInfo.cachedStructure = structure;
    526531    structure->ref();
    527532
    528     methodCallLinkInfo.structureLabel.repatch(structure);
    529     methodCallLinkInfo.structureLabel.dataLabelPtrAtOffset(patchOffsetMethodCheckProtoObj).repatch(proto);
    530     methodCallLinkInfo.structureLabel.dataLabelPtrAtOffset(patchOffsetMethodCheckProtoStruct).repatch(proto->structure());
    531     methodCallLinkInfo.structureLabel.dataLabelPtrAtOffset(patchOffsetMethodCheckPutFunction).repatch(callee);
     533    repatchBuffer.repatch(methodCallLinkInfo.structureLabel, structure);
     534    repatchBuffer.repatch(methodCallLinkInfo.structureLabel.dataLabelPtrAtOffset(patchOffsetMethodCheckProtoObj), proto);
     535    repatchBuffer.repatch(methodCallLinkInfo.structureLabel.dataLabelPtrAtOffset(patchOffsetMethodCheckProtoStruct), proto->structure());
     536    repatchBuffer.repatch(methodCallLinkInfo.structureLabel.dataLabelPtrAtOffset(patchOffsetMethodCheckPutFunction), callee);
    532537}
    533538
    534539void JIT::patchPutByIdReplace(StructureStubInfo* stubInfo, Structure* structure, size_t cachedOffset, ProcessorReturnAddress returnAddress)
    535540{
     541    RepatchBuffer repatchBuffer;
     542
    536543    // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
    537544    // Should probably go to JITStubs::cti_op_put_by_id_fail, but that doesn't do anything interesting right now.
    538     returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_put_by_id_generic));
     545    repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(JITStubs::cti_op_put_by_id_generic));
    539546
    540547    int offset = sizeof(JSValue) * cachedOffset;
     
    543550    // and makes the subsequent load's offset automatically correct
    544551    if (structure->isUsingInlineStorage())
    545         stubInfo->hotPathBegin.instructionAtOffset(patchOffsetPutByIdExternalLoad).repatchLoadPtrToLEA();
     552        repatchBuffer.repatchLoadPtrToLEA(stubInfo->hotPathBegin.instructionAtOffset(patchOffsetPutByIdExternalLoad));
    546553
    547554    // Patch the offset into the propoerty map to load from, then patch the Structure to look for.
    548     stubInfo->hotPathBegin.dataLabelPtrAtOffset(patchOffsetPutByIdStructure).repatch(structure);
    549     stubInfo->hotPathBegin.dataLabel32AtOffset(patchOffsetPutByIdPropertyMapOffset).repatch(offset);
     555    repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelPtrAtOffset(patchOffsetPutByIdStructure), structure);
     556    repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabel32AtOffset(patchOffsetPutByIdPropertyMapOffset), offset);
    550557}
    551558
     
    553560{
    554561    StructureStubInfo* stubInfo = &m_codeBlock->getStubInfo(returnAddress.addressForLookup());
    555 
    556     // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
    557     returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_get_by_id_array_fail));
    558562
    559563    // Check eax is an array
     
    585589    // Finally patch the jump to slow case back in the hot path to jump here instead.
    586590    CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(patchOffsetGetByIdBranchToSlowCase);
    587     jumpLocation.relink(entryLabel);
     591    RepatchBuffer repatchBuffer;
     592    repatchBuffer.relink(jumpLocation, entryLabel);
     593
     594    // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
     595    repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(JITStubs::cti_op_get_by_id_array_fail));
    588596}
    589597
    590598void JIT::privateCompileGetByIdProto(StructureStubInfo* stubInfo, Structure* structure, Structure* prototypeStructure, size_t cachedOffset, ProcessorReturnAddress returnAddress, CallFrame* callFrame)
    591599{
    592     // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
    593     returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_get_by_id_proto_list));
    594 
    595600    // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a Structure that is
    596601    // referencing the prototype object - let's speculatively load it's table nice and early!)
     
    630635    // Finally patch the jump to slow case back in the hot path to jump here instead.
    631636    CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(patchOffsetGetByIdBranchToSlowCase);
    632     jumpLocation.relink(entryLabel);
     637    RepatchBuffer repatchBuffer;
     638    repatchBuffer.relink(jumpLocation, entryLabel);
     639
     640    // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
     641    repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(JITStubs::cti_op_get_by_id_proto_list));
    633642}
    634643
     
    658667    // Finally patch the jump to slow case back in the hot path to jump here instead.
    659668    CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(patchOffsetGetByIdBranchToSlowCase);
    660     jumpLocation.relink(entryLabel);
     669    RepatchBuffer repatchBuffer;
     670    repatchBuffer.relink(jumpLocation, entryLabel);
    661671}
    662672
     
    702712    // Finally patch the jump to slow case back in the hot path to jump here instead.
    703713    CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(patchOffsetGetByIdBranchToSlowCase);
    704     jumpLocation.relink(entryLabel);
     714    RepatchBuffer repatchBuffer;
     715    repatchBuffer.relink(jumpLocation, entryLabel);
    705716}
    706717
     
    755766    // Finally patch the jump to slow case back in the hot path to jump here instead.
    756767    CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(patchOffsetGetByIdBranchToSlowCase);
    757     jumpLocation.relink(entryLabel);
     768    RepatchBuffer repatchBuffer;
     769    repatchBuffer.relink(jumpLocation, entryLabel);
    758770}
    759771
    760772void JIT::privateCompileGetByIdChain(StructureStubInfo* stubInfo, Structure* structure, StructureChain* chain, size_t count, size_t cachedOffset, ProcessorReturnAddress returnAddress, CallFrame* callFrame)
    761773{
    762     // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
    763     returnAddress.relinkCallerToFunction(FunctionPtr(JITStubs::cti_op_get_by_id_proto_list));
    764 
    765774    ASSERT(count);
    766775   
     
    805814    // Finally patch the jump to slow case back in the hot path to jump here instead.
    806815    CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(patchOffsetGetByIdBranchToSlowCase);
    807     jumpLocation.relink(entryLabel);
     816    RepatchBuffer repatchBuffer;
     817    repatchBuffer.relink(jumpLocation, entryLabel);
     818
     819    // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
     820    repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(JITStubs::cti_op_get_by_id_proto_list));
    808821}
    809822
Note: See TracChangeset for help on using the changeset viewer.