LLVM  10.0.0svn
Public Types | Public Member Functions | Friends | List of all members
llvm::orc::ExecutionSession Class Reference

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< SymbolStringPoolgetSymbolStringPool () 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...
 
JITDylibgetMainJITDylib ()
 Get the "main" JITDylib, which is created automatically on construction of the ExecutionSession. More...
 
JITDylibgetJITDylibByName (StringRef Name)
 Return a pointer to the "name" JITDylib. More...
 
JITDylibcreateJITDylib (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...
 
ExecutionSessionsetErrorReporter (ErrorReporter ReportError)
 Set the error reporter function. More...
 
void reportError (Error Err)
 Report a error for this execution session. More...
 
ExecutionSessionsetDispatchMaterialization (DispatchMaterializationFunction DispatchMaterialization)
 Set the materialization dispatch function. More...
 
void legacyFailQuery (AsynchronousSymbolQuery &Q, Error Err)
 
Expected< SymbolMaplegacyLookup (LegacyAsyncLookupFunction AsyncLookup, SymbolNameSet Names, SymbolState RequiredState, RegisterDependenciesFunction RegisterDependencies)
 A legacy lookup function for JITSymbolResolverAdapter. More...
 
void lookup (const JITDylibSearchList &SearchOrder, SymbolNameSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
 Search the given JITDylib list for the given symbols. More...
 
Expected< SymbolMaplookup (const JITDylibSearchList &SearchOrder, const SymbolNameSet &Symbols, SymbolState RequiredState=SymbolState::Ready, RegisterDependenciesFunction RegisterDependencies=NoDependenciesToRegister)
 Blocking version of lookup above. More...
 
Expected< JITEvaluatedSymbollookup (const JITDylibSearchList &SearchOrder, SymbolStringPtr Symbol)
 Convenience version of blocking lookup. More...
 
Expected< JITEvaluatedSymbollookup (ArrayRef< JITDylib *> SearchOrder, SymbolStringPtr Symbol)
 Convenience version of blocking lookup. More...
 
Expected< JITEvaluatedSymbollookup (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
 

Detailed Description

An ExecutionSession represents a running JIT program.

Definition at line 761 of file Core.h.

Member Typedef Documentation

◆ DispatchMaterializationFunction

For dispatching MaterializationUnit::materialize calls.

Definition at line 771 of file Core.h.

◆ ErrorReporter

For reporting errors.

Definition at line 767 of file Core.h.

◆ LegacyAsyncLookupFunction

Definition at line 838 of file Core.h.

Constructor & Destructor Documentation

◆ ExecutionSession()

llvm::orc::ExecutionSession::ExecutionSession ( std::shared_ptr< SymbolStringPool SSP = nullptr)

Construct an ExecutionSession.

SymbolStringPools may be shared between ExecutionSessions.

Definition at line 1821 of file Core.cpp.

References JITDylib.

Member Function Documentation

◆ allocateVModule()

VModuleKey llvm::orc::ExecutionSession::allocateVModule ( )
inline

Allocate a module key for a new module to add to the JIT.

Definition at line 807 of file Core.h.

◆ createJITDylib()

JITDylib & llvm::orc::ExecutionSession::createJITDylib ( std::string  Name,
bool  AddToMainDylibSearchOrder = true 
)

Add a new JITDylib to this ExecutionSession.

The JITDylib Name is required to be unique. Clients should verify that names are not being re-used (e.g. by calling getJITDylibByName) if names are based on user input.

Definition at line 1840 of file Core.cpp.

References assert(), getJITDylibByName(), JITDylib, and runSessionLocked().

◆ dispatchMaterialization()

void llvm::orc::ExecutionSession::dispatchMaterialization ( JITDylib JD,
std::unique_ptr< MaterializationUnit MU 
)
inline

Materialize the given unit.

Definition at line 902 of file Core.h.

References llvm::dbgs(), llvm::dump(), llvm::orc::JITDylib::getName(), and LLVM_DEBUG.

Referenced by dump().

◆ dump()

void llvm::orc::ExecutionSession::dump ( raw_ostream OS)

Dump the state of all the JITDylibs in this session.

Definition at line 2111 of file Core.cpp.

References assert(), dispatchMaterialization(), llvm::orc::JITDylib::dump(), llvm::Lock, and runSessionLocked().

◆ getJITDylibByName()

JITDylib * llvm::orc::ExecutionSession::getJITDylibByName ( StringRef  Name)

Return a pointer to the "name" JITDylib.

Ownership of JITDylib remains within Execution Session

Definition at line 1831 of file Core.cpp.

References llvm::orc::JITDylib::getName(), Name, and runSessionLocked().

Referenced by createJITDylib().

◆ getMainJITDylib()

JITDylib & llvm::orc::ExecutionSession::getMainJITDylib ( )

Get the "main" JITDylib, which is created automatically on construction of the ExecutionSession.

Definition at line 1827 of file Core.cpp.

References runSessionLocked().

◆ getSymbolStringPool()

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

Returns a shared_ptr to the SymbolStringPool for this ExecutionSession.

Definition at line 782 of file Core.h.

◆ intern()

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

◆ legacyFailQuery()

void llvm::orc::ExecutionSession::legacyFailQuery ( AsynchronousSymbolQuery Q,
Error  Err 
)

◆ legacyLookup()

Expected< SymbolMap > llvm::orc::ExecutionSession::legacyLookup ( LegacyAsyncLookupFunction  AsyncLookup,
SymbolNameSet  Names,
SymbolState  RequiredState,
RegisterDependenciesFunction  RegisterDependencies 
)

A legacy lookup function for JITSymbolResolverAdapter.

Do not use – this will be removed soon.

Definition at line 1867 of file Core.cpp.

References _, reportError(), runSessionLocked(), and llvm::Error::success().

◆ lookup() [1/5]

void llvm::orc::ExecutionSession::lookup ( const JITDylibSearchList SearchOrder,
SymbolNameSet  Symbols,
SymbolState  RequiredState,
SymbolsResolvedCallback  NotifyComplete,
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 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 1934 of file Core.cpp.

References assert(), llvm::dbgs(), LLVM_DEBUG, runSessionLocked(), and llvm::Error::success().

Referenced by llvm::orc::LazyCallThroughManager::callThroughToSymbol(), and lookup().

◆ lookup() [2/5]

Expected< SymbolMap > llvm::orc::ExecutionSession::lookup ( const JITDylibSearchList SearchOrder,
const SymbolNameSet Symbols,
SymbolState  RequiredState = SymbolState::Ready,
RegisterDependenciesFunction  RegisterDependencies = NoDependenciesToRegister 
)

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 2026 of file Core.cpp.

References _, lookup(), and llvm::Error::success().

◆ lookup() [3/5]

Expected< JITEvaluatedSymbol > llvm::orc::ExecutionSession::lookup ( const JITDylibSearchList SearchOrder,
SymbolStringPtr  Symbol 
)

Convenience version of blocking lookup.

Searches each of the JITDylibs in the search order in turn for the given symbol.

Definition at line 2080 of file Core.cpp.

References assert(), lookup(), and llvm::orc::Ready.

◆ lookup() [4/5]

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 2094 of file Core.cpp.

References lookup(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::reserve(), and llvm::ArrayRef< T >::size().

◆ lookup() [5/5]

Expected< JITEvaluatedSymbol > llvm::orc::ExecutionSession::lookup ( ArrayRef< JITDylib *>  SearchOrder,
StringRef  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 2107 of file Core.cpp.

References intern(), and lookup().

◆ releaseVModule()

void llvm::orc::ExecutionSession::releaseVModule ( VModuleKey  Key)
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.

Definition at line 814 of file Core.h.

◆ reportError()

void llvm::orc::ExecutionSession::reportError ( Error  Err)
inline

◆ runSessionLocked()

template<typename Func >
auto llvm::orc::ExecutionSession::runSessionLocked ( Func &&  F) -> decltype(F())
inline

◆ setDispatchMaterialization()

ExecutionSession& llvm::orc::ExecutionSession::setDispatchMaterialization ( DispatchMaterializationFunction  DispatchMaterialization)
inline

Set the materialization dispatch function.

Definition at line 829 of file Core.h.

◆ setErrorReporter()

ExecutionSession& llvm::orc::ExecutionSession::setErrorReporter ( ErrorReporter  ReportError)
inline

Set the error reporter function.

Definition at line 818 of file Core.h.

Friends And Related Function Documentation

◆ JITDylib

friend class JITDylib
friend

Definition at line 763 of file Core.h.

Referenced by createJITDylib(), and ExecutionSession().


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