LLVM  14.0.0git
Classes | Public Member Functions | Protected Attributes | Friends | List of all members
llvm::orc::ExecutorProcessControl Class Referenceabstract

ExecutorProcessControl supports interaction with a JIT target process. More...

#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"

Inheritance diagram for llvm::orc::ExecutorProcessControl:
Inheritance graph
[legend]
Collaboration diagram for llvm::orc::ExecutorProcessControl:
Collaboration graph
[legend]

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 ()
 
ExecutionSessiongetExecutionSession ()
 Return the ExecutionSession associated with this instance. More...
 
SymbolStringPtr intern (StringRef SymName)
 Intern a symbol name in the SymbolStringPool. More...
 
std::shared_ptr< SymbolStringPoolgetSymbolStringPool () const
 Return a shared pointer to the SymbolStringPool for this instance. More...
 
TaskDispatchergetDispatcher ()
 
const TriplegetTargetTriple () const
 Return the Triple for the target process. More...
 
unsigned getPageSize () const
 Get the page size for the target process. More...
 
const JITDispatchInfogetJITDispatchInfo () const
 Get the JIT dispatch function and context address for the executor. More...
 
MemoryAccessgetMemoryAccess () const
 Return a MemoryAccess object for the target process. More...
 
jitlink::JITLinkMemoryManagergetMemMgr () const
 Return a JITLinkMemoryManager for the target process. More...
 
const StringMap< ExecutorAddr > & getBootstrapSymbolsMap () const
 Returns the bootstrap symbol map. More...
 
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. More...
 
virtual Expected< tpctypes::DylibHandleloadDylib (const char *DylibPath)=0
 Load the dynamic library at the given path and return a handle to it. More...
 
virtual Expected< std::vector< tpctypes::LookupResult > > lookupSymbols (ArrayRef< LookupRequest > Request)=0
 Search for symbols in the target process. More...
 
virtual Expected< int32_t > runAsMain (ExecutorAddr MainFnAddr, ArrayRef< std::string > Args)=0
 Run function with a main-like signature. More...
 
virtual void callWrapperAsync (ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer)=0
 Run a wrapper function in the executor. More...
 
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. More...
 
template<typename FnT >
void callWrapperAsync (ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)
 Run a wrapper function in the executor. More...
 
shared::WrapperFunctionResult callWrapper (ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer)
 Run a wrapper function in the executor. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual Error disconnect ()=0
 Disconnect from the target process. More...
 

Protected Attributes

std::shared_ptr< SymbolStringPoolSSP
 
std::unique_ptr< TaskDispatcherD
 
ExecutionSessionES = nullptr
 
Triple TargetTriple
 
unsigned PageSize = 0
 
JITDispatchInfo JDI
 
MemoryAccessMemAccess = nullptr
 
jitlink::JITLinkMemoryManagerMemMgr = nullptr
 
StringMap< ExecutorAddrBootstrapSymbols
 

Friends

class ExecutionSession
 

Detailed Description

ExecutorProcessControl supports interaction with a JIT target process.

Definition at line 38 of file ExecutorProcessControl.h.

Constructor & Destructor Documentation

◆ ExecutorProcessControl()

llvm::orc::ExecutorProcessControl::ExecutorProcessControl ( std::shared_ptr< SymbolStringPool SSP,
std::unique_ptr< TaskDispatcher D 
)
inline

Definition at line 179 of file ExecutorProcessControl.h.

◆ ~ExecutorProcessControl()

llvm::orc::ExecutorProcessControl::~ExecutorProcessControl ( )
virtual

Definition at line 24 of file ExecutorProcessControl.cpp.

Member Function Documentation

◆ callSPSWrapper()

template<typename SPSSignature , typename... WrapperCallArgTs>
Error llvm::orc::ExecutorProcessControl::callSPSWrapper ( ExecutorAddr  WrapperFnAddr,
WrapperCallArgTs &&...  WrapperCallArgs 
)
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 342 of file ExecutorProcessControl.h.

References call(), and callWrapper().

◆ callSPSWrapperAsync() [1/2]

template<typename SPSSignature , typename SendResultT , typename... ArgTs>
void llvm::orc::ExecutorProcessControl::callSPSWrapperAsync ( ExecutorAddr  WrapperFnAddr,
SendResultT &&  SendResult,
const ArgTs &...  Args 
)
inline

Run a wrapper function using SPS to serialize the arguments and deserialize the results.

Definition at line 329 of file ExecutorProcessControl.h.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, and D.

