LLVM  14.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::orc::JITDylib Class Reference

A symbol table that supports asynchoronous symbol queries. More...

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

Inheritance diagram for llvm::orc::JITDylib:
Inheritance graph
[legend]
Collaboration diagram for llvm::orc::JITDylib:
Collaboration graph
[legend]

Public Types

using AsynchronousSymbolQuerySet = std::set< std::shared_ptr< AsynchronousSymbolQuery > >
 

Public Member Functions

 JITDylib (const JITDylib &)=delete
 
JITDyliboperator= (const JITDylib &)=delete
 
 JITDylib (JITDylib &&)=delete
 
JITDyliboperator= (JITDylib &&)=delete
 
const std::string & getName () const
 Get the name for this JITDylib. More...
 
ExecutionSessiongetExecutionSession () const
 Get a reference to the ExecutionSession for this JITDylib. More...
 
Error clear ()
 Calls remove on all trackers currently associated with this JITDylib. More...
 
ResourceTrackerSP getDefaultResourceTracker ()
 Get the default resource tracker for this JITDylib. More...
 
ResourceTrackerSP createResourceTracker ()
 Create a resource tracker for this JITDylib. More...
 
template<typename GeneratorT >
GeneratorT & addGenerator (std::unique_ptr< GeneratorT > DefGenerator)
 Adds a definition generator to this JITDylib and returns a referenece to it. More...
 
void removeGenerator (DefinitionGenerator &G)
 Remove a definition generator from this JITDylib. More...
 
void setLinkOrder (JITDylibSearchOrder NewSearchOrder, bool LinkAgainstThisJITDylibFirst=true)
 Set the link order to be used when fixing up definitions in JITDylib. More...
 
