LLVM 24.0.0git
llvm::orc::SelfExecutorProcessControl Class Reference

A ExecutorProcessControl implementation targeting the current process. More...

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

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

Classes

class  InProcessDylibManager

Public Member Functions

 SelfExecutorProcessControl (std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D, Triple TargetTriple, unsigned PageSize)
Expected< int32_t > runAsMain (ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
 Run function with a main-like 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 ()
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 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< SelfExecutorProcessControl > > Create (std::shared_ptr< SymbolStringPool > SSP=nullptr, std::unique_ptr< TaskDispatcher > D=nullptr)
 Create a SelfExecutorProcessControl with the given symbol string pool and memory manager.

Additional Inherited Members

Protected Attributes inherited from llvm::orc::ExecutorProcessControl
std::shared_ptr< SymbolStringPool > SSP
std::unique_ptr< TaskDispatcher > D
ExecutionSession * ES = nullptr
Triple TargetTriple
unsigned PageSize = 0
StringMap< std::vector< char > > BootstrapMap
StringMap< ExecutorAddr > BootstrapSymbols

Detailed Description

A ExecutorProcessControl implementation targeting the current process.

Definition at line 24 of file SelfExecutorProcessControl.h.

Constructor & Destructor Documentation

◆ SelfExecutorProcessControl()

Member Function Documentation

◆ callWrapperAsync()

void llvm::orc::SelfExecutorProcessControl::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:

CWrapperFunctionBuffer fn(uint8_t *Data, uint64_t Size);
unsigned uint64_t

{.cpp}

Implements llvm::orc::ExecutorProcessControl.

Definition at line 93 of file SelfExecutorProcessControl.cpp.

References llvm::Data, llvm::ArrayRef< T >::data(), Size, llvm::ArrayRef< T >::size(), and llvm::orc::ExecutorAddr::toPtr().

◆ Create()

Expected< std::unique_ptr< SelfExecutorProcessControl > > llvm::orc::SelfExecutorProcessControl::Create ( std::shared_ptr< SymbolStringPool > SSP = nullptr,
std::unique_ptr< TaskDispatcher > D = nullptr )
static

Create a SelfExecutorProcessControl with the given symbol string pool and memory manager.

If no symbol string pool is given then one will be created. If no memory manager is given a jitlink::InProcessMemoryManager will be created and used by default.

Definition at line 67 of file SelfExecutorProcessControl.cpp.

References llvm::orc::ExecutorProcessControl::D, llvm::sys::Process::getPageSize(), llvm::sys::getProcessTriple(), llvm::orc::ExecutorProcessControl::PageSize, and llvm::orc::ExecutorProcessControl::SSP.

Referenced by llvm::orc::LLJIT::LLJIT(), and llvm::orc::LLJITBuilderState::prepareForConstruction().

◆ createDefaultDylibMgr()

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

Create a default DylibManager for the target process.

Implements llvm::orc::ExecutorProcessControl.

Definition at line 115 of file SelfExecutorProcessControl.cpp.

References llvm::orc::ExecutorProcessControl::TargetTriple.

◆ createDefaultMemoryAccess()

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

Create a default MemoryAccess for the target process.

Implements llvm::orc::ExecutorProcessControl.

Definition at line 121 of file SelfExecutorProcessControl.cpp.

References llvm::orc::ExecutorProcessControl::TargetTriple.

◆ createDefaultMemoryManager()

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

Create a default JITLinkMemoryManager for the target process.

Implements llvm::orc::ExecutorProcessControl.

Definition at line 109 of file SelfExecutorProcessControl.cpp.

References llvm::sys::Process::getPageSizeEstimate().

◆ disconnect()

Error llvm::orc::SelfExecutorProcessControl::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 103 of file SelfExecutorProcessControl.cpp.

References llvm::orc::ExecutorProcessControl::D, and llvm::Error::success().

◆ runAsMain()

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

Run function with a main-like signature.

Implements llvm::orc::ExecutorProcessControl.

Definition at line 87 of file SelfExecutorProcessControl.cpp.

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


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