diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h index 83d85953fce691..69106fcb4c282d 100644 --- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h +++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h @@ -1377,7 +1377,7 @@ class LinkGraph { /// /// Accessing this object after finalization will result in undefined /// behavior. - JITLinkMemoryManager::AllocActions &allocActions() { return AAs; } + AllocActions &allocActions() { return AAs; } /// Dump the graph. void dump(raw_ostream &OS); @@ -1395,7 +1395,7 @@ class LinkGraph { SectionList Sections; ExternalSymbolSet ExternalSymbols; ExternalSymbolSet AbsoluteSymbols; - JITLinkMemoryManager::AllocActions AAs; + AllocActions AAs; }; inline MutableArrayRef Block::getMutableContent(LinkGraph &G) { diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h index 62c271dfc0b2e5..7dd382facde8aa 100644 --- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h +++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h @@ -33,52 +33,53 @@ class Block; class LinkGraph; class Section; +/// Represents a call to a graph-memory-management support function in the +/// executor. +/// +/// Support functions are called as: +/// +/// auto *Result = +/// ((char*(*)(const void*, size_t))FnAddr)( +/// (const void*)CtxAddr, (size_t)CtxSize) +/// +/// A null result is interpreted as success. +/// +/// A non-null result is interpreted as a heap-allocated string containing +/// an error message to report to the allocator (the allocator's +/// executor-side implementation code is responsible for freeing the error +/// string). +struct AllocActionCall { + JITTargetAddress FnAddr = 0; + JITTargetAddress CtxAddr = 0; + JITTargetAddress CtxSize = 0; +}; + +/// A pair of AllocActionCalls, one to be run at finalization time, one to be +/// run at deallocation time. +/// +/// AllocActionCallPairs should be constructed for paired operations (e.g. +/// __register_ehframe and __deregister_ehframe for eh-frame registration). +/// See comments for AllocActions for execution ordering. +/// +/// For unpaired operations one or the other member can be left unused, as +/// AllocationActionCalls with an FnAddr of zero will be skipped. +struct AllocActionCallPair { + AllocActionCall Finalize; + AllocActionCall Dealloc; +}; + +/// A vector of allocation actions to be run for this allocation. +/// +/// Finalize allocations will be run in order at finalize time. Dealloc +/// actions will be run in reverse order at deallocation time. +using AllocActions = std::vector; + /// Manages allocations of JIT memory. /// /// Instances of this class may be accessed concurrently from multiple threads /// and their implemetations should include any necessary synchronization. class JITLinkMemoryManager { public: - /// Represents a call to a graph-memory-management support function in the - /// executor. - /// - /// Support functions are called as: - /// - /// auto *Result = - /// ((char*(*)(const void*, size_t))FnAddr)( - /// (const void*)CtxAddr, (size_t)CtxSize) - /// - /// A null result is interpreted as success. - /// - /// A non-null result is interpreted as a heap-allocated string containing - /// an error message to report to the allocator (the allocator's - /// executor-side implementation code is responsible for freeing the error - /// string). - struct AllocActionCall { - JITTargetAddress FnAddr = 0; - JITTargetAddress CtxAddr = 0; - JITTargetAddress CtxSize = 0; - }; - - /// A pair of AllocActionCalls, one to be run at finalization time, one to be - /// run at deallocation time. - /// - /// AllocActionCallPairs should be constructed for paired operations (e.g. - /// __register_ehframe and __deregister_ehframe for eh-frame registration). - /// See comments for AllocActions for execution ordering. - /// - /// For unpaired operations one or the other member can be left unused, as - /// AllocationActionCalls with an FnAddr of zero will be skipped. - struct AllocActionCallPair { - AllocActionCall Finalize; - AllocActionCall Dealloc; - }; - - /// A vector of allocation actions to be run for this allocation. - /// - /// Finalize allocations will be run in order at finalize time. Dealloc - /// actions will be run in reverse order at deallocation time. - using AllocActions = std::vector; /// Represents a finalized allocation. /// @@ -312,7 +313,7 @@ class BasicLayout { /// Returns a reference to the AllocActions in the graph. /// This convenience function saves callers from having to #include /// LinkGraph.h if all they need are allocation actions. - JITLinkMemoryManager::AllocActions &graphAllocActions(); + AllocActions &graphAllocActions(); private: LinkGraph &G; diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp index 831b9b26d2fdee..67fe6287e38828 100644 --- a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp @@ -64,7 +64,7 @@ namespace jitlink { JITLinkMemoryManager::~JITLinkMemoryManager() = default; JITLinkMemoryManager::InFlightAlloc::~InFlightAlloc() = default; -static Error runAllocAction(JITLinkMemoryManager::AllocActionCall &C) { +static Error runAllocAction(AllocActionCall &C) { using WrapperFnTy = CWrapperFunctionResult (*)(const void *, size_t); auto *Fn = jitTargetAddressToPointer(C.FnAddr); @@ -189,9 +189,7 @@ Error BasicLayout::apply() { return Error::success(); } -JITLinkMemoryManager::AllocActions &BasicLayout::graphAllocActions() { - return G.allocActions(); -} +AllocActions &BasicLayout::graphAllocActions() { return G.allocActions(); } void SimpleSegmentAlloc::Create(JITLinkMemoryManager &MemMgr, const JITLinkDylib *JD, SegmentMap Segments,