void addToLinkOrder (JITDylib &JD, JITDylibLookupFlags JDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
 Add the given JITDylib to the link order for definitions in this JITDylib. More...
 
void replaceInLinkOrder (JITDylib &OldJD, JITDylib &NewJD, JITDylibLookupFlags JDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
 Replace OldJD with NewJD in the link order if OldJD is present. More...
 
void removeFromLinkOrder (JITDylib &JD)
 Remove the given JITDylib from the link order for this JITDylib if it is present. More...
 
template<typename Func >
auto withLinkOrderDo (Func &&F) -> decltype(F(std::declval< const JITDylibSearchOrder & >()))
 Do something with the link order (run under the session lock). More...
 
template<typename MaterializationUnitType >
Error define (std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
 Define all symbols provided by the materialization unit to be part of this JITDylib. More...
 
template<typename MaterializationUnitType >
Error define (std::unique_ptr< MaterializationUnitType > &MU, ResourceTrackerSP RT=nullptr)
 Define all symbols provided by the materialization unit to be part of this JITDylib. More...
 
Error remove (const SymbolNameSet &Names)
 Tries to remove the given symbols. More...
 
void dump (raw_ostream &OS)
 Dump current JITDylib state to OS. More...
 
std::vector< JITDylibSPgetDFSLinkOrder ()
 Return this JITDylib and its transitive dependencies in DFS order based on linkage relationships. More...
 
std::vector< JITDylibSPgetReverseDFSLinkOrder ()
 Rteurn this JITDylib and its transitive dependencies in reverse DFS order based on linkage relationships. More...
 
- Public Member Functions inherited from llvm::ThreadSafeRefCountedBase< JITDylib >
void Retain () const
 
void Release () const
 

Static Public Member Functions

static std::vector< JITDylibSPgetDFSLinkOrder (ArrayRef< JITDylibSP > JDs)
 Returns the given JITDylibs and all of their transitive dependencies in DFS order (based on linkage relationships). More...
 
static std::vector< JITDylibSPgetReverseDFSLinkOrder (ArrayRef< JITDylibSP > JDs)
 Returns the given JITDylibs and all of their transitive dependensies in reverse DFS order (based on linkage relationships). More...
 

Friends

class AsynchronousSymbolQuery
 
class ExecutionSession
 
class Platform
 
class MaterializationResponsibility
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::ThreadSafeRefCountedBase< JITDylib >
 ThreadSafeRefCountedBase ()=default
 
 ThreadSafeRefCountedBase (const ThreadSafeRefCountedBase &)
 
ThreadSafeRefCountedBaseoperator= (const ThreadSafeRefCountedBase &)=delete
 
 ~ThreadSafeRefCountedBase ()
 

Detailed Description

A symbol table that supports asynchoronous symbol queries.

Represents a virtual shared object. Instances can not be copied or moved, so their addresses may be used as keys for resource management. JITDylib state changes must be made via an ExecutionSession to guarantee that they are synchronized with respect to other JITDylib operations.

Definition at line 922 of file Core.h.

Member Typedef Documentation

◆ AsynchronousSymbolQuerySet

Definition at line 931 of file Core.h.

Constructor & Destructor Documentation

◆ JITDylib() [1/2]

llvm::orc::JITDylib::JITDylib ( const JITDylib )
delete

◆ JITDylib() [2/2]

llvm::orc::JITDylib::JITDylib ( JITDylib &&  )
delete

Member Function Documentation

◆ addGenerator()

template<typename GeneratorT >
GeneratorT & llvm::orc::JITDylib::addGenerator ( std::unique_ptr< GeneratorT >  DefGenerator)

Adds a definition generator to this JITDylib and returns a referenece to it.

When JITDylibs are searched during lookup, if no existing definition of a symbol is found, then any generators that have been added are run (in the order that they were added) to potentially generate a definition.

Definition at line 1684 of file Core.h.

References G, llvm::Lock, and move.

◆ addToLinkOrder()

void llvm::orc::JITDylib::addToLinkOrder ( JITDylib JD,
JITDylibLookupFlags  JDLookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly 
)

Add the given JITDylib to the link order for definitions in this JITDylib.

Definition at line 1281 of file Core.cpp.

References llvm::orc::ExecutionSession::runSessionLocked().

◆ clear()

Error llvm::orc::JITDylib::clear ( )

Calls remove on all trackers currently associated with this JITDylib.

Does not run static deinits.

Note that removal happens outside the session lock, so new code may be added concurrently while the clear is underway, and the newly added code will not be cleared. Adding new code concurrently with a clear is usually a bug and should be avoided.

Definition at line 615 of file Core.cpp.

References getDefaultResourceTracker(), and llvm::orc::ExecutionSession::runSessionLocked().

◆ createResourceTracker()

ResourceTrackerSP llvm::orc::JITDylib::createResourceTracker ( )

Create a resource tracker for this JITDylib.

Definition at line 637 of file Core.cpp.

References llvm::orc::ExecutionSession::runSessionLocked().

◆ define() [1/2]

template<typename MaterializationUnitType >
Error llvm::orc::JITDylib::define ( std::unique_ptr< MaterializationUnitType > &&  MU,
ResourceTrackerSP  RT = nullptr 
)

◆ define() [2/2]

template<typename MaterializationUnitType >
Error llvm::orc::JITDylib::define ( std::unique_ptr< MaterializationUnitType > &  MU,
ResourceTrackerSP  RT = nullptr 
)

Define all symbols provided by the materialization unit to be part of this JITDylib.

This overload only takes ownership of the MaterializationUnit no error is generated. If an error occurs, ownership remains with the caller. This may allow the caller to modify the MaterializationUnit to correct the issue, then re-call define.

Definition at line 1739 of file Core.h.

References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, getDefaultResourceTracker(), getName(), llvm::orc::ExecutionSession::runSessionLocked(), and llvm::Error::success().

◆ dump()

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

Dump current JITDylib state to OS.

Definition at line 1365 of file Core.cpp.

References llvm::format(), and llvm::orc::ExecutionSession::runSessionLocked().

◆ getDefaultResourceTracker()

ResourceTrackerSP llvm::orc::JITDylib::getDefaultResourceTracker ( )

◆ getDFSLinkOrder() [1/2]

std::vector< JITDylibSP > llvm::orc::JITDylib::getDFSLinkOrder ( )

Return this JITDylib and its transitive dependencies in DFS order based on linkage relationships.

Definition at line 1917 of file Core.cpp.

Referenced by getReverseDFSLinkOrder().

◆ getDFSLinkOrder() [2/2]

std::vector< JITDylibSP > llvm::orc::JITDylib::getDFSLinkOrder ( ArrayRef< JITDylibSP JDs)
static

Returns the given JITDylibs and all of their transitive dependencies in DFS order (based on linkage relationships).

Each JITDylib will appear only once.

Definition at line 1875 of file Core.cpp.

References llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::count(), llvm::ArrayRef< T >::empty(), and llvm::ArrayRef< T >::front().

◆ getExecutionSession()

ExecutionSession& llvm::orc::JITDylib::getExecutionSession ( ) const
inline

◆ getName()

const std::string& llvm::orc::JITDylib::getName ( ) const
inline

Get the name for this JITDylib.

Definition at line 939 of file Core.h.

Referenced by define(), llvm::orc::LLJIT::deinitialize(), and llvm::orc::LLJIT::initialize().

◆ getReverseDFSLinkOrder() [1/2]

std::vector< JITDylibSP > llvm::orc::JITDylib::getReverseDFSLinkOrder ( )

Rteurn this JITDylib and its transitive dependencies in reverse DFS order based on linkage relationships.

Definition at line 1921 of file Core.cpp.

◆ getReverseDFSLinkOrder() [2/2]

std::vector< JITDylibSP > llvm::orc::JITDylib::getReverseDFSLinkOrder ( ArrayRef< JITDylibSP JDs)
static

Returns the given JITDylibs and all of their transitive dependensies in reverse DFS order (based on linkage relationships).

Each JITDylib will appear only once.

Definition at line 1911 of file Core.cpp.

References getDFSLinkOrder(), and llvm::reverse().

◆ operator=() [1/2]

JITDylib& llvm::orc::JITDylib::operator= ( const JITDylib )
delete

◆ operator=() [2/2]

JITDylib& llvm::orc::JITDylib::operator= ( JITDylib &&  )
delete

◆ remove()

Error llvm::orc::JITDylib::remove ( const SymbolNameSet Names)

Tries to remove the given symbols.

If any symbols are not defined in this JITDylib this method will return a SymbolsNotFound error covering the missing symbols.

If all symbols are found but some symbols are in the process of being materialized this method will return a SymbolsCouldNotBeRemoved error.

On success, all symbols are removed. On failure, the JITDylib state is left unmodified (no symbols are removed).

Definition at line 1307 of file Core.cpp.

References I, llvm::orc::Materializing, and llvm::orc::ExecutionSession::runSessionLocked().

◆ removeFromLinkOrder()

void llvm::orc::JITDylib::removeFromLinkOrder ( JITDylib JD)

Remove the given JITDylib from the link order for this JITDylib if it is present.

Otherwise this operation is a no-op.

Definition at line 1296 of file Core.cpp.

References llvm::find_if(), I, and llvm::orc::ExecutionSession::runSessionLocked().

◆ removeGenerator()

void llvm::orc::JITDylib::removeGenerator ( DefinitionGenerator G)

Remove a definition generator from this JITDylib.

The given generator must exist in this JITDylib's generators list (i.e. have been added and not yet removed).

Definition at line 644 of file Core.cpp.

References assert(), llvm::find_if(), G, H, I, and llvm::Lock.

◆ replaceInLinkOrder()

void llvm::orc::JITDylib::replaceInLinkOrder ( JITDylib OldJD,
JITDylib NewJD,
JITDylibLookupFlags  JDLookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly 
)

Replace OldJD with NewJD in the link order if OldJD is present.

Otherwise this operation is a no-op.

Definition at line 1285 of file Core.cpp.

References llvm::orc::ExecutionSession::runSessionLocked().

◆ setLinkOrder()

void llvm::orc::JITDylib::setLinkOrder ( JITDylibSearchOrder  NewSearchOrder,
bool  LinkAgainstThisJITDylibFirst = true 
)

Set the link order to be used when fixing up definitions in JITDylib.

This will replace the previous link order, and apply to any symbol resolutions made for definitions in this JITDylib after the call to setLinkOrder (even if the definition itself was added before the call).

If LinkAgainstThisJITDylibFirst is true (the default) then this JITDylib will add itself to the beginning of the LinkOrder (Clients should not put this JITDylib in the list in this case, to avoid redundant lookups).

If LinkAgainstThisJITDylibFirst is false then the link order will be used as-is. The primary motivation for this feature is to support deliberate shadowing of symbols in this JITDylib by a facade JITDylib. For example, the facade may resolve function names to stubs, and the stubs may compile lazily by looking up symbols in this dylib. Adding the facade dylib as the first in the link order (instead of this dylib) ensures that definitions within this dylib resolve to the lazy-compiling stubs, rather than immediately materializing the definitions in this dylib.

Definition at line 1267 of file Core.cpp.

References llvm::append_range(), move, and llvm::orc::ExecutionSession::runSessionLocked().

◆ withLinkOrderDo()

template<typename Func >
auto llvm::orc::JITDylib::withLinkOrderDo ( Func &&  F) -> decltype(F(std::declval<const JITDylibSearchOrder &>()))

Do something with the link order (run under the session lock).

Definition at line 1692 of file Core.h.

References F.

Friends And Related Function Documentation

◆ AsynchronousSymbolQuery

friend class AsynchronousSymbolQuery
friend

Definition at line 924 of file Core.h.

◆ ExecutionSession

friend class ExecutionSession
friend

Definition at line 925 of file Core.h.

◆ MaterializationResponsibility

friend class MaterializationResponsibility
friend

Definition at line 927 of file Core.h.

◆ Platform

friend class Platform
friend

Definition at line 926 of file Core.h.


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