LLVM 20.0.0git
|
Remote-mapped RuntimeDyld-compatible memory manager. More...
#include "llvm/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.h"
Classes | |
struct | SymbolAddrs |
Symbol addresses for memory access. More... | |
Public Member Functions | |
EPCGenericRTDyldMemoryManager (ExecutorProcessControl &EPC, SymbolAddrs SAs) | |
Create an EPCGenericRTDyldMemoryManager using the given EPC and symbol addrs. | |
EPCGenericRTDyldMemoryManager (const EPCGenericRTDyldMemoryManager &)=delete | |
EPCGenericRTDyldMemoryManager & | operator= (const EPCGenericRTDyldMemoryManager &)=delete |
EPCGenericRTDyldMemoryManager (EPCGenericRTDyldMemoryManager &&)=delete | |
EPCGenericRTDyldMemoryManager & | operator= (EPCGenericRTDyldMemoryManager &&)=delete |
~EPCGenericRTDyldMemoryManager () | |
uint8_t * | allocateCodeSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) override |
Allocate a memory block of (at least) the given size suitable for executable code. | |
uint8_t * | allocateDataSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool IsReadOnly) override |
Allocate a memory block of (at least) the given size suitable for data. | |
void | reserveAllocationSpace (uintptr_t CodeSize, Align CodeAlign, uintptr_t RODataSize, Align RODataAlign, uintptr_t RWDataSize, Align RWDataAlign) override |
Inform the memory manager about the total amount of memory required to allocate all sections to be loaded: CodeSize - the total size of all code sections DataSizeRO - the total size of all read-only data sections DataSizeRW - the total size of all read-write data sections. | |
bool | needsToReserveAllocationSpace () override |
Override to return true to enable the reserveAllocationSpace callback. | |
void | registerEHFrames (uint8_t *Addr, uint64_t LoadAddr, size_t Size) override |
Register the EH frames with the runtime so that c++ exceptions work. | |
void | deregisterEHFrames () override |
void | notifyObjectLoaded (RuntimeDyld &Dyld, const object::ObjectFile &Obj) override |
This method is called after an object has been loaded into memory but before relocations are applied to the loaded sections. | |
bool | finalizeMemory (std::string *ErrMsg=nullptr) override |
This method is called when object loading is complete and section page permissions can be applied. | |
Public Member Functions inherited from llvm::RuntimeDyld::MemoryManager | |
MemoryManager ()=default | |
virtual | ~MemoryManager ()=default |
virtual uint8_t * | allocateCodeSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName)=0 |
Allocate a memory block of (at least) the given size suitable for executable code. | |
virtual uint8_t * | allocateDataSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool IsReadOnly)=0 |
Allocate a memory block of (at least) the given size suitable for data. | |
virtual TLSSection | allocateTLSSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) |
Allocate a memory block of (at least) the given size to be used for thread-local storage (TLS). | |
virtual void | reserveAllocationSpace (uintptr_t CodeSize, Align CodeAlign, uintptr_t RODataSize, Align RODataAlign, uintptr_t RWDataSize, Align RWDataAlign) |
Inform the memory manager about the total amount of memory required to allocate all sections to be loaded: CodeSize - the total size of all code sections DataSizeRO - the total size of all read-only data sections DataSizeRW - the total size of all read-write data sections. | |
virtual bool | needsToReserveAllocationSpace () |
Override to return true to enable the reserveAllocationSpace callback. | |
virtual bool | allowStubAllocation () const |
Override to return false to tell LLVM no stub space will be needed. | |
virtual void | registerEHFrames (uint8_t *Addr, uint64_t LoadAddr, size_t Size)=0 |
Register the EH frames with the runtime so that c++ exceptions work. | |
virtual void | deregisterEHFrames ()=0 |
virtual bool | finalizeMemory (std::string *ErrMsg=nullptr)=0 |
This method is called when object loading is complete and section page permissions can be applied. | |
virtual void | notifyObjectLoaded (RuntimeDyld &RTDyld, const object::ObjectFile &Obj) |
This method is called after an object has been loaded into memory but before relocations are applied to the loaded sections. | |
Static Public Member Functions | |
static Expected< std::unique_ptr< EPCGenericRTDyldMemoryManager > > | CreateWithDefaultBootstrapSymbols (ExecutorProcessControl &EPC) |
Create an EPCGenericRTDyldMemoryManager using the given EPC, looking up the default symbol names in the bootstrap symbol set. | |
Remote-mapped RuntimeDyld-compatible memory manager.
Definition at line 26 of file EPCGenericRTDyldMemoryManager.h.
llvm::orc::EPCGenericRTDyldMemoryManager::EPCGenericRTDyldMemoryManager | ( | ExecutorProcessControl & | EPC, |
SymbolAddrs | SAs | ||
) |
Create an EPCGenericRTDyldMemoryManager using the given EPC and symbol addrs.
Definition at line 38 of file EPCGenericRTDyldMemoryManager.cpp.
References llvm::dbgs(), and LLVM_DEBUG.
|
delete |
|
delete |
llvm::orc::EPCGenericRTDyldMemoryManager::~EPCGenericRTDyldMemoryManager | ( | ) |
Definition at line 44 of file EPCGenericRTDyldMemoryManager.cpp.
References llvm::orc::ExecutorProcessControl::callSPSWrapper(), llvm::dbgs(), llvm::errs(), llvm::orc::EPCGenericRTDyldMemoryManager::SymbolAddrs::Instance, LLVM_DEBUG, llvm::logAllUnhandledErrors(), llvm::orc::EPCGenericRTDyldMemoryManager::SymbolAddrs::Reserve, and llvm::Error::success().
|
overridevirtual |
Allocate a memory block of (at least) the given size suitable for executable code.
The SectionID is a unique identifier assigned by the RuntimeDyld instance, and optionally recorded by the memory manager to access a loaded section.
Implements llvm::RuntimeDyld::MemoryManager.
Definition at line 62 of file EPCGenericRTDyldMemoryManager.cpp.
References llvm::alignAddr(), llvm::dbgs(), llvm::formatv(), LLVM_DEBUG, and Size.
|
overridevirtual |
Allocate a memory block of (at least) the given size suitable for data.
The SectionID is a unique identifier assigned by the JIT engine, and optionally recorded by the memory manager to access a loaded section.
Implements llvm::RuntimeDyld::MemoryManager.
Definition at line 77 of file EPCGenericRTDyldMemoryManager.cpp.
References llvm::alignAddr(), llvm::dbgs(), llvm::formatv(), LLVM_DEBUG, and Size.
|
static |
Create an EPCGenericRTDyldMemoryManager using the given EPC, looking up the default symbol names in the bootstrap symbol set.
Definition at line 23 of file EPCGenericRTDyldMemoryManager.cpp.
References llvm::orc::ExecutorProcessControl::getBootstrapSymbols().
|
overridevirtual |
Implements llvm::RuntimeDyld::MemoryManager.
Definition at line 184 of file EPCGenericRTDyldMemoryManager.cpp.
|
overridevirtual |
This method is called when object loading is complete and section page permissions can be applied.
It is up to the memory manager implementation to decide whether or not to act on this method. The memory manager will typically allocate all sections as read-write and then apply specific permissions when this method is called. Code sections cannot be executed until this function has been called. In addition, any cache coherency operations needed to reliably use the memory are also performed.
Returns true if an error occurred, false otherwise.
Implements llvm::RuntimeDyld::MemoryManager.
Definition at line 204 of file EPCGenericRTDyldMemoryManager.cpp.
References llvm::orc::tpctypes::FinalizeRequest::Actions, llvm::alignAddr(), llvm::alignTo(), llvm::orc::ExecutorProcessControl::callSPSWrapper(), llvm::cantFail(), llvm::orc::shared::WrapperFunctionCall::Create(), llvm::dbgs(), llvm::orc::EPCGenericRTDyldMemoryManager::SymbolAddrs::DeregisterEHFrame, llvm::orc::Exec, llvm::orc::EPCGenericRTDyldMemoryManager::SymbolAddrs::Finalize, I, llvm::orc::EPCGenericRTDyldMemoryManager::SymbolAddrs::Instance, LLVM_DEBUG, llvm::orc::Read, llvm::orc::EPCGenericRTDyldMemoryManager::SymbolAddrs::RegisterEHFrame, llvm::orc::tpctypes::FinalizeRequest::Segments, llvm::orc::ExecutorAddrRange::Start, llvm::Error::success(), std::swap(), llvm::dwarf::toString(), and llvm::orc::Write.
|
overridevirtual |
Override to return true to enable the reserveAllocationSpace callback.
Reimplemented from llvm::RuntimeDyld::MemoryManager.
Definition at line 156 of file EPCGenericRTDyldMemoryManager.cpp.
|
overridevirtual |
This method is called after an object has been loaded into memory but before relocations are applied to the loaded sections.
Memory managers which are preparing code for execution in an external address space can use this call to remap the section addresses for the newly loaded object.
For clients that do not need access to an ExecutionEngine instance this method should be preferred to its cousin MCJITMemoryManager::notifyObjectLoaded as this method is compatible with ORC JIT stacks.
Reimplemented from llvm::RuntimeDyld::MemoryManager.
Definition at line 188 of file EPCGenericRTDyldMemoryManager.cpp.
References llvm::dbgs(), and LLVM_DEBUG.
|
delete |
|
delete |
|
overridevirtual |
Register the EH frames with the runtime so that c++ exceptions work.
Addr
parameter provides the local address of the EH frame section data, while LoadAddr
provides the address of the data in the target address space. If the section has not been remapped (which will usually be the case for local execution) these two values will be the same.
Implements llvm::RuntimeDyld::MemoryManager.
Definition at line 160 of file EPCGenericRTDyldMemoryManager.cpp.
References llvm::dbgs(), llvm::formatv(), LLVM_DEBUG, llvm::reverse(), and Size.
|
overridevirtual |
Inform the memory manager about the total amount of memory required to allocate all sections to be loaded: CodeSize
- the total size of all code sections DataSizeRO
- the total size of all read-only data sections DataSizeRW
- the total size of all read-write data sections.
Note that by default the callback is disabled. To enable it redefine the method needsToReserveAllocationSpace to return true.
Reimplemented from llvm::RuntimeDyld::MemoryManager.
Definition at line 96 of file EPCGenericRTDyldMemoryManager.cpp.
References llvm::alignTo(), llvm::orc::ExecutorProcessControl::callSPSWrapper(), llvm::dbgs(), llvm::formatv(), llvm::orc::ExecutorProcessControl::getPageSize(), llvm::orc::EPCGenericRTDyldMemoryManager::SymbolAddrs::Instance, LLVM_DEBUG, llvm::orc::EPCGenericRTDyldMemoryManager::SymbolAddrs::Reserve, and llvm::dwarf::toString().