LLVM: llvm::orc::ExecutionSession Class Reference (original) (raw)
An ExecutionSession represents a running JIT program. More...
#include "[llvm/ExecutionEngine/Orc/Core.h](llvm%5F2ExecutionEngine%5F2Orc%5F2Core%5F8h%5Fsource.html)"
| Public Types | |
|---|---|
| using | ErrorReporter = unique_function<void(Error)> |
| For reporting errors. | |
| using | SendResultFunction = unique_function<void(shared::WrapperFunctionResult)> |
| Send a result to the remote. | |
| using | JITDispatchHandlerFunction |
| An asynchronous wrapper-function callable from the executor via jit-dispatch. | |
| using | JITDispatchHandlerAssociationMap |
| A map associating tag names with asynchronous wrapper function implementations in the JIT. |
| Public Member Functions | |
|---|---|
| LLVM_ABI | ExecutionSession (std::unique_ptr< ExecutorProcessControl > EPC) |
| Construct an ExecutionSession with the given ExecutorProcessControl object. | |
| LLVM_ABI | ~ExecutionSession () |
| Destroy an ExecutionSession. | |
| LLVM_ABI Error | endSession () |
| End the session. | |
| ExecutorProcessControl & | getExecutorProcessControl () |
| Get the ExecutorProcessControl object associated with this ExecutionSession. | |
| const Triple & | getTargetTriple () const |
| Return the triple for the executor. | |
| size_t | getPageSize () const |
| std::shared_ptr< SymbolStringPool > | getSymbolStringPool () |
| Get the SymbolStringPool for this instance. | |
| SymbolStringPtr | intern (StringRef SymName) |
| Add a symbol name to the SymbolStringPool and return a pointer to it. | |
| void | setPlatform (std::unique_ptr< Platform > P) |
| Set the Platform for this ExecutionSession. | |
| Platform * | getPlatform () |
| Get the Platform for this session. | |
| template | |
| decltype(auto) | runSessionLocked (Func &&F) |
| Run the given lambda with the session mutex locked. | |
| LLVM_ABI void | registerResourceManager (ResourceManager &RM) |
| Register the given ResourceManager with this ExecutionSession. | |
| LLVM_ABI void | deregisterResourceManager (ResourceManager &RM) |
| Deregister the given ResourceManager with this ExecutionSession. | |
| LLVM_ABI JITDylib * | getJITDylibByName (StringRef Name) |
| Return a pointer to the "name" JITDylib. | |
| LLVM_ABI JITDylib & | createBareJITDylib (std::string Name) |
| Add a new bare JITDylib to this ExecutionSession. | |
| LLVM_ABI Expected< JITDylib & > | createJITDylib (std::string Name) |
| Add a new JITDylib to this ExecutionSession. | |
| LLVM_ABI Error | removeJITDylibs (std::vector< JITDylibSP > JDsToRemove) |
| Removes the given JITDylibs from the ExecutionSession. | |
| Error | removeJITDylib (JITDylib &JD) |
| Calls removeJTIDylibs on the gives JITDylib. | |
| ExecutionSession & | setErrorReporter (ErrorReporter ReportError) |
| Set the error reporter function. | |
| void | reportError (Error Err) |
| Report a error for this execution session. | |
| LLVM_ABI void | lookupFlags (LookupKind K, JITDylibSearchOrder SearchOrder, SymbolLookupSet Symbols, unique_function< void(Expected< SymbolFlagsMap >)> OnComplete) |
| Search the given JITDylibs to find the flags associated with each of the given symbols. | |
| LLVM_ABI Expected< SymbolFlagsMap > | lookupFlags (LookupKind K, JITDylibSearchOrder SearchOrder, SymbolLookupSet Symbols) |
| Blocking version of lookupFlags. | |
| LLVM_ABI void | lookup (LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies) |
| Search the given JITDylibs for the given symbols. | |
| LLVM_ABI Expected< SymbolMap > | lookup (const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, LookupKind K=LookupKind::Static, SymbolState RequiredState=SymbolState::Ready, RegisterDependenciesFunction RegisterDependencies=NoDependenciesToRegister) |
| Blocking version of lookup above. | |
| LLVM_ABI Expected< ExecutorSymbolDef > | lookup (const JITDylibSearchOrder &SearchOrder, SymbolStringPtr Symbol, SymbolState RequiredState=SymbolState::Ready) |
| Convenience version of blocking lookup. | |
| LLVM_ABI Expected< ExecutorSymbolDef > | lookup (ArrayRef< JITDylib * > SearchOrder, SymbolStringPtr Symbol, SymbolState RequiredState=SymbolState::Ready) |
| Convenience version of blocking lookup. | |
| LLVM_ABI Expected< ExecutorSymbolDef > | lookup (ArrayRef< JITDylib * > SearchOrder, StringRef Symbol, SymbolState RequiredState=SymbolState::Ready) |
| Convenience version of blocking lookup. | |
| void | dispatchTask (std::unique_ptr< Task > T) |
| Materialize the given unit. | |
| 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. | |
| void | callWrapperAsync (ExecutorAddr WrapperFnAddr, ExecutorProcessControl::IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) |
| 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 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. | |
| LLVM_ABI Error | registerJITDispatchHandlers (JITDylib &JD, JITDispatchHandlerAssociationMap WFs) |
| For each tag symbol name, associate the corresponding AsyncHandlerWrapperFunction with the address of that symbol. | |
| LLVM_ABI void | runJITDispatchHandler (SendResultFunction SendResult, ExecutorAddr HandlerFnTagAddr, ArrayRef< char > ArgBuffer) |
| Run a registered jit-side wrapper function. | |
| LLVM_ABI void | dump (raw_ostream &OS) |
| Dump the state of all the JITDylibs in this session. |
| Static Public Member Functions | |
|---|---|
| template<typename SPSSignature, typename HandlerT> | |
| static JITDispatchHandlerFunction | wrapAsyncWithSPS (HandlerT &&H) |
| Wrap a handler that takes concrete argument types (and a sender for a concrete return type) to produce an AsyncHandlerWrapperFunction. | |
| template<typename SPSSignature, typename ClassT, typename... MethodArgTs> | |
| static JITDispatchHandlerFunction | wrapAsyncWithSPS (ClassT *Instance, void(ClassT::*Method)(MethodArgTs...)) |
| Wrap a class method that takes concrete argument types (and a sender for a concrete return type) to produce an AsyncHandlerWrapperFunction. |
| Friends | |
|---|---|
| class | InProgressLookupFlagsState |
| class | InProgressFullLookupState |
| class | JITDylib |
| class | LookupState |
| class | MaterializationResponsibility |
| class | ResourceTracker |
An ExecutionSession represents a running JIT program.
Definition at line 1342 of file Core.h.
◆ ErrorReporter
For reporting errors.
Definition at line 1352 of file Core.h.
◆ JITDispatchHandlerAssociationMap
Initial value:
A map associating tag names with asynchronous wrapper function implementations in the JIT.
Definition at line 1365 of file Core.h.
◆ JITDispatchHandlerFunction
Initial value:
SendResultFunction SendResult,
const char *ArgData, size_t ArgSize)>
unique_function< void(shared::WrapperFunctionResult)> SendResultFunction
Send a result to the remote.
unique_function is a type-erasing functor similar to std::function.
An asynchronous wrapper-function callable from the executor via jit-dispatch.
Definition at line 1359 of file Core.h.
◆ SendResultFunction
Send a result to the remote.
Definition at line 1355 of file Core.h.
◆ ~ExecutionSession()
| llvm::orc::ExecutionSession::~ExecutionSession | ( | ) |
|---|
◆ callSPSWrapper()
template<typename SPSSignature, typename... WrapperCallArgTs>
| Error llvm::orc::ExecutionSession::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 1639 of file Core.h.
◆ callSPSWrapperAsync()
template<typename SPSSignature, typename SendResultT, typename... ArgTs>
| void llvm::orc::ExecutionSession::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 1627 of file Core.h.
◆ callWrapper()
Run a wrapper function in the executor.
The wrapper function should be callable as:
FunctionAddr VTableAddr uintptr_t uintptr_t Data
{.cpp}
Definition at line 1619 of file Core.h.
◆ callWrapperAsync() [1/3]
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}
Definition at line 1589 of file Core.h.
◆ callWrapperAsync() [2/3]
template<typename FnT>
| void llvm::orc::ExecutionSession::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 1607 of file Core.h.
◆ callWrapperAsync() [3/3]
template<typename RunPolicyT, typename FnT>
| void llvm::orc::ExecutionSession::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 1598 of file Core.h.
◆ createBareJITDylib()
| JITDylib & llvm::orc::ExecutionSession::createBareJITDylib | ( | std::string | Name | ) |
|---|
◆ createJITDylib()
| Expected< JITDylib & > llvm::orc::ExecutionSession::createJITDylib | ( | std::string | Name | ) |
|---|
◆ deregisterResourceManager()
| void llvm::orc::ExecutionSession::deregisterResourceManager | ( | ResourceManager & | RM | ) |
|---|
◆ dispatchTask()
| void llvm::orc::ExecutionSession::dispatchTask ( std::unique_ptr< Task > T) | inline |
|---|
◆ dump()
| void llvm::orc::ExecutionSession::dump | ( | raw_ostream & | OS | ) |
|---|
◆ endSession()
| Error llvm::orc::ExecutionSession::endSession | ( | ) |
|---|
◆ getBootstrapMap()
| const StringMap< std::vector< char > > & llvm::orc::ExecutionSession::getBootstrapMap ( ) const | inline |
|---|
Returns the bootstrap map.
Definition at line 1558 of file Core.h.
◆ getBootstrapMapValue()
template<typename T, typename SPSTagT>
| Error llvm::orc::ExecutionSession::getBootstrapMapValue ( StringRef Key, std::optional< T > & Val ) const | inline |
|---|
◆ getBootstrapSymbols()
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 1576 of file Core.h.
◆ getBootstrapSymbolsMap()
Returns the bootstrap symbol map.
Definition at line 1569 of file Core.h.
◆ getExecutorProcessControl()
◆ getJITDylibByName()
◆ getPageSize()
| size_t llvm::orc::ExecutionSession::getPageSize ( ) const | inline |
|---|
◆ getPlatform()
| Platform * llvm::orc::ExecutionSession::getPlatform ( ) | inline |
|---|
◆ getSymbolStringPool()
| std::shared_ptr< SymbolStringPool > llvm::orc::ExecutionSession::getSymbolStringPool ( ) | inline |
|---|
◆ getTargetTriple()
| const Triple & llvm::orc::ExecutionSession::getTargetTriple ( ) const | inline |
|---|
◆ intern()
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition at line 1396 of file Core.h.
Referenced by llvm::orc::addAliases(), llvm::orc::addInitSymbol(), llvm::orc::GDBJITDebugInfoRegistrationPlugin::Create(), llvm::orc::getCOFFObjectFileSymbolInfo(), llvm::orc::getDylibInterfaceFromDylib(), llvm::orc::getDylibInterfaceFromTapiFile(), llvm::orc::getELFObjectFileSymbolInfo(), llvm::orc::getGenericObjectFileSymbolInfo(), llvm::orc::getMachOObjectFileSymbolInfo(), llvm::orc::getXCOFFObjectFileSymbolInfo(), llvm::orc::IRMaterializationUnit::IRMaterializationUnit(), and lookup().
◆ lookup() [1/5]
Convenience version of blocking lookup.
Searches each of the JITDylibs in the search order in turn for the given symbol. The search will not find non-exported symbols.
Definition at line 1856 of file Core.cpp.
References intern(), and lookup().
◆ lookup() [2/5]
◆ lookup() [3/5]
Blocking version of lookup above.
Returns the resolved symbol map. If WaitUntilReady is true (the default), will not return until all requested symbols are ready (or an error occurs). If WaitUntilReady is false, will return as soon as all requested symbols are resolved, or an error occurs. If WaitUntilReady is false and an error occurs after resolution, the function will return a success value, but the error will be reported via reportErrors.
Definition at line 1796 of file Core.cpp.
References _, lookup(), llvm::orc::Result, and llvm::Error::success().
◆ lookup() [4/5]
◆ lookup() [5/5]
Search the given JITDylibs for the given symbols.
SearchOrder lists the JITDylibs to search. For each dylib, the associated boolean indicates whether the search should match against non-exported (hidden visibility) symbols in that dylib (true means match against non-exported symbols, false means do not match).
The NotifyComplete callback will be called once all requested symbols reach the required state.
If all symbols are found, the RegisterDependencies function will be called while the session lock is held. This gives clients a chance to register dependencies for on the queried symbols for any symbols they are materializing (if a MaterializationResponsibility instance is present, this can be implemented by calling MaterializationResponsibility::addDependencies). If there are no dependenant symbols for this query (e.g. it is being made by a top level client to get an address to call) then the value NoDependenciesToRegister can be used.
Definition at line 1766 of file Core.cpp.
References llvm::dbgs(), LLVM_DEBUG, runSessionLocked(), and llvm::Error::success().
Referenced by llvm::orc::GDBJITDebugInfoRegistrationPlugin::Create(), lookup(), lookup(), lookup(), lookup(), llvm::orc::lookupAndRecordAddrs(), llvm::orc::Platform::lookupInitSymbols(), llvm::orc::Platform::lookupInitSymbolsAsync(), and registerJITDispatchHandlers().
◆ lookupFlags() [1/2]
◆ lookupFlags() [2/2]
◆ registerJITDispatchHandlers()
| Error llvm::orc::ExecutionSession::registerJITDispatchHandlers | ( | JITDylib & | JD, |
|---|---|---|---|
| JITDispatchHandlerAssociationMap | WFs ) |
For each tag symbol name, associate the corresponding AsyncHandlerWrapperFunction with the address of that symbol.
The handler becomes callable from the executor using the ORC runtime __orc_rt_jit_dispatch function and the given tag.
Tag symbols will be looked up in JD using LookupKind::Static, JITDylibLookupFlags::MatchAllSymbols (hidden tags will be found), and LookupFlags::WeaklyReferencedSymbol. Missing tag definitions will not cause an error, the handler will simply be dropped.
Definition at line 1861 of file Core.cpp.
References assert(), llvm::dbgs(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::formatv(), llvm::orc::SymbolLookupSet::fromMapKeys(), I, llvm::inconvertibleErrorCode(), JITDylib, LLVM_DEBUG, lookup(), llvm::make_error(), llvm::orc::MatchAllSymbols, llvm::Error::success(), and llvm::orc::WeaklyReferencedSymbol.
◆ registerResourceManager()
| void llvm::orc::ExecutionSession::registerResourceManager | ( | ResourceManager & | RM | ) |
|---|
◆ removeJITDylib()
| Error llvm::orc::ExecutionSession::removeJITDylib ( JITDylib & JD) | inline |
|---|
◆ removeJITDylibs()
| Error llvm::orc::ExecutionSession::removeJITDylibs | ( | std::vector< JITDylibSP > | JDsToRemove | ) |
|---|
Removes the given JITDylibs from the ExecutionSession.
This method clears all resources held for the JITDylibs, puts them in the closed state, and clears all references to them that are held by the ExecutionSession or other JITDylibs. No further code can be added to the removed JITDylibs, and the JITDylib objects will be freed once any remaining JITDylibSPs pointing to them are destroyed.
This method does not run static destructors for code contained in the JITDylibs, and each JITDylib can only be removed once.
JITDylibs will be removed in the order given. Teardown is usually independent for each JITDylib, but not always. In particular, where the ORC runtime is used it is expected that teardown off all JITDylibs will depend on it, so the JITDylib containing the ORC runtime must be removed last. If the client has introduced any other dependencies they should be accounted for in the removal order too.
Definition at line 1645 of file Core.cpp.
References assert(), llvm::find(), I, llvm::joinErrors(), runSessionLocked(), and llvm::Error::success().
Referenced by endSession(), and removeJITDylib().
◆ reportError()
| void llvm::orc::ExecutionSession::reportError ( Error Err) | inline |
|---|
◆ runJITDispatchHandler()
| void llvm::orc::ExecutionSession::runJITDispatchHandler | ( | SendResultFunction | SendResult, |
|---|---|---|---|
| ExecutorAddr | HandlerFnTagAddr, | ||
| ArrayRef< char > | ArgBuffer ) |
◆ runSessionLocked()
template
| decltype(auto) llvm::orc::ExecutionSession::runSessionLocked ( Func && F) | inline |
|---|
◆ setErrorReporter()
| ExecutionSession & llvm::orc::ExecutionSession::setErrorReporter ( ErrorReporter ReportError) | inline |
|---|
◆ setPlatform()
| void llvm::orc::ExecutionSession::setPlatform ( std::unique_ptr< Platform > P) | inline |
|---|
◆ wrapAsyncWithSPS() [1/2]
template<typename SPSSignature, typename ClassT, typename... MethodArgTs>
| JITDispatchHandlerFunction llvm::orc::ExecutionSession::wrapAsyncWithSPS ( ClassT * Instance, void(ClassT::* Method )(MethodArgTs...) ) | inlinestatic |
|---|
Wrap a class method that takes concrete argument types (and a sender for a concrete return type) to produce an AsyncHandlerWrapperFunction.
Uses SPS to unpack the arguments and pack the result.
This function is intended to support easy construction of AsyncHandlerWrapperFunctions that can be associated with a tag (using registerJITDispatchHandler) and called from the executor.
Definition at line 1671 of file Core.h.
References llvm::orc::Instance, and wrapAsyncWithSPS().
◆ wrapAsyncWithSPS() [2/2]
template<typename SPSSignature, typename HandlerT>
| JITDispatchHandlerFunction llvm::orc::ExecutionSession::wrapAsyncWithSPS ( HandlerT && H) | inlinestatic |
|---|
Wrap a handler that takes concrete argument types (and a sender for a concrete return type) to produce an AsyncHandlerWrapperFunction.
Uses SPS to unpack the arguments and pack the result.
This function is intended to support easy construction of AsyncHandlerWrapperFunctions that can be associated with a tag (using registerJITDispatchHandler) and called from the executor.
Definition at line 1653 of file Core.h.
References H.
Referenced by wrapAsyncWithSPS().
◆ InProgressFullLookupState
◆ InProgressLookupFlagsState
◆ JITDylib
◆ LookupState
◆ MaterializationResponsibility
◆ ResourceTracker
The documentation for this class was generated from the following files: