Ignore:
Timestamp:
Jul 21, 2009, 8:24:34 PM (16 years ago)
Author:
[email protected]
Message:

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

Reviewed by Sam Weinig.

Move call linking / repatching down from AbstractMacroAssembler into MacroAssemblerARCH classes.
( https://bugs.webkit.org/show_bug.cgi?id=27527 )

This allows the implementation to be defined per architecture. Specifically this addresses the
fact that x86-64 MacroAssembler implements far calls as a load to register, followed by a call
to register. Patching the call actually requires the pointer load to be patched, rather than
the call to be patched. This is implementation detail specific to MacroAssemblerX86_64, and as
such is best handled there.

  • assembler/AbstractMacroAssembler.h:
  • assembler/MacroAssemblerARM.h: (JSC::MacroAssemblerARM::linkCall): (JSC::MacroAssemblerARM::repatchCall):
  • assembler/MacroAssemblerARMv7.h: (JSC::MacroAssemblerARMv7::linkCall): (JSC::MacroAssemblerARMv7::repatchCall):
  • assembler/MacroAssemblerX86.h: (JSC::MacroAssemblerX86::linkCall): (JSC::MacroAssemblerX86::repatchCall):
  • assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::linkCall): (JSC::MacroAssemblerX86_64::repatchCall):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/assembler/AbstractMacroAssembler.h

    r46202 r46209  
    3636#if ENABLE(ASSEMBLER)
    3737
    38 // FIXME: keep transitioning this out into MacroAssemblerX86_64.
    39 #if PLATFORM(X86_64)
    40 #define REPTACH_OFFSET_CALL_R11 3
    41 #endif
    42 
    4338namespace JSC {
    4439
     
    296291        template<class TemplateAssemblerType>
    297292        friend class AbstractMacroAssembler;
    298         friend class LinkBuffer;
     293
    299294    public:
    300295        enum Flags {
     
    331326        }
    332327
     328        JmpSrc m_jmp;
    333329    private:
    334         JmpSrc m_jmp;
    335330        Flags m_flags;
    336331    };
     
    486481    AssemblerType m_assembler;
    487482
    488 private:
    489483    friend class LinkBuffer;
    490484    friend class RepatchBuffer;
     
    495489    }
    496490
    497     static void linkCall(void* code, Call call, FunctionPtr function)
    498     {
    499 #if PLATFORM(X86_64)
    500         if (!call.isFlagSet(Call::Near)) {
    501             char* callLocation = reinterpret_cast<char*>(getLinkerAddress(code, call.m_jmp)) - REPTACH_OFFSET_CALL_R11;
    502             AssemblerType::linkPointerForCall(callLocation, function.value());
    503         } else
    504 #endif
    505         AssemblerType::linkCall(code, call.m_jmp, function.value());
    506     }
    507 
    508491    static void linkPointer(void* code, typename AssemblerType::JmpDst label, void* value)
    509492    {
     
    531514    }
    532515
    533     static void repatchCall(CodeLocationCall call, CodeLocationLabel destination)
    534     {
    535 #if PLATFORM(X86_64)
    536         AssemblerType::repatchPointer(call.dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11).dataLocation(), destination.executableAddress());
    537 #else
    538         AssemblerType::relinkCall(call.dataLocation(), destination.executableAddress());
    539 #endif
    540     }
    541 
    542     static void repatchCall(CodeLocationCall call, FunctionPtr destination)
    543     {
    544 #if PLATFORM(X86_64)
    545         AssemblerType::repatchPointer(call.dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11).dataLocation(), destination.executableAddress());
    546 #else
    547         AssemblerType::relinkCall(call.dataLocation(), destination.executableAddress());
    548 #endif
    549     }
    550 
    551516    static void repatchNearCall(CodeLocationNearCall nearCall, CodeLocationLabel destination)
    552517    {
Note: See TracChangeset for help on using the changeset viewer.