◆ callSPSWrapperAsync() [2/2]

template<typename SPSSignature , typename RunPolicyT , typename SendResultT , typename... ArgTs>
void llvm::orc::ExecutorProcessControl::callSPSWrapperAsync ( RunPolicyT &&  Runner,
ExecutorAddr  WrapperFnAddr,
SendResultT &&  SendResult,
const ArgTs &...  Args 
)
inline

Run a wrapper function using SPS to serialize the arguments and deserialize the results.

Definition at line 314 of file ExecutorProcessControl.h.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, callWrapperAsync(), and move.

◆ callWrapper()

shared::WrapperFunctionResult llvm::orc::ExecutorProcessControl::callWrapper ( ExecutorAddr  WrapperFnAddr,
ArrayRef< char >  ArgBuffer 
)
inline

Run a wrapper function in the executor.

The wrapper function should be callable as:

CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);

{.cpp}

Definition at line 298 of file ExecutorProcessControl.h.

References callWrapperAsync(), move, and llvm::AArch64::RP.

Referenced by callSPSWrapper().

◆ callWrapperAsync() [1/3]

template<typename FnT >
void llvm::orc::ExecutorProcessControl::callWrapperAsync ( ExecutorAddr  WrapperFnAddr,
FnT &&  OnComplete,
ArrayRef< char >  ArgBuffer 
)
inline

Run a wrapper function in the executor.

OnComplete will be dispatched as a GenericNamedTask using this instance's TaskDispatch object.

Definition at line 286 of file ExecutorProcessControl.h.

References callWrapperAsync(), and D.

◆ callWrapperAsync() [2/3]

virtual void llvm::orc::ExecutorProcessControl::callWrapperAsync ( ExecutorAddr  WrapperFnAddr,
IncomingWFRHandler  OnComplete,
ArrayRef< char >  ArgBuffer 
)
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:

CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);

{.cpp}

Implemented in llvm::orc::SelfExecutorProcessControl, llvm::orc::UnsupportedExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.

Referenced by callSPSWrapperAsync(), callWrapper(), and callWrapperAsync().

◆ callWrapperAsync() [3/3]

template<typename RunPolicyT , typename FnT >
void llvm::orc::ExecutorProcessControl::callWrapperAsync ( RunPolicyT &&  Runner,
ExecutorAddr  WrapperFnAddr,
FnT &&  OnComplete,
ArrayRef< char >  ArgBuffer 
)
inline

Run a wrapper function in the executor using the given Runner to dispatch OnComplete when the result is ready.

Definition at line 277 of file ExecutorProcessControl.h.

References callWrapperAsync().

◆ disconnect()

virtual Error llvm::orc::ExecutorProcessControl::disconnect ( )
pure virtual

Disconnect from the target process.

This should be called after the JIT session is shut down.

Implemented in llvm::orc::SelfExecutorProcessControl, llvm::orc::UnsupportedExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.

◆ getBootstrapSymbols()

Error llvm::orc::ExecutorProcessControl::getBootstrapSymbols ( ArrayRef< std::pair< ExecutorAddr &, StringRef >>  Pairs) const
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 229 of file ExecutorProcessControl.h.

References BootstrapSymbols, I, llvm::inconvertibleErrorCode(), and llvm::Error::success().

◆ getBootstrapSymbolsMap()

const StringMap<ExecutorAddr>& llvm::orc::ExecutorProcessControl::getBootstrapSymbolsMap ( ) const
inline

Returns the bootstrap symbol map.

Definition at line 222 of file ExecutorProcessControl.h.

References BootstrapSymbols.

◆ getDispatcher()

TaskDispatcher& llvm::orc::ExecutorProcessControl::getDispatcher ( )
inline

Definition at line 198 of file ExecutorProcessControl.h.

References D.

◆ getExecutionSession()

ExecutionSession& llvm::orc::ExecutorProcessControl::getExecutionSession ( )
inline

Return the ExecutionSession associated with this instance.

Not callable until the ExecutionSession has been associated.

Definition at line 187 of file ExecutorProcessControl.h.

References assert(), and ES.

◆ getJITDispatchInfo()

const JITDispatchInfo& llvm::orc::ExecutorProcessControl::getJITDispatchInfo ( ) const
inline

Get the JIT dispatch function and context address for the executor.

Definition at line 207 of file ExecutorProcessControl.h.

References JDI.

◆ getMemMgr()

