//===-- JITLinkMemoryManager.h - JITLink mem manager interface --*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Contains the JITLinkMemoryManager interface. // //===----------------------------------------------------------------------===// #ifndef LLVM_EXECUTIONENGINE_JITLINK_JITLINKMEMORYMANAGER_H #define LLVM_EXECUTIONENGINE_JITLINK_JITLINKMEMORYMANAGER_H #include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ExecutionEngine/JITLink/JITLinkDylib.h" #include "llvm/ExecutionEngine/Orc/Shared/AllocationActions.h" #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h" #include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Error.h" #include "llvm/Support/MSVCErrorWorkarounds.h" #include "llvm/Support/Memory.h" #include "llvm/Support/RecyclingAllocator.h" #include <cassert> #include <cstdint> #include <future> #include <mutex> namespace llvm { namespace jitlink { class Block; class LinkGraph; class Section; /// 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 { … }; /// BasicLayout simplifies the implementation of JITLinkMemoryManagers. /// /// BasicLayout groups Sections into Segments based on their memory protection /// and deallocation policies. JITLinkMemoryManagers can construct a BasicLayout /// from a Graph, and then assign working memory and addresses to each of the /// Segments. These addreses will be mapped back onto the Graph blocks in /// the apply method. class BasicLayout { … }; /// A utility class for making simple allocations using JITLinkMemoryManager. /// /// SimpleSegementAlloc takes a mapping of AllocGroups to Segments and uses /// this to create a LinkGraph with one Section (containing one Block) per /// Segment. Clients can obtain a pointer to the working memory and executor /// address of that block using the Segment's AllocGroup. Once memory has been /// populated, clients can call finalize to finalize the memory. /// /// Note: Segments with MemLifetime::NoAlloc are not permitted, since they would /// not be useful, and their presence is likely to indicate a bug. class SimpleSegmentAlloc { … }; /// A JITLinkMemoryManager that allocates in-process memory. class InProcessMemoryManager : public JITLinkMemoryManager { … }; } // end namespace jitlink } // end namespace llvm #endif // LLVM_EXECUTIONENGINE_JITLINK_JITLINKMEMORYMANAGER_H