LLVM 17.0.0git
|
ExecutorProcessControl supports interaction with a JIT target process. More...
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
Classes | |
class | IncomingWFRHandler |
A handler or incoming WrapperFunctionResults – either return values from callWrapper* calls, or incoming JIT-dispatch requests. More... | |
struct | JITDispatchInfo |
Contains the address of the dispatch function and context that the ORC runtime can use to call functions in the JIT. More... | |
struct | LookupRequest |
A pair of a dylib and a set of symbols to be looked up. More... | |
class | MemoryAccess |
APIs for manipulating memory in the target process. More... | |
class | RunAsTask |
Constructs an IncomingWFRHandler from a function object by creating a new function object that dispatches the original using a TaskDispatcher, wrapping the original as a GenericNamedTask. More... | |
class | RunInPlace |
Constructs an IncomingWFRHandler from a function object that is callable as void(shared::WrapperFunctionResult). More... | |
Public Member Functions | |
ExecutorProcessControl (std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D) | |
virtual | ~ExecutorProcessControl () |
ExecutionSession & | getExecutionSession () |
Return the ExecutionSession associated with this instance. | |
SymbolStringPtr | intern (StringRef SymName) |
Intern a symbol name in the SymbolStringPool. | |
std::shared_ptr< SymbolStringPool > | getSymbolStringPool () const |
Return a shared pointer to the SymbolStringPool for this instance. | |
TaskDispatcher & | getDispatcher () |
const Triple & | getTargetTriple () const |
Return the Triple for the target process. | |
unsigned | getPageSize () const |
Get the page size for the target process. | |
const JITDispatchInfo & | getJITDispatchInfo () const |
Get the JIT dispatch function and context address for the executor. | |
MemoryAccess & | getMemoryAccess () const |
Return a MemoryAccess object for the target process. | |
jitlink::JITLinkMemoryManager & | getMemMgr () const |
Return a JITLinkMemoryManager for the target process. | |
const StringMap< std::vector< char > > & | getBootstrapMap () const |
Returns the bootstrap map. | |
template<typename T , typename SPSTagT > | |
Error | getBootstrapMapValue (StringRef Key, std::optional< T > &Val) const |
Look up and SPS-deserialize a bootstrap map value. | |
const StringMap< ExecutorAddr > & | getBootstrapSymbolsMap () const |
Returns the bootstrap symbol map. | |
Error | getBootstrapSymbols (ArrayRef< std::pair< ExecutorAddr &, StringRef > > Pairs) const |
For each (ExecutorAddr&, StringRef) pair, looks up the string in the bootstrap symbols map and writes its address to the ExecutorAddr if found. | |
virtual Expected< tpctypes::DylibHandle > | loadDylib (const char *DylibPath)=0 |
Load the dynamic library at the given path and return a handle to it. | |
virtual Expected< std::vector< tpctypes::LookupResult > > | lookupSymbols (ArrayRef< LookupRequest > Request)=0 |
Search for symbols in the target process. | |
virtual Expected< int32_t > | runAsMain (ExecutorAddr MainFnAddr, ArrayRef< std::string > Args)=0 |
Run function with a main-like signature. | |
virtual Expected< int32_t > | runAsVoidFunction (ExecutorAddr VoidFnAddr)=0 |
Run function with a int (*)(void) signature. | |
virtual Expected< int32_t > | runAsIntFunction (ExecutorAddr IntFnAddr, int Arg)=0 |
Run function with a int (*)(int) signature. | |
virtual void | callWrapperAsync (ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer)=0 |
Run a wrapper function in the executor. | |
template<typename RunPolicyT , typename FnT > | |
void | callWrapperAsync (RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer) |
Run a wrapper function in the executor using the given Runner to dispatch OnComplete when the result is ready. | |
template<typename FnT > | |
void | callWrapperAsync (ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer) |
Run a wrapper function in the executor. | |
shared::WrapperFunctionResult | callWrapper (ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer) |
Run a wrapper function in the executor. | |
template<typename SPSSignature , typename RunPolicyT , typename SendResultT , typename... ArgTs> | |
void | callSPSWrapperAsync (RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args) |
Run a wrapper function using SPS to serialize the arguments and deserialize the results. | |
template<typename SPSSignature , typename SendResultT , typename... ArgTs> | |
void | callSPSWrapperAsync (ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args) |
Run a wrapper function using SPS to serialize the arguments and deserialize the results. | |
template<typename SPSSignature , typename... WrapperCallArgTs> | |
Error | callSPSWrapper (ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs) |
Run a wrapper function using SPS to serialize the arguments and deserialize the results. | |
virtual Error | disconnect ()=0 |
Disconnect from the target process. | |
Protected Attributes | |
std::shared_ptr< SymbolStringPool > | SSP |
std::unique_ptr< TaskDispatcher > | D |
ExecutionSession * | ES = nullptr |
Triple | TargetTriple |
unsigned | PageSize = 0 |
JITDispatchInfo | JDI |
MemoryAccess * | MemAccess = nullptr |
jitlink::JITLinkMemoryManager * | MemMgr = nullptr |
StringMap< std::vector< char > > | BootstrapMap |
StringMap< ExecutorAddr > | BootstrapSymbols |
Friends | |
class | ExecutionSession |
ExecutorProcessControl supports interaction with a JIT target process.
Definition at line 38 of file ExecutorProcessControl.h.
|
inline |
Definition at line 179 of file ExecutorProcessControl.h.
|
virtualdefault |
|
inline |
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
If SPSSignature is a non-void function signature then the second argument (the first in the Args list) should be a reference to a return value.
Definition at line 378 of file ExecutorProcessControl.h.
References callWrapper().
Referenced by llvm::orc::EPCGenericRTDyldMemoryManager::finalizeMemory(), llvm::orc::EPCGenericRTDyldMemoryManager::reserveAllocationSpace(), and llvm::orc::EPCGenericRTDyldMemoryManager::~EPCGenericRTDyldMemoryManager().
|
inline |
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition at line 365 of file ExecutorProcessControl.h.
References D.
|
inline |
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition at line 350 of file ExecutorProcessControl.h.
References callWrapperAsync().
Referenced by llvm::orc::EPCGenericJITLinkMemoryManager::InFlightAlloc::abandon(), llvm::orc::EPCGenericJITLinkMemoryManager::allocate(), llvm::orc::EPCGenericJITLinkMemoryManager::deallocate(), llvm::orc::SharedMemoryMapper::deinitialize(), llvm::orc::EPCGenericJITLinkMemoryManager::InFlightAlloc::finalize(), llvm::orc::SharedMemoryMapper::initialize(), llvm::orc::SharedMemoryMapper::release(), llvm::orc::SharedMemoryMapper::reserve(), llvm::orc::EPCGenericMemoryAccess::writeBuffersAsync(), llvm::orc::EPCGenericMemoryAccess::writeUInt16sAsync(), llvm::orc::EPCGenericMemoryAccess::writeUInt32sAsync(), llvm::orc::EPCGenericMemoryAccess::writeUInt64sAsync(), and llvm::orc::EPCGenericMemoryAccess::writeUInt8sAsync().
|
inline |
Run a wrapper function in the executor.
The wrapper function should be callable as:
{.cpp}
Definition at line 334 of file ExecutorProcessControl.h.
References callWrapperAsync().
Referenced by callSPSWrapper().
|
inline |
Run a wrapper function in the executor.
OnComplete will be dispatched as a GenericNamedTask using this instance's TaskDispatch object.
Definition at line 322 of file ExecutorProcessControl.h.
References callWrapperAsync(), and D.
|
pure virtual |
Run a wrapper function in the executor.
The given WFRHandler will be called on the result when it is returned.
The wrapper function should be callable as:
{.cpp}
Implemented in llvm::orc::UnsupportedExecutorProcessControl, llvm::orc::SelfExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.
Referenced by callSPSWrapperAsync(), callWrapper(), and callWrapperAsync().
|
inline |
Run a wrapper function in the executor using the given Runner to dispatch OnComplete when the result is ready.
Definition at line 313 of file ExecutorProcessControl.h.
References callWrapperAsync().
|
pure virtual |
Disconnect from the target process.
This should be called after the JIT session is shut down.
Implemented in llvm::orc::UnsupportedExecutorProcessControl, llvm::orc::SelfExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.
|
inline |
Returns the bootstrap map.
Definition at line 222 of file ExecutorProcessControl.h.
References BootstrapMap.
|
inline |
Look up and SPS-deserialize a bootstrap map value.
Definition at line 230 of file ExecutorProcessControl.h.
References BootstrapMap, llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::StringMap< ValueTy, AllocatorTy >::find(), I, llvm::inconvertibleErrorCode(), and llvm::Error::success().
|
inline |
For each (ExecutorAddr&, StringRef) pair, looks up the string in the bootstrap symbols map and writes its address to the ExecutorAddr if found.
If any symbol is not found then the function returns an error.
Definition at line 256 of file ExecutorProcessControl.h.
References BootstrapSymbols, I, llvm::inconvertibleErrorCode(), and llvm::Error::success().
Referenced by llvm::orc::EPCGenericDylibManager::CreateWithDefaultBootstrapSymbols(), and llvm::orc::EPCGenericRTDyldMemoryManager::CreateWithDefaultBootstrapSymbols().
|
inline |
Returns the bootstrap symbol map.
Definition at line 249 of file ExecutorProcessControl.h.
References BootstrapSymbols.
|
inline |
Definition at line 198 of file ExecutorProcessControl.h.
References D.
|
inline |
Return the ExecutionSession associated with this instance.
Not callable until the ExecutionSession has been associated.
Definition at line 187 of file ExecutorProcessControl.h.
Referenced by llvm::orc::SimpleRemoteEPC::callWrapperAsync().
|
inline |
Get the JIT dispatch function and context address for the executor.
Definition at line 207 of file ExecutorProcessControl.h.
References JDI.
|
inline |
Return a JITLinkMemoryManager for the target process.
Definition at line 216 of file ExecutorProcessControl.h.
|
inline |
Return a MemoryAccess object for the target process.
Definition at line 210 of file ExecutorProcessControl.h.
|
inline |
Get the page size for the target process.
Definition at line 204 of file ExecutorProcessControl.h.
References PageSize.
Referenced by llvm::orc::EPCGenericJITLinkMemoryManager::allocate(), llvm::orc::EPCGenericJITLinkMemoryManager::InFlightAlloc::finalize(), and llvm::orc::EPCGenericRTDyldMemoryManager::reserveAllocationSpace().
|
inline |
Return a shared pointer to the SymbolStringPool for this instance.
Definition at line 196 of file ExecutorProcessControl.h.
References SSP.
Return the Triple for the target process.
Definition at line 201 of file ExecutorProcessControl.h.
References TargetTriple.
Referenced by llvm::orc::EPCIndirectionUtils::Create().
|
inline |
Intern a symbol name in the SymbolStringPool.
Definition at line 193 of file ExecutorProcessControl.h.
References SSP.
|
pure virtual |
Load the dynamic library at the given path and return a handle to it.
If LibraryPath is null this function will return the global handle for the target process.
Implemented in llvm::orc::UnsupportedExecutorProcessControl, llvm::orc::SelfExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.
Referenced by llvm::orc::EPCDynamicLibrarySearchGenerator::Load().
|
pure virtual |
Search for symbols in the target process.
The result of the lookup is a 2-dimentional array of target addresses that correspond to the lookup order. If a required symbol is not found then this method will return an error. If a weakly referenced symbol is not found then it be assigned a '0' value.
Implemented in llvm::orc::UnsupportedExecutorProcessControl, llvm::orc::SelfExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.
Referenced by llvm::orc::lookupAndRecordAddrs(), and llvm::orc::EPCDynamicLibrarySearchGenerator::tryToGenerate().
|
pure virtual |
Run function with a int (*)(int) signature.
Implemented in llvm::orc::UnsupportedExecutorProcessControl, llvm::orc::SelfExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.
Referenced by llvm::orc::COFFVCRuntimeBootstrapper::initializeStaticVCRuntime().
|
pure virtual |
Run function with a main-like signature.
Implemented in llvm::orc::UnsupportedExecutorProcessControl, llvm::orc::SelfExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.
|
pure virtual |
Run function with a int (*)(void) signature.
Implemented in llvm::orc::UnsupportedExecutorProcessControl, llvm::orc::SelfExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.
Referenced by llvm::orc::COFFVCRuntimeBootstrapper::initializeStaticVCRuntime().
|
friend |
Definition at line 39 of file ExecutorProcessControl.h.
Definition at line 402 of file ExecutorProcessControl.h.
Referenced by getBootstrapMap(), and getBootstrapMapValue().
|
protected |
Definition at line 403 of file ExecutorProcessControl.h.
Referenced by getBootstrapSymbols(), and getBootstrapSymbolsMap().
|
protected |
Definition at line 395 of file ExecutorProcessControl.h.
Referenced by callSPSWrapperAsync(), callWrapperAsync(), llvm::orc::SelfExecutorProcessControl::Create(), llvm::orc::SimpleRemoteEPC::Create(), llvm::orc::SelfExecutorProcessControl::disconnect(), llvm::orc::SimpleRemoteEPC::disconnect(), and getDispatcher().
|
protected |
Definition at line 396 of file ExecutorProcessControl.h.
Referenced by getExecutionSession().
|
protected |
Definition at line 399 of file ExecutorProcessControl.h.
Referenced by getJITDispatchInfo(), and llvm::orc::SelfExecutorProcessControl::SelfExecutorProcessControl().
|
protected |
Definition at line 400 of file ExecutorProcessControl.h.
Referenced by getMemoryAccess(), and llvm::orc::SelfExecutorProcessControl::SelfExecutorProcessControl().
|
protected |
Definition at line 401 of file ExecutorProcessControl.h.
Referenced by llvm::orc::SelfExecutorProcessControl::Create(), getMemMgr(), and llvm::orc::SelfExecutorProcessControl::SelfExecutorProcessControl().
|
protected |
|
protected |
Definition at line 394 of file ExecutorProcessControl.h.
Referenced by llvm::orc::SelfExecutorProcessControl::Create(), getSymbolStringPool(), intern(), and llvm::orc::SelfExecutorProcessControl::lookupSymbols().
|
protected |
Definition at line 397 of file ExecutorProcessControl.h.
Referenced by getTargetTriple(), llvm::orc::SelfExecutorProcessControl::SelfExecutorProcessControl(), and llvm::orc::UnsupportedExecutorProcessControl::UnsupportedExecutorProcessControl().