jitlink::JITLinkMemoryManager& llvm::orc::ExecutorProcessControl::getMemMgr ( ) const
inline

Return a JITLinkMemoryManager for the target process.

Definition at line 216 of file ExecutorProcessControl.h.

References assert(), and MemMgr.

◆ getMemoryAccess()

MemoryAccess& llvm::orc::ExecutorProcessControl::getMemoryAccess ( ) const
inline

Return a MemoryAccess object for the target process.

Definition at line 210 of file ExecutorProcessControl.h.

References assert(), and MemAccess.

◆ getPageSize()

unsigned llvm::orc::ExecutorProcessControl::getPageSize ( ) const
inline

Get the page size for the target process.

Definition at line 204 of file ExecutorProcessControl.h.

References PageSize.

Referenced by llvm::orc::EPCGenericRTDyldMemoryManager::reserveAllocationSpace().

◆ getSymbolStringPool()

std::shared_ptr<SymbolStringPool> llvm::orc::ExecutorProcessControl::getSymbolStringPool ( ) const
inline

Return a shared pointer to the SymbolStringPool for this instance.

Definition at line 196 of file ExecutorProcessControl.h.

References SSP.

◆ getTargetTriple()

const Triple& llvm::orc::ExecutorProcessControl::getTargetTriple ( ) const
inline

Return the Triple for the target process.

Definition at line 201 of file ExecutorProcessControl.h.

References TargetTriple.

Referenced by llvm::orc::EPCIndirectionUtils::Create().

◆ intern()

SymbolStringPtr llvm::orc::ExecutorProcessControl::intern ( StringRef  SymName)
inline

Intern a symbol name in the SymbolStringPool.

Definition at line 193 of file ExecutorProcessControl.h.

References SSP.

◆ loadDylib()

virtual Expected<tpctypes::DylibHandle> llvm::orc::ExecutorProcessControl::loadDylib ( const char *  DylibPath)
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::SelfExecutorProcessControl, llvm::orc::UnsupportedExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.

Referenced by llvm::orc::EPCEHFrameRegistrar::Create(), llvm::orc::createJITLoaderGDBRegistrar(), and llvm::orc::EPCDynamicLibrarySearchGenerator::Load().

◆ lookupSymbols()

virtual Expected<std::vector<tpctypes::LookupResult> > llvm::orc::ExecutorProcessControl::lookupSymbols ( ArrayRef< LookupRequest Request)
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::SelfExecutorProcessControl, llvm::orc::UnsupportedExecutorProcessControl, and llvm::orc::SimpleRemoteEPC.

Referenced by llvm::orc::lookupAndRecordAddrs(), and llvm::orc::EPCDynamicLibrarySearchGenerator::tryToGenerate().

◆ runAsMain()

virtual Expected<int32_t> llvm::orc::ExecutorProcessControl::runAsMain ( ExecutorAddr  MainFnAddr,
ArrayRef< std::string >  Args 
)
pure virtual

Friends And Related Function Documentation

◆ ExecutionSession

friend class ExecutionSession
friend

Definition at line 39 of file ExecutorProcessControl.h.

Member Data Documentation

◆ BootstrapSymbols

StringMap<ExecutorAddr> llvm::orc::ExecutorProcessControl::BootstrapSymbols
protected

Definition at line 366 of file ExecutorProcessControl.h.

Referenced by getBootstrapSymbols(), and getBootstrapSymbolsMap().

◆ D

std::unique_ptr<TaskDispatcher> llvm::orc::ExecutorProcessControl::D
protected

◆ ES

ExecutionSession* llvm::orc::ExecutorProcessControl::ES = nullptr
protected

Definition at line 360 of file ExecutorProcessControl.h.

Referenced by getExecutionSession().

◆ JDI

JITDispatchInfo llvm::orc::ExecutorProcessControl::JDI
protected

◆ MemAccess

MemoryAccess* llvm::orc::ExecutorProcessControl::MemAccess = nullptr
protected

◆ MemMgr

jitlink::JITLinkMemoryManager* llvm::orc::ExecutorProcessControl::MemMgr = nullptr
protected

◆ PageSize

unsigned llvm::orc::ExecutorProcessControl::PageSize = 0
protected

◆ SSP

std::shared_ptr<SymbolStringPool> llvm::orc::ExecutorProcessControl::SSP
protected

◆ TargetTriple

Triple llvm::orc::ExecutorProcessControl::TargetTriple
protected

The documentation for this class was generated from the following files:
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
uint64_t