PostgreSQL Source Code git master
|
#include <SectionMemoryManager.h>
Data Structures | |
struct | FreeMemBlock |
struct | MemoryGroup |
class | MemoryMapper |
Public Types | |
enum class | AllocationPurpose { Code , ROData , RWData } |
Public Member Functions | |
SectionMemoryManager (MemoryMapper *MM=nullptr, bool ReserveAlloc=false) | |
SectionMemoryManager (const SectionMemoryManager &)=delete | |
void | operator= (const SectionMemoryManager &)=delete |
~SectionMemoryManager () override | |
bool | needsToReserveAllocationSpace () override |
Enable reserveAllocationSpace when requested. More... | |
virtual void | reserveAllocationSpace (uintptr_t CodeSize, uint32_t CodeAlign, uintptr_t RODataSize, uint32_t RODataAlign, uintptr_t RWDataSize, uint32_t RWDataAlign) override |
uint8_t * | allocateCodeSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) override |
uint8_t * | allocateDataSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool IsReadOnly) override |
bool | finalizeMemory (std::string *ErrMsg=nullptr) override |
virtual void | invalidateInstructionCache () |
Private Member Functions | |
uint8_t * | allocateSection (AllocationPurpose Purpose, uintptr_t Size, unsigned Alignment) |
std::error_code | applyMemoryGroupPermissions (MemoryGroup &MemGroup, unsigned Permissions) |
bool | hasSpace (const MemoryGroup &MemGroup, uintptr_t Size) const |
void | anchor () override |
Private Attributes | |
MemoryGroup | CodeMem |
MemoryGroup | RWDataMem |
MemoryGroup | RODataMem |
MemoryMapper * | MMapper |
std::unique_ptr< MemoryMapper > | OwnedMMapper |
bool | ReserveAllocation |
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 46 of file SectionMemoryManager.h.
|
strong |
This enum describes the various reasons to allocate pages from allocateMappedMemory.
Enumerator | |
---|---|
Code | |
ROData | |
RWData |
Definition at line 50 of file SectionMemoryManager.h.
llvm::backport::SectionMemoryManager::SectionMemoryManager | ( | MemoryMapper * | MM = nullptr , |
bool | ReserveAlloc = false |
||
) |
Creates a SectionMemoryManager instance with MM
as the associated memory mapper. If MM
is nullptr then a default memory mapper is used that directly calls into the operating system.
If ReserveAlloc
is true all memory will be pre-allocated, and any attempts to allocate beyond pre-allocated memory will fail.
|
delete |
|
override |
|
override |
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.
|
override |
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.
|
private |
|
overrideprivate |
|
private |
|
override |
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.
|
private |
|
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.
|
inlineoverride |
Enable reserveAllocationSpace when requested.
Definition at line 123 of file SectionMemoryManager.h.
References ReserveAllocation.
|
delete |
|
overridevirtual |
Implements allocating all memory in a single block. This is required to limit memory offsets to fit the ARM ABI; large memory systems may otherwise allocate separate sections too far apart.
|
private |
Definition at line 215 of file SectionMemoryManager.h.
|
private |
Definition at line 218 of file SectionMemoryManager.h.
|
private |
Definition at line 219 of file SectionMemoryManager.h.
|
private |
Definition at line 220 of file SectionMemoryManager.h.
Referenced by needsToReserveAllocationSpace().
|
private |
Definition at line 217 of file SectionMemoryManager.h.
|
private |
Definition at line 216 of file SectionMemoryManager.h.