43 : Parent(Parent),
G(
G), AllocAddr(AllocAddr), Segs(
std::
move(Segs)) {}
47 for (
auto &KV : Segs) {
48 assert(KV.second.ContentSize <= std::numeric_limits<size_t>::max());
52 alignTo(KV.second.ContentSize + KV.second.ZeroFillSize,
54 {KV.second.WorkingMem,
static_cast<size_t>(KV.second.ContentSize)}});
63 [OnFinalize = std::move(OnFinalize), AllocAddr = this->AllocAddr](
64 Error SerializationErr,
Error FinalizeErr)
mutable {
66 if (SerializationErr) {
68 OnFinalize(std::move(SerializationErr));
69 }
else if (FinalizeErr)
70 OnFinalize(std::move(FinalizeErr));
82 [OnAbandoned = std::move(OnAbandoned)](
Error SerializationErr,
83 Error DeallocateErr)
mutable {
84 if (SerializationErr) {
86 OnAbandoned(std::move(SerializationErr));
88 OnAbandoned(std::move(DeallocateErr));
105 auto Pages = BL.getContiguousPageBasedLayoutSizes(EPC.
getPageSize());
107 return OnAllocated(Pages.takeError());
111 [
this, BL = std::move(BL), OnAllocated = std::move(OnAllocated)](
113 if (SerializationErr) {
115 return OnAllocated(std::move(SerializationErr));
118 return OnAllocated(AllocAddr.takeError());
120 completeAllocation(*AllocAddr, std::move(BL), std::move(OnAllocated));
130 [OnDeallocated = std::move(OnDeallocated)](
Error SerErr,
131 Error DeallocErr)
mutable {
134 OnDeallocated(std::move(SerErr));
136 OnDeallocated(std::move(DeallocErr));
139 for (
auto &
A : Allocs)
143void EPCGenericJITLinkMemoryManager::completeAllocation(
149 for (
auto &KV : BL.segments()) {
150 const auto &AG = KV.first;
151 auto &Seg = KV.second;
153 Seg.Addr = NextSegAddr;
154 KV.second.WorkingMem = BL.getGraph().allocateBuffer(Seg.ContentSize).data();
158 auto &SegInfo = SegInfos[AG];
159 SegInfo.ContentSize = Seg.ContentSize;
160 SegInfo.ZeroFillSize = Seg.ZeroFillSize;
161 SegInfo.Addr = Seg.Addr;
162 SegInfo.WorkingMem = Seg.WorkingMem;
165 if (
auto Err = BL.apply())
166 return OnAllocated(std::move(Err));
168 OnAllocated(std::make_unique<InFlightAlloc>(*
this, BL.getGraph(), AllocAddr,
169 std::move(SegInfos)));
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
BasicLayout simplifies the implementation of JITLinkMemoryManagers.
Represents a finalized allocation.
Represents an allocation which has not been finalized yet.
orc::shared::AllocActions & allocActions()
Accessor for the AllocActions object for this graph.
void finalize(OnFinalizedFunction OnFinalize) override
Called to transfer working memory to the target and apply finalization.
void abandon(OnAbandonedFunction OnAbandoned) override
Called prior to finalization if the allocation should be abandoned.
InFlightAlloc(EPCGenericJITLinkMemoryManager &Parent, LinkGraph &G, ExecutorAddr AllocAddr, SegInfoMap Segs)
AllocGroupSmallMap< SegInfo > SegInfoMap
void deallocate(std::vector< FinalizedAlloc > Allocs, OnDeallocatedFunction OnDeallocated) override
Deallocate a list of allocation objects.
void allocate(const jitlink::JITLinkDylib *JD, jitlink::LinkGraph &G, OnAllocatedFunction OnAllocated) override
Start the allocation process.
Represents an address in the executor process.
void callSPSWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
unsigned getPageSize() const
Get the page size for the target process.
unique_function is a type-erasing functor similar to std::function.
shared::SPSExpected< shared::SPSExecutorAddr >(shared::SPSExecutorAddr, uint64_t) SPSSimpleExecutorMemoryManagerReserveSignature
shared::SPSError(shared::SPSExecutorAddr, shared::SPSFinalizeRequest) SPSSimpleExecutorMemoryManagerFinalizeSignature
shared::SPSError(shared::SPSExecutorAddr, shared::SPSSequence< shared::SPSExecutorAddr >) SPSSimpleExecutorMemoryManagerDeallocateSignature
uint64_t ExecutorAddrDiff
This is an optimization pass for GlobalISel generic memory operations.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
std::vector< SegFinalizeRequest > Segments
shared::AllocActions Actions