LLVM  15.0.0git
llvm::orc::JITDylib Class Reference

Represents a JIT'd dynamic library. More...

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

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

## Public Member Functions

JITDylib (const JITDylib &)=delete

JITDyliboperator= (const JITDylib &)=delete

JITDylib (JITDylib &&)=delete

JITDyliboperator= (JITDylib &&)=delete

~JITDylib ()

ExecutionSessiongetExecutionSession () const
Get a reference to the ExecutionSession for this JITDylib. More...

void dump (raw_ostream &OS)
Dump current JITDylib state to OS. 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...

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

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

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

Expected< std::vector< JITDylibSP > > getDFSLinkOrder ()
Return this JITDylib and its transitive dependencies in DFS order based on linkage relationships. More...

Expected< std::vector< JITDylibSP > > getReverseDFSLinkOrder ()
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 Expected< std::vector< JITDylibSP > > getDFSLinkOrder (ArrayRef< JITDylibSP > JDs)
Returns the given JITDylibs and all of their transitive dependencies in DFS order (based on linkage relationships). More...

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

## Friends

class AsynchronousSymbolQuery

class ExecutionSession

class Platform

class MaterializationResponsibility

Protected Member Functions inherited from llvm::ThreadSafeRefCountedBase< JITDylib >

## Detailed Description

Represents a JIT'd dynamic library.

This class aims to mimic the behavior of a regular dylib or shared object, but without requiring the contained program representations to be compiled up-front. The JITDylib's content is defined by adding MaterializationUnits, and contained MaterializationUnits will typically rely on the JITDylib's links-against order to resolve external references (similar to a regular dylib).

The JITDylib object is a thin wrapper that references state held by the ExecutionSession. JITDylibs can be removed, clearing this underlying state and leaving the JITDylib object in a defunct state. In this state the JITDylib's name is guaranteed to remain accessible. If the ExecutionSession is still alive then other operations are callable but will return an Error or null result (depending on the API). It is illegal to call any operation other than getName on a JITDylib after the ExecutionSession has been torn down.

JITDylibs cannot be moved or copied. Their address is stable, and useful as a key in some JIT data structures.

Definition at line 947 of file Core.h.

## ◆ JITDylib() [1/2]

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

## ◆ JITDylib() [2/2]

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

## ◆ ~JITDylib()

 llvm::orc::JITDylib::~JITDylib ( )

Definition at line 614 of file Core.cpp.

## Member Function Documentation

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.

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 1779 of file Core.h.

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

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

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

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 1302 of file Core.cpp.

## ◆ 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.

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 618 of file Core.cpp.

## ◆ createResourceTracker()

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

Create a resource tracker for this JITDylib.

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 642 of file Core.cpp.

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

## ◆ define() [1/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.

If RT is not specified then the default resource tracker will be used.

This overload always takes ownership of the MaterializationUnit. If any errors occur, the MaterializationUnit consumed.

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 1796 of file Core.h.

## ◆ 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.

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 1839 of file Core.h.

## ◆ dump()

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

Dump current JITDylib state to OS.

It is legal to call this method on a defunct JITDylib.

Definition at line 1389 of file Core.cpp.

## ◆ getDefaultResourceTracker()

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

Get the default resource tracker for this JITDylib.

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 633 of file Core.cpp.

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

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

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

If any JITDylib in the order is defunct then this method will return an error, otherwise returns the order.

Definition at line 2008 of file Core.cpp.

 Expected< 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.

If any JITDylib in the order is defunct then this method will return an error, otherwise returns the order.

Definition at line 1961 of file Core.cpp.

## ◆ getExecutionSession()

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

Get a reference to the ExecutionSession for this JITDylib.

It is legal to call this method on a defunct JITDylib, however the result will only usable if the ExecutionSession is still alive. If this JITDylib is held by an error that may have torn down the JIT then the result should not be used.

Definition at line 967 of file Core.h.

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

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

If any JITDylib in the order is defunct then this method will return an error, otherwise returns the order.

Definition at line 2012 of file Core.cpp.

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

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

Each JITDylib will appear only once.

If any JITDylib in the order is defunct then this method will return an error, otherwise returns the order.

Definition at line 2001 of file Core.cpp.

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

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 1330 of file Core.cpp.

 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.

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 1318 of file Core.cpp.

References assert(), 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).

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 650 of file Core.cpp.

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

 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.

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 1306 of file Core.cpp.

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

 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.

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 1287 of file Core.cpp.

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

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

It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.

Definition at line 1789 of file Core.h.

References assert(), and F.

## ◆ AsynchronousSymbolQuery

 friend class AsynchronousSymbolQuery
friend

Definition at line 949 of file Core.h.

## ◆ ExecutionSession

 friend class ExecutionSession
friend

Definition at line 950 of file Core.h.

## ◆ MaterializationResponsibility

 friend class MaterializationResponsibility
friend

Definition at line 952 of file Core.h.

## ◆ Platform

 friend class Platform
friend

Definition at line 951 of file Core.h.

The documentation for this class was generated from the following files:
• include/llvm/ExecutionEngine/Orc/Core.h
• lib/ExecutionEngine/Orc/Core.cpp