LLVM 24.0.0git
EPCGenericJITLinkMemoryManager.h
Go to the documentation of this file.
1//===- EPCGenericJITLinkMemoryManager.h - EPC-based mem manager -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Implements JITLinkMemoryManager by calling executor-side wrapper functions
10// through Proxy objects.
11//
12// This simplifies the implementaton of new ExecutorProcessControl instances,
13// as this implementation will always work (at the cost of some performance
14// overhead for the calls).
15//
16// This header is protocol-agnostic. To build an instance that targets the ORC
17// runtime's SPS controller interface, see EPCGenericJITLinkMemoryManagerSPS.h.
18//
19//===----------------------------------------------------------------------===//
20
21#ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICJITLINKMEMORYMANAGER_H
22#define LLVM_EXECUTIONENGINE_ORC_EPCGENERICJITLINKMEMORYMANAGER_H
23
29
30#include <cstdint>
31
32namespace llvm {
33namespace orc {
34
37public:
38 /// Reserve an address range of the given size; returns its base.
40
41 /// Apply a finalize request; returns a key for the initialized allocation.
44
45 /// Deinitialize the allocations with the given base addresses (running their
46 /// deallocation actions) without releasing their memory.
48
49 /// Release the allocations with the given base addresses.
51
52 /// The resolved controller-side handle to an executor-side memory manager:
53 /// the address of the allocator instance (passed as the first argument to
54 /// each call) plus the proxies for its functions. These are
55 /// protocol-agnostic: sps::createEPCGenericJITLinkMemoryManager populates
56 /// them for the runtime's SPS controller interface, but a client targeting a
57 /// different protocol can build its own Bindings and pass them to the
58 /// constructor.
59 ///
60 /// Deinitialize is part of the interface but is not currently used by this
61 /// manager.
69
70 /// Create an EPCGenericJITLinkMemoryManager instance from a given set of
71 /// memory-manager bindings.
74
75 void allocate(const jitlink::JITLinkDylib *JD, jitlink::LinkGraph &G,
76 OnAllocatedFunction OnAllocated) override;
77
78 // Use overloads from base class.
79 using JITLinkMemoryManager::allocate;
80
81 void deallocate(std::vector<FinalizedAlloc> Allocs,
82 OnDeallocatedFunction OnDeallocated) override;
83
84 // Use overloads from base class.
85 using JITLinkMemoryManager::deallocate;
86
87private:
88 class InFlightAlloc;
89
90 void completeAllocation(ExecutorAddr AllocAddr, jitlink::BasicLayout BL,
91 OnAllocatedFunction OnAllocated);
92
94 Bindings B;
95};
96
97} // end namespace orc
98} // end namespace llvm
99
100#endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICJITLINKMEMORYMANAGER_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
#define G(x, y, z)
Definition MD5.cpp:55
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Proxy< Expected< ExecutorAddr >(ExecutorAddr, uint64_t)> ReserveProxy
Reserve an address range of the given size; returns its base.
EPCGenericJITLinkMemoryManager(ExecutionSession &ES, Bindings B)
Create an EPCGenericJITLinkMemoryManager instance from a given set of memory-manager bindings.
Proxy< Error(ExecutorAddr, ArrayRef< ExecutorAddr >)> DeinitializeProxy
Deinitialize the allocations with the given base addresses (running their deallocation actions) witho...
Proxy< Error(ExecutorAddr, ArrayRef< ExecutorAddr >)> ReleaseProxy
Release the allocations with the given base addresses.
Proxy< Expected< ExecutorAddr >(ExecutorAddr, tpctypes::FinalizeRequest)> InitializeProxy
Apply a finalize request; returns a key for the initialized allocation.
An ExecutionSession represents a running JIT program.
Definition Core.h:1111
Represents an address in the executor process.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
The resolved controller-side handle to an executor-side memory manager: the address of the allocator ...