Changeset 44455 in webkit for trunk/JavaScriptCore/assembler


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):
Location:
trunk/JavaScriptCore/assembler
Files:
3 edited

Legend:

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

    r44443 r44455  
    4545class AbstractMacroAssembler {
    4646public:
     47    typedef MacroAssemblerCodePtr CodePtr;
    4748    typedef MacroAssemblerCodeRef CodeRef;
    4849
     
    415416    public:
    416417        CodeLocationCommon()
    417             : m_location(0)
    418418        {
    419419        }
     
    432432        CodeLocationDataLabel32 dataLabel32AtOffset(int offset);
    433433
    434         operator bool() { return m_location; }
    435         void reset() { m_location = 0; }
    436 
    437434    protected:
    438         explicit CodeLocationCommon(void* location)
     435        explicit CodeLocationCommon(CodePtr location)
    439436            : m_location(location)
    440437        {
    441438        }
    442439
    443         void* m_location;
     440        void* dataLocation() { return m_location.dataLocation(); }
     441        void* executableAddress() { return m_location.executableAddress(); }
     442   
     443        void reset()
     444        {
     445            m_location = CodePtr();
     446        }
     447
     448    private:
     449        CodePtr m_location;
    444450    };
    445451
     
    456462        void repatchLoadToLEA()
    457463        {
    458             AssemblerType::repatchLoadToLEA(this->m_location);
     464            AssemblerType::repatchLoadToLEA(this->dataLocation());
    459465        }
    460466
    461467    private:
    462468        explicit CodeLocationInstruction(void* location)
    463             : CodeLocationCommon(location)
     469            : CodeLocationCommon(CodePtr(location))
    464470        {
    465471        }
     
    482488        }
    483489
    484         void* addressForSwitch() { return this->m_location; }
    485         void* addressForExceptionHandler() { return this->m_location; }
    486         void* addressForJSR() { return this->m_location; }
    487 
    488         template<typename FunctionSig>
    489         static CodeLocationLabel fromFunctionPointer(FunctionSig* function)
    490         {
    491             return CodeLocationLabel(reinterpret_cast<void*>(function));
    492         }
    493 
    494     private:
     490        void* addressForSwitch() { return this->executableAddress(); }
     491        void* addressForExceptionHandler() { return this->executableAddress(); }
     492        void* addressForJSR() { return this->executableAddress(); }
     493
     494        bool operator!()
     495        {
     496            return !this->executableAddress();
     497        }
     498
     499        void reset()
     500        {
     501            CodeLocationCommon::reset();
     502        }
     503
     504    private:
     505        explicit CodeLocationLabel(CodePtr location)
     506            : CodeLocationCommon(location)
     507        {
     508        }
     509
    495510        explicit CodeLocationLabel(void* location)
    496             : CodeLocationCommon(location)
    497         {
    498         }
    499 
    500         void* getJumpDestination() { return this->m_location; }
     511            : CodeLocationCommon(CodePtr(location))
     512        {
     513        }
     514
     515        void* getJumpDestination() { return this->executableAddress(); }
    501516    };
    502517
     
    514529        void relink(CodeLocationLabel destination)
    515530        {
    516             AssemblerType::relinkJump(this->m_location, destination.m_location);
     531            AssemblerType::relinkJump(this->dataLocation(), destination.executableAddress());
    517532        }
    518533
    519534    private:
    520535        explicit CodeLocationJump(void* location)
    521             : CodeLocationCommon(location)
     536            : CodeLocationCommon(CodePtr(location))
    522537        {
    523538        }
     
    530545        friend class CodeLocationCommon;
    531546        friend class PatchBuffer;
     547        friend class ProcessorReturnAddress;
    532548    public:
    533549        CodeLocationCall()
     
    535551        }
    536552
    537         CodeLocationCall(ProcessorReturnAddress*);
    538 
    539553        void relink(CodeLocationLabel destination)
    540554        {
    541555#if PLATFORM(X86_64)
    542             CodeLocationCommon::dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11).repatch(destination.m_location);
     556            CodeLocationCommon::dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11).repatch(destination.executableAddress());
    543557#else
    544             AssemblerType::relinkCall(this->m_location, destination.m_location);
     558            AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress());
    545559#endif
    546560        }
    547561
    548         template<typename FunctionSig>
    549         void relink(FunctionSig* function)
    550         {
    551             relink(CodeLocationLabel::fromFunctionPointer(function));
     562        void relink(FunctionPtr destination)
     563        {
     564#if PLATFORM(X86_64)
     565            CodeLocationCommon::dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11).repatch(destination.executableAddress());
     566#else
     567            AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress());
     568#endif
    552569        }
    553570
     
    556573        void* calleeReturnAddressValue()
    557574        {
    558             return this->m_location;
    559         }
    560 
    561     private:
     575            return this->executableAddress();
     576        }
     577
     578    private:
     579        explicit CodeLocationCall(CodePtr location)
     580            : CodeLocationCommon(location)
     581        {
     582        }
     583
    562584        explicit CodeLocationCall(void* location)
    563             : CodeLocationCommon(location)
     585            : CodeLocationCommon(CodePtr(location))
    564586        {
    565587        }
     
    572594        friend class CodeLocationCommon;
    573595        friend class PatchBuffer;
     596        friend class ProcessorReturnAddress;
    574597    public:
    575598        CodeLocationNearCall()
     
    577600        }
    578601
    579         CodeLocationNearCall(ProcessorReturnAddress*);
     602        void relink(CodePtr destination)
     603        {
     604            AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress());
     605        }
    580606
    581607        void relink(CodeLocationLabel destination)
    582608        {
    583             AssemblerType::relinkCall(this->m_location, destination.m_location);
    584         }
    585 
    586         template<typename FunctionSig>
    587         void relink(FunctionSig* function)
    588         {
    589             relink(CodeLocationLabel::fromFunctionPointer(function));
     609            AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress());
     610        }
     611
     612        void relink(FunctionPtr destination)
     613        {
     614            AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress());
    590615        }
    591616
     
    594619        void* calleeReturnAddressValue()
    595620        {
    596             return this->m_location;
    597         }
    598 
    599     private:
     621            return this->executableAddress();
     622        }
     623
     624    private:
     625        explicit CodeLocationNearCall(CodePtr location)
     626            : CodeLocationCommon(location)
     627        {
     628        }
     629
    600630        explicit CodeLocationNearCall(void* location)
    601             : CodeLocationCommon(location)
     631            : CodeLocationCommon(CodePtr(location))
    602632        {
    603633        }
     
    617647        void repatch(int32_t value)
    618648        {
    619             AssemblerType::repatchInt32(this->m_location, value);
     649            AssemblerType::repatchInt32(this->dataLocation(), value);
    620650        }
    621651
    622652    private:
    623653        explicit CodeLocationDataLabel32(void* location)
    624             : CodeLocationCommon(location)
     654            : CodeLocationCommon(CodePtr(location))
    625655        {
    626656        }
     
    640670        void repatch(void* value)
    641671        {
    642             AssemblerType::repatchPointer(this->m_location, value);
     672            AssemblerType::repatchPointer(this->dataLocation(), value);
    643673        }
    644674
    645675    private:
    646676        explicit CodeLocationDataLabelPtr(void* location)
    647             : CodeLocationCommon(location)
     677            : CodeLocationCommon(CodePtr(location))
    648678        {
    649679        }
     
    664694        void relinkCallerToTrampoline(CodeLocationLabel label)
    665695        {
    666             CodeLocationCall(this).relink(label);
    667         }
    668        
    669         template<typename FunctionSig>
    670         void relinkCallerToFunction(FunctionSig* newCalleeFunction)
    671         {
    672             relinkCallerToTrampoline(CodeLocationLabel::fromFunctionPointer(newCalleeFunction));
     696            CodeLocationCall(CodePtr(m_location)).relink(label);
     697        }
     698       
     699        void relinkCallerToTrampoline(CodePtr newCalleeFunction)
     700        {
     701            relinkCallerToTrampoline(CodeLocationLabel(newCalleeFunction));
     702        }
     703
     704        void relinkCallerToFunction(FunctionPtr function)
     705        {
     706            CodeLocationCall(CodePtr(m_location)).relink(function);
    673707        }
    674708       
    675709        void relinkNearCallerToTrampoline(CodeLocationLabel label)
    676710        {
    677             CodeLocationNearCall(this).relink(label);
    678         }
    679        
    680         template<typename FunctionSig>
    681         void relinkNearCallerToFunction(FunctionSig* newCalleeFunction)
    682         {
    683             relinkNearCallerToTrampoline(CodeLocationLabel::fromFunctionPointer(newCalleeFunction));
    684         }
    685        
    686         operator void*()
    687         {
    688             return m_location;
    689         }
    690 
    691     private:
    692         void* m_location;
     711            CodeLocationNearCall(CodePtr(m_location)).relink(label);
     712        }
     713       
     714        void relinkNearCallerToTrampoline(CodePtr newCalleeFunction)
     715        {
     716            relinkNearCallerToTrampoline(CodeLocationLabel(newCalleeFunction));
     717        }
     718
     719        void* addressForLookup()
     720        {
     721            return m_location.value();
     722        }
     723
     724    private:
     725        ReturnAddressPtr m_location;
    693726    };
    694727
     
    696729    // Section 4: PatchBuffer - utility to finalize code generation.
    697730
    698     static void* trampolineAt(CodeRef ref, Label label)
    699     {
    700         return AssemblerType::getRelocatedAddress(ref.m_code, label.m_label);
     731    static CodePtr trampolineAt(CodeRef ref, Label label)
     732    {
     733        return CodePtr(AssemblerType::getRelocatedAddress(ref.m_code.dataLocation(), label.m_label));
    701734    }
    702735
     
    740773        // These methods are used to link or set values at code generation time.
    741774
    742         template<typename FunctionSig>
    743         void link(Call call, FunctionSig* function)
     775        void link(Call call, FunctionPtr function)
    744776        {
    745777            ASSERT(call.isFlagSet(Call::Linkable));
    746778#if PLATFORM(X86_64)
    747779            if (!call.isFlagSet(Call::Near)) {
    748                 intptr_t callLocation = reinterpret_cast<intptr_t>(AssemblerType::getRelocatedAddress(code(), call.m_jmp)) - REPTACH_OFFSET_CALL_R11;
    749                 AssemblerType::patchPointer(reinterpret_cast<void*>(callLocation), reinterpret_cast<void*>(function));
     780                char* callLocation = reinterpret_cast<char*>(AssemblerType::getRelocatedAddress(code(), call.m_jmp)) - REPTACH_OFFSET_CALL_R11;
     781                AssemblerType::patchPointerForCall(callLocation, function.value());
    750782            } else
    751783#endif
    752             AssemblerType::linkCall(code(), call.m_jmp, reinterpret_cast<void*>(function));
    753         }
    754        
    755         template<typename FunctionSig>
    756         void linkTailRecursive(Jump jump, FunctionSig* function)
    757         {
    758             AssemblerType::linkJump(code(), jump.m_jmp, reinterpret_cast<void*>(function));
    759         }
    760 
    761         template<typename FunctionSig>
    762         void linkTailRecursive(JumpList list, FunctionSig* function)
     784            AssemblerType::linkCall(code(), call.m_jmp, function.value());
     785        }
     786       
     787        void link(Jump jump, CodeLocationLabel label)
     788        {
     789            AssemblerType::linkJump(code(), jump.m_jmp, label.executableAddress());
     790        }
     791
     792        void link(JumpList list, CodeLocationLabel label)
    763793        {
    764794            for (unsigned i = 0; i < list.m_jumps.size(); ++i)
    765                 AssemblerType::linkJump(code(), list.m_jumps[i].m_jmp, reinterpret_cast<void*>(function));
    766         }
    767 
    768         void link(Jump jump, CodeLocationLabel label)
    769         {
    770             AssemblerType::linkJump(code(), jump.m_jmp, label.m_location);
    771         }
    772 
    773         void link(JumpList list, CodeLocationLabel label)
    774         {
    775             for (unsigned i = 0; i < list.m_jumps.size(); ++i)
    776                 AssemblerType::linkJump(code(), list.m_jumps[i].m_jmp, label.m_location);
     795                AssemblerType::linkJump(code(), list.m_jumps[i].m_jmp, label.executableAddress());
    777796        }
    778797
     
    857876#endif
    858877
    859             ExecutableAllocator::makeExecutable(m_code, m_size);
     878            ExecutableAllocator::makeExecutable(code(), m_size);
    860879        }
    861880
     
    935954typename AbstractMacroAssembler<AssemblerType>::CodeLocationInstruction AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::instructionAtOffset(int offset)
    936955{
    937     return typename AbstractMacroAssembler::CodeLocationInstruction(reinterpret_cast<char*>(m_location) + offset);
     956    return typename AbstractMacroAssembler::CodeLocationInstruction(reinterpret_cast<char*>(dataLocation()) + offset);
    938957}
    939958
     
    941960typename AbstractMacroAssembler<AssemblerType>::CodeLocationLabel AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::labelAtOffset(int offset)
    942961{
    943     return typename AbstractMacroAssembler::CodeLocationLabel(reinterpret_cast<char*>(m_location) + offset);
     962    return typename AbstractMacroAssembler::CodeLocationLabel(reinterpret_cast<char*>(dataLocation()) + offset);
    944963}
    945964
     
    947966typename AbstractMacroAssembler<AssemblerType>::CodeLocationJump AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::jumpAtOffset(int offset)
    948967{
    949     return typename AbstractMacroAssembler::CodeLocationJump(reinterpret_cast<char*>(m_location) + offset);
     968    return typename AbstractMacroAssembler::CodeLocationJump(reinterpret_cast<char*>(dataLocation()) + offset);
    950969}
    951970
     
    953972typename AbstractMacroAssembler<AssemblerType>::CodeLocationCall AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::callAtOffset(int offset)
    954973{
    955     return typename AbstractMacroAssembler::CodeLocationCall(reinterpret_cast<char*>(m_location) + offset);
     974    return typename AbstractMacroAssembler::CodeLocationCall(reinterpret_cast<char*>(dataLocation()) + offset);
    956975}
    957976
     
    959978typename AbstractMacroAssembler<AssemblerType>::CodeLocationNearCall AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::nearCallAtOffset(int offset)
    960979{
    961     return typename AbstractMacroAssembler::CodeLocationNearCall(reinterpret_cast<char*>(m_location) + offset);
     980    return typename AbstractMacroAssembler::CodeLocationNearCall(reinterpret_cast<char*>(dataLocation()) + offset);
    962981}
    963982
     
    965984typename AbstractMacroAssembler<AssemblerType>::CodeLocationDataLabelPtr AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::dataLabelPtrAtOffset(int offset)
    966985{
    967     return typename AbstractMacroAssembler::CodeLocationDataLabelPtr(reinterpret_cast<char*>(m_location) + offset);
     986    return typename AbstractMacroAssembler::CodeLocationDataLabelPtr(reinterpret_cast<char*>(dataLocation()) + offset);
    968987}
    969988
     
    971990typename AbstractMacroAssembler<AssemblerType>::CodeLocationDataLabel32 AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::dataLabel32AtOffset(int offset)
    972991{
    973     return typename AbstractMacroAssembler::CodeLocationDataLabel32(reinterpret_cast<char*>(m_location) + offset);
     992    return typename AbstractMacroAssembler::CodeLocationDataLabel32(reinterpret_cast<char*>(dataLocation()) + offset);
    974993}
    975994
    976 template <class AssemblerType>
    977 AbstractMacroAssembler<AssemblerType>::CodeLocationCall::CodeLocationCall(typename AbstractMacroAssembler<AssemblerType>::ProcessorReturnAddress* ra)
    978     : CodeLocationCommon(ra->m_location)
    979 {
    980 }
    981 
    982 template <class AssemblerType>
    983 AbstractMacroAssembler<AssemblerType>::CodeLocationNearCall::CodeLocationNearCall(typename AbstractMacroAssembler<AssemblerType>::ProcessorReturnAddress* ra)
    984     : CodeLocationCommon(ra->m_location)
    985 {
    986 }
    987 
    988995} // namespace JSC
    989996
  • trunk/JavaScriptCore/assembler/MacroAssemblerCodeRef.h

    r44030 r44455  
    3838namespace JSC {
    3939
     40// FunctionPtr:
     41//
     42// FunctionPtr should be used to wrap pointers to C/C++ functions in JSC
     43// (particularly, the stub functions).
     44class FunctionPtr {
     45public:
     46    FunctionPtr()
     47        : m_value(0)
     48    {
     49    }
     50
     51    template<typename FunctionType>
     52    explicit FunctionPtr(FunctionType* value)
     53        : m_value(reinterpret_cast<void*>(value))
     54    {
     55        ASSERT(m_value);
     56    }
     57
     58    void* value() const { return m_value; }
     59    void* executableAddress() const { return m_value; }
     60
     61
     62private:
     63    void* m_value;
     64};
     65
     66// ReturnAddressPtr:
     67//
     68// ReturnAddressPtr should be used to wrap return addresses generated by processor
     69// 'call' instructions exectued in JIT code.  We use return addresses to look up
     70// exception and optimization information, and to repatch the call instruction
     71// that is the source of the return address.
     72class ReturnAddressPtr {
     73public:
     74    ReturnAddressPtr()
     75        : m_value(0)
     76    {
     77    }
     78
     79    explicit ReturnAddressPtr(void* value)
     80        : m_value(value)
     81    {
     82        ASSERT(m_value);
     83    }
     84
     85    void* value() const { return m_value; }
     86
     87private:
     88    void* m_value;
     89};
     90
     91// MacroAssemblerCodePtr:
     92//
     93// MacroAssemblerCodePtr should be used to wrap pointers to JIT generated code.
     94class MacroAssemblerCodePtr {
     95public:
     96    MacroAssemblerCodePtr()
     97        : m_value(0)
     98    {
     99    }
     100
     101    explicit MacroAssemblerCodePtr(void* value)
     102        : m_value(value)
     103    {
     104        ASSERT(m_value);
     105    }
     106
     107    explicit MacroAssemblerCodePtr(ReturnAddressPtr ra)
     108        : m_value(ra.value())
     109    {
     110        ASSERT(m_value);
     111    }
     112
     113    void* executableAddress() const { return m_value; }
     114    void* dataLocation() const { ASSERT(m_value); return m_value; }
     115
     116private:
     117    void* m_value;
     118};
     119
    40120// MacroAssemblerCodeRef:
    41121//
     
    46126public:
    47127    MacroAssemblerCodeRef()
    48         : m_code(0)
    49128#ifndef NDEBUG
    50         , m_size(0)
     129        : m_size(0)
    51130#endif
    52131    {
     
    64143    }
    65144
    66     void* m_code;
     145    MacroAssemblerCodePtr m_code;
    67146    RefPtr<ExecutablePool> m_executablePool;
    68147#ifndef NDEBUG
  • trunk/JavaScriptCore/assembler/X86Assembler.h

    r44341 r44455  
    13701370    }
    13711371   
    1372     void linkCall(JmpSrc from, JmpDst to)
     1372    static void linkJump(void* code, JmpSrc from, void* to)
    13731373    {
    13741374        ASSERT(from.m_offset != -1);
    1375         ASSERT(to.m_offset != -1);
    1376        
    1377         char* code = reinterpret_cast<char*>(m_formatter.data());
    1378         patchRel32(code + from.m_offset, code + to.m_offset);
    1379     }
    1380    
    1381     static void linkJump(void* code, JmpSrc from, void* to)
     1375
     1376        patchRel32(reinterpret_cast<char*>(code) + from.m_offset, to);
     1377    }
     1378
     1379    static void linkCall(void* code, JmpSrc from, void* to)
    13821380    {
    13831381        ASSERT(from.m_offset != -1);
     
    13861384    }
    13871385
    1388     static void linkCall(void* code, JmpSrc from, void* to)
    1389     {
    1390         ASSERT(from.m_offset != -1);
    1391 
    1392         patchRel32(reinterpret_cast<char*>(code) + from.m_offset, to);
    1393     }
    1394 
    13951386    static void patchPointer(void* where, void* value)
    13961387    {
    13971388        reinterpret_cast<void**>(where)[-1] = value;
    13981389    }
     1390
     1391#if PLATFORM(X86_64)
     1392    static void patchPointerForCall(void* where, void* value)
     1393    {
     1394        reinterpret_cast<void**>(where)[-1] = value;
     1395    }
     1396#endif
    13991397
    14001398    static void patchPointer(void* code, JmpDst where, void* value)
Note: See TracChangeset for help on using the changeset viewer.