14#ifndef LLVM_EXECUTIONENGINE_SECTIONMEMORYMANAGER_H
15#define LLVM_EXECUTIONENGINE_SECTIONMEMORYMANAGER_H
23#include <system_error>
76 unsigned Flags, std::error_code &EC) = 0;
122 void reserveAllocationSpace(uintptr_t
CodeSize,
Align CodeAlign,
123 uintptr_t RODataSize,
Align RODataAlign,
124 uintptr_t RWDataSize,
Align RWDataAlign)
override;
131 uint8_t *allocateCodeSection(uintptr_t
Size,
unsigned Alignment,
140 uint8_t *allocateDataSection(uintptr_t
Size,
unsigned Alignment,
142 bool isReadOnly)
override;
155 bool finalizeMemory(std::string *ErrMsg =
nullptr)
override;
164 virtual void invalidateInstructionCache();
167 struct FreeMemBlock {
174 unsigned PendingPrefixIndex;
182 SmallVector<sys::MemoryBlock, 16> PendingMem;
183 SmallVector<FreeMemBlock, 16> FreeMem;
186 SmallVector<sys::MemoryBlock, 16> AllocatedMem;
188 sys::MemoryBlock Near;
191 uint8_t *allocateSection(AllocationPurpose Purpose, uintptr_t
Size,
194 std::error_code applyMemoryGroupPermissions(MemoryGroup &MemGroup,
195 unsigned Permissions);
197 bool hasSpace(
const MemoryGroup &MemGroup, uintptr_t
Size)
const;
199 void anchor()
override;
202 MemoryGroup RWDataMem;
203 MemoryGroup RODataMem;
204 MemoryMapper *MMapper;
205 std::unique_ptr<MemoryMapper> OwnedMMapper;
206 bool ReserveAllocation;
This file defines the SmallVector class.
RTDyldMemoryManager()=default
Implementations of this interface are used by SectionMemoryManager to request pages from the operatin...
virtual std::error_code protectMappedMemory(const sys::MemoryBlock &Block, unsigned Flags)=0
This method sets the protection flags for a block of memory to the state specified by Flags.
virtual std::error_code releaseMappedMemory(sys::MemoryBlock &M)=0
This method releases a block of memory that was allocated with the allocateMappedMemory method.
virtual sys::MemoryBlock allocateMappedMemory(AllocationPurpose Purpose, size_t NumBytes, const sys::MemoryBlock *const NearBlock, unsigned Flags, std::error_code &EC)=0
This method attempts to allocate NumBytes bytes of virtual memory for Purpose.
AllocationPurpose
This enum describes the various reasons to allocate pages from allocateMappedMemory.
void operator=(const SectionMemoryManager &)=delete
SectionMemoryManager(MemoryMapper *MM=nullptr, bool ReserveAlloc=false)
Creates a SectionMemoryManager instance with MM as the associated memory mapper.
SectionMemoryManager(const SectionMemoryManager &)=delete
bool needsToReserveAllocationSpace() override
Enable reserveAllocationSpace when requested.
StringRef - Represent a constant reference to a string, i.e.
This class encapsulates the notion of a memory block which has an address and a size.
This is an optimization pass for GlobalISel generic memory operations.
This struct is a compact representation of a valid (non-zero power of two) alignment.