Go to the documentation of this file.
14 #ifndef LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H
15 #define LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H
26 class ExecutorProcessControl;
38 ABISupport(
unsigned PointerSize,
unsigned TrampolineSize,
unsigned StubSize,
39 unsigned StubToPointerMaxDisplacement,
unsigned ResolverCodeSize)
40 : PointerSize(PointerSize), TrampolineSize(TrampolineSize),
42 StubToPointerMaxDisplacement(StubToPointerMaxDisplacement),
43 ResolverCodeSize(ResolverCodeSize) {}
52 return StubToPointerMaxDisplacement;
64 unsigned NumTrampolines)
const = 0;
70 unsigned NumStubs)
const = 0;
73 unsigned PointerSize = 0;
74 unsigned TrampolineSize = 0;
75 unsigned StubSize = 0;
76 unsigned StubToPointerMaxDisplacement = 0;
77 unsigned ResolverCodeSize = 0;
81 template <
typename ORCABI>
82 static std::unique_ptr<EPCIndirectionUtils>
124 assert(LCTM &&
"createLazyCallThroughManager must be called first");
131 struct IndirectStubInfo {
132 IndirectStubInfo() =
default;
135 : StubAddress(StubAddress), PointerAddress(PointerAddress) {}
140 using IndirectStubInfoVector = std::vector<IndirectStubInfo>;
143 EPCIndirectionUtils(ExecutorProcessControl &EPC,
144 std::unique_ptr<ABISupport> ABI);
146 Expected<IndirectStubInfoVector> getIndirectStubs(
unsigned NumStubs);
148 std::mutex EPCUIMutex;
149 ExecutorProcessControl &EPC;
150 std::unique_ptr<ABISupport> ABI;
152 FinalizedAlloc ResolverBlock;
153 std::unique_ptr<TrampolinePool> TP;
154 std::unique_ptr<LazyCallThroughManager> LCTM;
156 std::vector<IndirectStubInfo> AvailableIndirectStubs;
157 std::vector<FinalizedAlloc> IndirectStubAllocs;
175 template <
typename ORCABI>
179 :
ABISupport(ORCABI::PointerSize, ORCABI::TrampolineSize,
180 ORCABI::StubSize, ORCABI::StubToPointerMaxDisplacement,
181 ORCABI::ResolverCodeSize) {}
187 ORCABI::writeResolverCode(ResolverWorkingMem, ResolverTargetAddr,
188 ReentryFnAddr, ReentryCtxAddr);
194 unsigned NumTrampolines)
const override {
195 ORCABI::writeTrampolines(TrampolineBlockWorkingMem,
196 TrampolineBlockTargetAddr, ResolverAddr,
203 unsigned NumStubs)
const override {
204 ORCABI::writeIndirectStubsBlock(StubsBlockWorkingMem,
205 StubsBlockTargetAddress,
206 PointersBlockTargetAddress, NumStubs);
212 template <
typename ORCABI>
213 std::unique_ptr<EPCIndirectionUtils>
222 #endif // LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H
Error cleanup()
Release memory for resources held by this instance.
This is an optimization pass for GlobalISel generic memory operations.
ABISupport(unsigned PointerSize, unsigned TrampolineSize, unsigned StubSize, unsigned StubToPointerMaxDisplacement, unsigned ResolverCodeSize)
std::unique_ptr< IndirectStubsManager > createIndirectStubsManager()
Create an IndirectStubsManager for the executor process.
Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU)
This will call writeResolver on the given EPCIndirectionUtils instance to set up re-entry via a funct...
Manages a set of 'lazy call-through' trampolines.
ExecutorProcessControl supports interaction with a JIT target process.
LazyCallThroughManager & getLazyCallThroughManager()
Create a LazyCallThroughManager for the executor process.
Tagged union holding either a T or a Error.
ExecutorProcessControl & getExecutorProcessControl() const
Return a reference to the ExecutorProcessControl object.
void writeIndirectStubsBlock(char *StubsBlockWorkingMem, JITTargetAddress StubsBlockTargetAddress, JITTargetAddress PointersBlockTargetAddress, unsigned NumStubs) const override
unsigned getResolverCodeSize() const
Base class for pools of compiler re-entry trampolines.
virtual void writeTrampolines(char *TrampolineBlockWorkingMem, JITTargetAddress TrampolineBlockTragetAddr, JITTargetAddress ResolverAddr, unsigned NumTrampolines) const =0
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
TrampolinePool & getTrampolinePool()
Create a TrampolinePool for the executor process.
ABISupport & getABISupport() const
Return a reference to the ABISupport object for this instance.
virtual void writeIndirectStubsBlock(char *StubsBlockWorkingMem, JITTargetAddress StubsBlockTargetAddress, JITTargetAddress PointersBlockTargetAddress, unsigned NumStubs) const =0
void writeResolverCode(char *ResolverWorkingMem, JITTargetAddress ResolverTargetAddr, JITTargetAddress ReentryFnAddr, JITTargetAddress ReentryCtxAddr) const override
Expected< JITTargetAddress > writeResolverBlock(JITTargetAddress ReentryFnAddr, JITTargetAddress ReentryCtxAddr)
Write resolver code to the executor process and return its address.
JITTargetAddress getResolverBlockAddress() const
Returns the address of the Resolver block.
unsigned getTrampolineSize() const
static std::unique_ptr< EPCIndirectionUtils > CreateWithABI(ExecutorProcessControl &EPC)
Create using the given ABI class.
static Expected< std::unique_ptr< EPCIndirectionUtils > > Create(ExecutorProcessControl &EPC)
Create based on the ExecutorProcessControl triple.
Represents a finalized allocation.
Lightweight error class with error context and mandatory checking.
An ExecutionSession represents a running JIT program.
uint64_t JITTargetAddress
Represents an address in the target process's address space.
LazyCallThroughManager & createLazyCallThroughManager(ExecutionSession &ES, JITTargetAddress ErrorHandlerAddr)
Create a LazyCallThroughManager.
unsigned getStubToPointerMaxDisplacement() const
virtual void writeResolverCode(char *ResolverWorkingMem, JITTargetAddress ResolverTargetAddr, JITTargetAddress ReentryFnAddr, JITTargetAddress ReentryCtxAddr) const =0
Provides ExecutorProcessControl based indirect stubs, trampoline pool and lazy call through manager.
void writeTrampolines(char *TrampolineBlockWorkingMem, JITTargetAddress TrampolineBlockTargetAddr, JITTargetAddress ResolverAddr, unsigned NumTrampolines) const override
unsigned getPointerSize() const
unsigned getStubSize() const