LLVM 23.0.0git
llvm::orc::InProcessEPC Class Reference

An ExecutorProcessControl implementation for in-process JITs that use the new ORC runtime (llvm-project/orc-rt). More...

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

Inheritance diagram for llvm::orc::InProcessEPC:
[legend]

Classes

struct  BootstrapInfoAccess
 Provides access to bootstrap info. More...
struct  Connection
 Pseudo-connection C struct. More...

Public Member Functions

 ~InProcessEPC ()
Expected< int32_t > runAsMain (ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
 Run function with a main-like signature.
Expected< int32_t > runAsVoidFunction (ExecutorAddr VoidFnAddr) override
 Run function with a int (*)(void) signature.
Expected< int32_t > runAsIntFunction (ExecutorAddr IntFnAddr, int Arg) override
 Run function with a int (*)(int) signature.
void callWrapperAsync (ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) override
 Run a wrapper function in the executor.
Expected< std::unique_ptr< jitlink::JITLinkMemoryManager > > createDefaultMemoryManager () override
 Create a default JITLinkMemoryManager for the target process.
Expected< std::unique_ptr< DylibManager > > createDefaultDylibMgr () override
 Create a default DylibManager for the target process.
Expected< std::unique_ptr< MemoryAccess > > createDefaultMemoryAccess () override
 Create a default MemoryAccess for the target process.
Error disconnect () override
 Disconnect from the target process.
Public Member Functions inherited from llvm::orc::ExecutorProcessControl
 ExecutorProcessControl (std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D)
virtual ~ExecutorProcessControl ()
ExecutionSessiongetExecutionSession ()
 Return the ExecutionSession associated with this instance.
SymbolStringPtr intern (StringRef SymName)
 Intern a symbol name in the SymbolStringPool.
std::shared_ptr< SymbolStringPoolgetSymbolStringPool () const
 Return a shared pointer to the SymbolStringPool for this instance.
TaskDispatchergetDispatcher ()
const TriplegetTargetTriple () const
 Return the Triple for the target process.
unsigned getPageSize () const
 Get the page size for the target process.
const JITDispatchInfogetJITDispatchInfo () const
 Get the JIT dispatch function and context address for the executor.
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.
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::WrapperFunctionBuffer 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.

Static Public Member Functions

static Expected< std::unique_ptr< InProcessEPC > > Create (Connection *C, BootstrapInfoAccess *BIA, std::shared_ptr< SymbolStringPool > SSP=nullptr, std::unique_ptr< TaskDispatcher > D=nullptr)
 Create a new InProcessEPC.

Additional Inherited Members

Protected Attributes inherited from llvm::orc::ExecutorProcessControl
std::shared_ptr< SymbolStringPoolSSP
std::unique_ptr< TaskDispatcherD
ExecutionSessionES = nullptr
Triple TargetTriple
unsigned PageSize = 0
JITDispatchInfo JDI
StringMap< std::vector< char > > BootstrapMap
StringMap< ExecutorAddrBootstrapSymbols

Detailed Description

An ExecutorProcessControl implementation for in-process JITs that use the new ORC runtime (llvm-project/orc-rt).

This class communicates with the runtime's InProcessControllerAccess via direct function calls through a virtual connection object.

Definition at line 34 of file InProcessEPC.h.

Constructor & Destructor Documentation

◆ ~InProcessEPC()

llvm::orc::InProcessEPC::~InProcessEPC ( )

Definition at line 115 of file InProcessEPC.cpp.

References llvm::orc::ExecutorProcessControl::D.

Member Function Documentation

◆ callWrapperAsync()

void llvm::orc::InProcessEPC::callWrapperAsync ( ExecutorAddr WrapperFnAddr,
IncomingWFRHandler OnComplete,
ArrayRef< char > ArgBuffer )
overridevirtual

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}

Implements llvm::orc::ExecutorProcessControl.

Definition at line 148 of file InProcessEPC.cpp.

References llvm::orc::shared::WrapperFunctionBuffer::copyFrom(), llvm::orc::shared::WrapperFunctionBuffer::createOutOfBandError(), llvm::ArrayRef< T >::data(), llvm::dbgs(), LLVM_DEBUG, llvm::ArrayRef< T >::size(), and llvm::orc::ExecutorAddr::toPtr().

◆ Create()

◆ createDefaultDylibMgr()

Expected< std::unique_ptr< DylibManager > > llvm::orc::InProcessEPC::createDefaultDylibMgr ( )
overridevirtual

◆ createDefaultMemoryAccess()

Expected< std::unique_ptr< MemoryAccess > > llvm::orc::InProcessEPC::createDefaultMemoryAccess ( )
overridevirtual

◆ createDefaultMemoryManager()

Expected< std::unique_ptr< jitlink::JITLinkMemoryManager > > llvm::orc::InProcessEPC::createDefaultMemoryManager ( )
overridevirtual

Create a default JITLinkMemoryManager for the target process.

Implements llvm::orc::ExecutorProcessControl.

Definition at line 168 of file InProcessEPC.cpp.

References llvm::orc::EPCGenericJITLinkMemoryManager::Create(), and llvm::orc::ExecutorProcessControl::getExecutionSession().

◆ disconnect()

Error llvm::orc::InProcessEPC::disconnect ( )
overridevirtual

Disconnect from the target process.

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

Implements llvm::orc::ExecutorProcessControl.

Definition at line 203 of file InProcessEPC.cpp.

References llvm::Error::success().

◆ runAsIntFunction()

Expected< int32_t > llvm::orc::InProcessEPC::runAsIntFunction ( ExecutorAddr IntFnAddr,
int Arg )
overridevirtual

Run function with a int (*)(int) signature.

Implements llvm::orc::ExecutorProcessControl.

Definition at line 142 of file InProcessEPC.cpp.

References llvm::orc::runAsIntFunction(), and llvm::orc::ExecutorAddr::toPtr().

◆ runAsMain()

Expected< int32_t > llvm::orc::InProcessEPC::runAsMain ( ExecutorAddr MainFnAddr,
ArrayRef< std::string > Args )
overridevirtual

Run function with a main-like signature.

Implements llvm::orc::ExecutorProcessControl.

Definition at line 131 of file InProcessEPC.cpp.

References llvm::orc::runAsMain(), and llvm::orc::ExecutorAddr::toPtr().

◆ runAsVoidFunction()

Expected< int32_t > llvm::orc::InProcessEPC::runAsVoidFunction ( ExecutorAddr VoidFnAddr)
overridevirtual

Run function with a int (*)(void) signature.

Implements llvm::orc::ExecutorProcessControl.

Definition at line 137 of file InProcessEPC.cpp.

References llvm::orc::runAsVoidFunction(), and llvm::orc::ExecutorAddr::toPtr().


The documentation for this class was generated from the following files: