[JITLink] Move AllocActions and associated types out of JITLinkMemoryManager.
authorLang Hames <lhames@gmail.com>
Mon, 3 Jan 2022 03:33:23 +0000 (14:33 +1100)
committerLang Hames <lhames@gmail.com>
Mon, 3 Jan 2022 03:37:18 +0000 (14:37 +1100)
They're shared with LinkGraph, so having them as top-level types makes sense,
and saves users from qualifying the names everywhere.

llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp

index 83d8595..69106fc 100644 (file)
@@ -1377,7 +1377,7 @@ public:
   ///
   /// 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 @@ private:
   SectionList Sections;
   ExternalSymbolSet ExternalSymbols;
   ExternalSymbolSet AbsoluteSymbols;
-  JITLinkMemoryManager::AllocActions AAs;
+  AllocActions AAs;
 };
 
 inline MutableArrayRef<char> Block::getMutableContent(LinkGraph &G) {
index 62c271d..7dd382f 100644 (file)
@@ -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<AllocActionCallPair>;
+
 /// 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<AllocActionCallPair>;
 
   /// Represents a finalized allocation.
   ///
@@ -312,7 +313,7 @@ public:
   /// 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;
index 831b9b2..67fe628 100644 (file)
@@ -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<WrapperFnTy>(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,