LLVM
8.0.1
|
An ExecutionSession represents a running JIT program. More...
#include "llvm/ExecutionEngine/Orc/Core.h"
Public Types | |
using | ErrorReporter = std::function< void(Error)> |
For reporting errors. More... | |
using | DispatchMaterializationFunction = std::function< void(JITDylib &JD, std::unique_ptr< MaterializationUnit > MU)> |
For dispatching MaterializationUnit::materialize calls. More... | |
using | LegacyAsyncLookupFunction = std::function< SymbolNameSet(std::shared_ptr< AsynchronousSymbolQuery > Q, SymbolNameSet Names)> |
Public Member Functions | |
ExecutionSession (std::shared_ptr< SymbolStringPool > SSP=nullptr) | |
Construct an ExecutionSession. More... | |
SymbolStringPtr | intern (StringRef SymName) |
Add a symbol name to the SymbolStringPool and return a pointer to it. More... | |
std::shared_ptr< SymbolStringPool > | getSymbolStringPool () const |
Returns a shared_ptr to the SymbolStringPool for this ExecutionSession. More... | |
template<typename Func > | |
auto | runSessionLocked (Func &&F) -> decltype(F()) |
Run the given lambda with the session mutex locked. More... | |
JITDylib & | getMainJITDylib () |
Get the "main" JITDylib, which is created automatically on construction of the ExecutionSession. More... | |
JITDylib & | createJITDylib (std::string Name, bool AddToMainDylibSearchOrder=true) |
Add a new JITDylib to this ExecutionSession. More... | |
VModuleKey | allocateVModule () |
Allocate a module key for a new module to add to the JIT. More... | |
void | releaseVModule (VModuleKey Key) |
Return a module key to the ExecutionSession so that it can be re-used. More... | |
ExecutionSession & | setErrorReporter (ErrorReporter ReportError) |
Set the error reporter function. More... | |
void | reportError (Error Err) |
Report a error for this execution session. More... | |
ExecutionSession & | setDispatchMaterialization (DispatchMaterializationFunction DispatchMaterialization) |
Set the materialization dispatch function. More... | |
void | legacyFailQuery (AsynchronousSymbolQuery &Q, Error Err) |
Expected< SymbolMap > | legacyLookup (LegacyAsyncLookupFunction AsyncLookup, SymbolNameSet Names, bool WaiUntilReady, RegisterDependenciesFunction RegisterDependencies) |
A legacy lookup function for JITSymbolResolverAdapter. More... | |
void | lookup (const JITDylibSearchList &SearchOrder, SymbolNameSet Symbols, SymbolsResolvedCallback OnResolve, SymbolsReadyCallback OnReady, RegisterDependenciesFunction RegisterDependencies) |
Search the given JITDylib list for the given symbols. More... | |
Expected< SymbolMap > | lookup (const JITDylibSearchList &SearchOrder, const SymbolNameSet &Symbols, RegisterDependenciesFunction RegisterDependencies=NoDependenciesToRegister, bool WaitUntilReady=true) |
Blocking version of lookup above. More... | |
Expected< JITEvaluatedSymbol > | lookup (const JITDylibSearchList &SearchOrder, SymbolStringPtr Symbol) |
Convenience version of blocking lookup. More... | |
Expected< JITEvaluatedSymbol > | lookup (ArrayRef< JITDylib *> SearchOrder, SymbolStringPtr Symbol) |
Convenience version of blocking lookup. More... | |
Expected< JITEvaluatedSymbol > | lookup (ArrayRef< JITDylib *> SearchOrder, StringRef Symbol) |
Convenience version of blocking lookup. More... | |
void | dispatchMaterialization (JITDylib &JD, std::unique_ptr< MaterializationUnit > MU) |
Materialize the given unit. More... | |
void | dump (raw_ostream &OS) |
Dump the state of all the JITDylibs in this session. More... | |
Friends | |
class | JITDylib |
An ExecutionSession represents a running JIT program.
using llvm::orc::ExecutionSession::DispatchMaterializationFunction = std::function<void( JITDylib &JD, std::unique_ptr<MaterializationUnit> MU)> |
using llvm::orc::ExecutionSession::ErrorReporter = std::function<void(Error)> |
using llvm::orc::ExecutionSession::LegacyAsyncLookupFunction = std::function<SymbolNameSet( std::shared_ptr<AsynchronousSymbolQuery> Q, SymbolNameSet Names)> |
llvm::orc::ExecutionSession::ExecutionSession | ( | std::shared_ptr< SymbolStringPool > | SSP = nullptr | ) |
Construct an ExecutionSession.
SymbolStringPools may be shared between ExecutionSessions.
Definition at line 1575 of file Core.cpp.
References JITDylib.
|
inline |
JITDylib & llvm::orc::ExecutionSession::createJITDylib | ( | std::string | Name, |
bool | AddToMainDylibSearchOrder = true |
||
) |
Add a new JITDylib to this ExecutionSession.
Definition at line 1585 of file Core.cpp.
References JITDylib, and runSessionLocked().
|
inline |
Materialize the given unit.
Definition at line 833 of file Core.h.
References llvm::dbgs(), llvm::dump(), llvm::orc::JITDylib::getName(), and LLVM_DEBUG.
Referenced by dump().
void llvm::orc::ExecutionSession::dump | ( | raw_ostream & | OS | ) |
Dump the state of all the JITDylibs in this session.
Definition at line 1963 of file Core.cpp.
References assert(), dispatchMaterialization(), llvm::orc::JITDylib::dump(), llvm::Lock, and runSessionLocked().
JITDylib & llvm::orc::ExecutionSession::getMainJITDylib | ( | ) |
Get the "main" JITDylib, which is created automatically on construction of the ExecutionSession.
Definition at line 1581 of file Core.cpp.
References runSessionLocked().
|
inline |
Returns a shared_ptr to the SymbolStringPool for this ExecutionSession.
|
inline |
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition at line 715 of file Core.h.
Referenced by llvm::orc::getObjectSymbolFlags(), llvm::orc::JITSymbolResolverAdapter::getResponsibilitySet(), llvm::orc::JITSymbolResolverAdapter::lookup(), lookup(), and llvm::orc::MangleAndInterner::operator()().
void llvm::orc::ExecutionSession::legacyFailQuery | ( | AsynchronousSymbolQuery & | Q, |
Error | Err | ||
) |
Definition at line 1596 of file Core.cpp.
References assert(), reportError(), and runSessionLocked().
Referenced by llvm::orc::lookupWithLegacyFn().
Expected< SymbolMap > llvm::orc::ExecutionSession::legacyLookup | ( | LegacyAsyncLookupFunction | AsyncLookup, |
SymbolNameSet | Names, | ||
bool | WaiUntilReady, | ||
RegisterDependenciesFunction | RegisterDependencies | ||
) |
A legacy lookup function for JITSymbolResolverAdapter.
Do not use – this will be removed soon.
Definition at line 1611 of file Core.cpp.
References _, llvm::Lock, and llvm::Error::success().
void llvm::orc::ExecutionSession::lookup | ( | const JITDylibSearchList & | SearchOrder, |
SymbolNameSet | Symbols, | ||
SymbolsResolvedCallback | OnResolve, | ||
SymbolsReadyCallback | OnReady, | ||
RegisterDependenciesFunction | RegisterDependencies | ||
) |
Search the given JITDylib list 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 OnResolve callback will be called once all requested symbols are resolved, or if an error occurs prior to resolution.
The OnReady callback will be called once all requested symbols are ready, or if an error occurs after resolution but before all symbols are ready.
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 1742 of file Core.cpp.
References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::orc::AsynchronousSymbolQuery::handleFullyReady(), llvm::orc::AsynchronousSymbolQuery::handleFullyResolved(), llvm::orc::AsynchronousSymbolQuery::isFullyReady(), llvm::orc::AsynchronousSymbolQuery::isFullyResolved(), llvm::Lock, and runSessionLocked().
Referenced by llvm::orc::LazyCallThroughManager::callThroughToSymbol(), and lookup().
Expected< SymbolMap > llvm::orc::ExecutionSession::lookup | ( | const JITDylibSearchList & | SearchOrder, |
const SymbolNameSet & | Symbols, | ||
RegisterDependenciesFunction | RegisterDependencies = NoDependenciesToRegister , |
||
bool | WaitUntilReady = true |
||
) |
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 1819 of file Core.cpp.
References _, llvm::Lock, and llvm::Error::success().
Expected< JITEvaluatedSymbol > llvm::orc::ExecutionSession::lookup | ( | const JITDylibSearchList & | SearchOrder, |
SymbolStringPtr | Symbol | ||
) |
Expected< JITEvaluatedSymbol > llvm::orc::ExecutionSession::lookup | ( | ArrayRef< JITDylib *> | SearchOrder, |
SymbolStringPtr | Symbol | ||
) |
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 1946 of file Core.cpp.
References lookup(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::reserve(), and llvm::ArrayRef< T >::size().
Expected< JITEvaluatedSymbol > llvm::orc::ExecutionSession::lookup | ( | ArrayRef< JITDylib *> | SearchOrder, |
StringRef | Symbol | ||
) |
|
inline |
Return a module key to the ExecutionSession so that it can be re-used.
This should only be done once all resources associated with the original key have been released.
|
inline |
Report a error for this execution session.
Unhandled errors can be sent here to log them.
Definition at line 754 of file Core.h.
Referenced by llvm::orc::LazyCallThroughManager::callThroughToSymbol(), llvm::orc::ObjectTransformLayer::emit(), llvm::orc::IRTransformLayer::emit(), llvm::orc::IRCompileLayer::emit(), llvm::orc::RTDyldObjectLinkingLayer::emit(), llvm::orc::LazyReexportsMaterializationUnit::getName(), and legacyFailQuery().
|
inline |
Run the given lambda with the session mutex locked.
Definition at line 721 of file Core.h.
References F(), llvm::Lock, and Name.
Referenced by createJITDylib(), dump(), getMainJITDylib(), llvm::orc::IRMaterializationUnit::getName(), legacyFailQuery(), lookup(), and llvm::orc::MaterializationResponsibility::replace().
|
inline |
|
inline |
|
friend |
Definition at line 699 of file Core.h.
Referenced by createJITDylib(), and ExecutionSession().