File indexing completed on 2026-05-10 08:43:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORMEMORYMANAGER_H
0016 #define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORMEMORYMANAGER_H
0017
0018 #include "llvm/ADT/DenseMap.h"
0019 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
0020 #include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
0021 #include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
0022 #include "llvm/ExecutionEngine/Orc/TargetProcess/ExecutorBootstrapService.h"
0023 #include "llvm/Support/Error.h"
0024
0025 #include <mutex>
0026
0027 namespace llvm {
0028 namespace orc {
0029 namespace rt_bootstrap {
0030
0031
0032 class SimpleExecutorMemoryManager : public ExecutorBootstrapService {
0033 public:
0034 virtual ~SimpleExecutorMemoryManager();
0035
0036 Expected<ExecutorAddr> allocate(uint64_t Size);
0037 Error finalize(tpctypes::FinalizeRequest &FR);
0038 Error deallocate(const std::vector<ExecutorAddr> &Bases);
0039
0040 Error shutdown() override;
0041 void addBootstrapSymbols(StringMap<ExecutorAddr> &M) override;
0042
0043 private:
0044 struct Allocation {
0045 size_t Size = 0;
0046 std::vector<shared::WrapperFunctionCall> DeallocationActions;
0047 };
0048
0049 using AllocationsMap = DenseMap<void *, Allocation>;
0050
0051 Error deallocateImpl(void *Base, Allocation &A);
0052
0053 static llvm::orc::shared::CWrapperFunctionResult
0054 reserveWrapper(const char *ArgData, size_t ArgSize);
0055
0056 static llvm::orc::shared::CWrapperFunctionResult
0057 finalizeWrapper(const char *ArgData, size_t ArgSize);
0058
0059 static llvm::orc::shared::CWrapperFunctionResult
0060 deallocateWrapper(const char *ArgData, size_t ArgSize);
0061
0062 std::mutex M;
0063 AllocationsMap Allocations;
0064 };
0065
0066 }
0067 }
0068 }
0069
0070 #endif