LLVM API Documentation
#include <SectionMemoryManager.h>
Classes | |
struct | MemoryGroup |
Public Member Functions | |
SectionMemoryManager () | |
virtual | ~SectionMemoryManager () |
uint8_t * | allocateCodeSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) override |
Allocates 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 |
Allocates a memory block of (at least) the given size suitable for executable code. | |
bool | finalizeMemory (std::string *ErrMsg=nullptr) override |
Update section-specific memory permissions and other attributes. | |
virtual void | invalidateInstructionCache () |
Invalidate instruction cache for code sections. |
This is a simple memory manager which implements the methods called by the RuntimeDyld class to allocate memory for section-based loading of objects, usually those generated by the MCJIT execution engine.
This memory manager allocates all section memory as read-write. The RuntimeDyld will copy JITed section memory into these allocated blocks and perform any necessary linking and relocations.
Any client using this memory manager MUST ensure that section-specific page permissions have been applied before attempting to execute functions in the JITed object. Permissions can be applied either by calling MCJIT::finalizeObject or by calling SectionMemoryManager::finalizeMemory directly. Clients of MCJIT should call MCJIT::finalizeObject.
Definition at line 37 of file SectionMemoryManager.h.
llvm::SectionMemoryManager::SectionMemoryManager | ( | ) | [inline] |
Definition at line 42 of file SectionMemoryManager.h.
llvm::SectionMemoryManager::~SectionMemoryManager | ( | ) | [virtual] |
Definition at line 168 of file SectionMemoryManager.cpp.
References llvm::sys::Memory::releaseMappedMemory().
uint8_t * llvm::SectionMemoryManager::allocateCodeSection | ( | uintptr_t | Size, |
unsigned | Alignment, | ||
unsigned | SectionID, | ||
StringRef | SectionName | ||
) | [override, virtual] |
Allocates a memory block of (at least) the given size suitable for executable code.
The value of Alignment
must be a power of two. If Alignment
is zero a default alignment of 16 will be used.
Implements llvm::RTDyldMemoryManager.
Definition at line 31 of file SectionMemoryManager.cpp.
uint8_t * llvm::SectionMemoryManager::allocateDataSection | ( | uintptr_t | Size, |
unsigned | Alignment, | ||
unsigned | SectionID, | ||
StringRef | SectionName, | ||
bool | isReadOnly | ||
) | [override, virtual] |
Allocates a memory block of (at least) the given size suitable for executable code.
The value of Alignment
must be a power of two. If Alignment
is zero a default alignment of 16 will be used.
Implements llvm::RTDyldMemoryManager.
Definition at line 21 of file SectionMemoryManager.cpp.
bool llvm::SectionMemoryManager::finalizeMemory | ( | std::string * | ErrMsg = nullptr | ) | [override, virtual] |
Update section-specific memory permissions and other attributes.
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.
Implements llvm::RTDyldMemoryManager.
Definition at line 105 of file SectionMemoryManager.cpp.
References invalidateInstructionCache(), llvm::sys::Memory::MF_EXEC, and llvm::sys::Memory::MF_READ.
void llvm::SectionMemoryManager::invalidateInstructionCache | ( | ) | [virtual] |
Invalidate instruction cache for code sections.
Some platforms with separate data cache and instruction cache require explicit cache flush, otherwise JIT code manipulations (like resolved relocations) will get to the data cache but not to the instruction cache.
This method is called from finalizeMemory.
Definition at line 162 of file SectionMemoryManager.cpp.
References llvm::sys::Memory::InvalidateInstructionCache().
Referenced by finalizeMemory().