LLVM  8.0.1
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...
 
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, 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< SymbolMaplookup (const JITDylibSearchList &SearchOrder, const SymbolNameSet &Symbols, RegisterDependenciesFunction RegisterDependencies=NoDependenciesToRegister, bool WaitUntilReady=true)
 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 697 of file Core.h.

Member Typedef Documentation

◆ DispatchMaterializationFunction

For dispatching MaterializationUnit::materialize calls.

Definition at line 707 of file Core.h.

◆ ErrorReporter

For reporting errors.

Definition at line 703 of file Core.h.

◆ LegacyAsyncLookupFunction

Definition at line 766 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 1575 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 735 of file Core.h.

◆ createJITDylib()

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().

◆ dispatchMaterialization()

void llvm::orc::ExecutionSession::dispatchMaterialization ( JITDylib JD,
std::unique_ptr< MaterializationUnit MU 
)
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().

◆ 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().

◆ getMainJITDylib()

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().

◆ getSymbolStringPool()

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

Returns a shared_ptr to the SymbolStringPool for this ExecutionSession.

Definition at line 718 of file Core.h.

◆ intern()

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

◆ legacyFailQuery()

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().

◆ legacyLookup()

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().

◆ lookup() [1/5]

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().

◆ lookup() [2/5]

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().

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

References assert(), and lookup().

◆ 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 1946 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 1959 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 742 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

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().

◆ setDispatchMaterialization()

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

Set the materialization dispatch function.

Definition at line 757 of file Core.h.

◆ setErrorReporter()

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

Set the error reporter function.

Definition at line 746 of file Core.h.

Friends And Related Function Documentation

◆ JITDylib

friend class JITDylib
friend

Definition at line 699 of file Core.h.

Referenced by createJITDylib(), and ExecutionSession().


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