Go to the documentation of this file.
31 SegInfo() : WorkingMem(nullptr), ContentSize(0), ZeroFillSize(0) {}
43 : Parent(Parent),
G(
G), AllocAddr(AllocAddr), Segs(
std::
move(Segs)) {}
47 for (
auto &KV : Segs) {
53 alignTo(KV.second.ContentSize + KV.second.ZeroFillSize,
54 Parent.EPC.getPageSize()),
55 {KV.second.WorkingMem,
static_cast<size_t>(KV.second.ContentSize)}});
61 Parent.EPC.callSPSWrapperAsync<
64 [OnFinalize =
std::move(OnFinalize), AllocAddr = this->AllocAddr](
65 Error SerializationErr,
Error FinalizeErr)
mutable {
67 if (SerializationErr) {
70 }
else if (FinalizeErr)
80 Parent.EPC.callSPSWrapperAsync<
82 Parent.SAs.Deallocate,
84 Error DeallocateErr)
mutable {
85 if (SerializationErr) {
106 auto Pages =
BL.getContiguousPageBasedLayoutSizes(EPC.getPageSize());
108 return OnAllocated(Pages.takeError());
114 if (SerializationErr) {
116 return OnAllocated(
std::move(SerializationErr));
119 return OnAllocated(AllocAddr.takeError());
123 SAs.Allocator, Pages->total());
126 void EPCGenericJITLinkMemoryManager::deallocate(
128 EPC.callSPSWrapperAsync<
132 Error DeallocErr)
mutable {
139 SAs.Allocator, Allocs);
140 for (
auto &A : Allocs)
144 void EPCGenericJITLinkMemoryManager::completeAllocation(
147 InFlightAlloc::SegInfoMap SegInfos;
150 for (
auto &KV :
BL.segments()) {
151 const auto &AG = KV.first;
152 auto &Seg = KV.second;
154 Seg.Addr = NextSegAddr;
155 KV.second.WorkingMem =
BL.getGraph().allocateBuffer(Seg.ContentSize).data();
157 alignTo(Seg.ContentSize + Seg.ZeroFillSize, EPC.getPageSize()));
159 auto &SegInfo = SegInfos[AG];
160 SegInfo.ContentSize = Seg.ContentSize;
161 SegInfo.ZeroFillSize = Seg.ZeroFillSize;
163 SegInfo.WorkingMem = Seg.WorkingMem;
166 if (
auto Err =
BL.apply())
169 OnAllocated(std::make_unique<InFlightAlloc>(*
this,
BL.getGraph(), AllocAddr,
Represents an address in the executor process.
WireProtectionFlags toWireProtectionFlags(sys::Memory::ProtectionFlags PF)
Convert from sys::Memory::ProtectionFlags.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
This is an optimization pass for GlobalISel generic memory operations.
unique_function is a type-erasing functor similar to std::function.
shared::SPSError(shared::SPSExecutorAddr, shared::SPSFinalizeRequest) SPSSimpleExecutorMemoryManagerFinalizeSignature
Tagged union holding either a T or a Error.
shared::AllocActions Actions
shared::SPSExpected< shared::SPSExecutorAddr >(shared::SPSExecutorAddr, uint64_t) SPSSimpleExecutorMemoryManagerReserveSignature
uint64_t ExecutorAddrDiff
BasicLayout simplifies the implementation of JITLinkMemoryManagers.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
std::vector< SegFinalizeRequest > Segments
sys::Memory::ProtectionFlags toSysMemoryProtectionFlags(MemProt MP)
Convert a MemProt value to a corresponding sys::Memory::ProtectionFlags value.
void abandon(OnAbandonedFunction OnAbandoned) override
Called prior to finalization if the allocation should be abandoned.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Represents an allocation which has not been finalized yet.
Represents a finalized allocation.
Lightweight error class with error context and mandatory checking.
void finalize(OnFinalizedFunction OnFinalize) override
Called to transfer working memory to the target and apply finalization.
Align max(MaybeAlign Lhs, Align Rhs)
InFlightAlloc(EPCGenericJITLinkMemoryManager &Parent, LinkGraph &G, ExecutorAddr AllocAddr, SegInfoMap Segs)
shared::SPSError(shared::SPSExecutorAddr, shared::SPSSequence< shared::SPSExecutorAddr >) SPSSimpleExecutorMemoryManagerDeallocateSignature