class JITDylib

Declaration

class JITDylib : public ThreadSafeRefCountedBase, public JITLinkDylib { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:946

Inherits from: ThreadSafeRefCountedBase, JITLinkDylib

Member Variables

private llvm::orc::ExecutionSession& ES
private enum(unnamed enum at / home / hdoc / tmp / llvm - project / llvm / include / llvm / ExecutionEngine / Orc / Core.h : 1283 : 3) State = Open
private std::mutex GeneratorsMutex
private llvm::orc::JITDylib::SymbolTable Symbols
private llvm::orc::JITDylib::UnmaterializedInfosMap UnmaterializedInfos
private llvm::orc::JITDylib::MaterializingInfosMap MaterializingInfos
private std::vector<std::shared_ptr<DefinitionGenerator>> DefGenerators
private llvm::orc::JITDylibSearchOrder LinkOrder
private llvm::orc::ResourceTrackerSP DefaultTracker
private DenseMap<llvm::orc::ResourceTracker*, llvm::orc::SymbolNameVector> TrackerSymbols
private DenseMap< llvm::orc::ResourceTracker*, DenseSet<llvm::orc:: MaterializationResponsibility*>> TrackerMRs

Method Overview

  • public JITDylib(llvm::orc::JITDylib &&)
  • public JITDylib(const llvm::orc::JITDylib &)
  • private JITDylib(llvm::orc::ExecutionSession & ES, std::string Name)
  • private void addDependencies(const llvm::orc::SymbolStringPtr & Name, const llvm::orc::SymbolDependenceMap & Dependants)
  • public template <typename GeneratorT>GeneratorT & addGenerator(std::unique_ptr<GeneratorT> DefGenerator)
  • public void addToLinkOrder(llvm::orc::JITDylib & JD, llvm::orc::JITDylibLookupFlags JDLookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly)
  • public llvm::Error clear()
  • public llvm::orc::ResourceTrackerSP createResourceTracker()
  • public template <typename MaterializationUnitType>llvm::Error define(std::unique_ptr<MaterializationUnitType> & MU, llvm::orc::ResourceTrackerSP RT = nullptr)
  • public template <typename MaterializationUnitType>llvm::Error define(std::unique_ptr<MaterializationUnitType> && MU, llvm::orc::ResourceTrackerSP RT = nullptr)
  • private llvm::Error defineImpl(llvm::orc::MaterializationUnit & MU)
  • private Expected<llvm::orc::SymbolFlagsMap> defineMaterializing(llvm::orc::SymbolFlagsMap SymbolFlags)
  • private Expected<std::unique_ptr<MaterializationResponsibility>> delegate(llvm::orc::MaterializationResponsibility & FromMR, llvm::orc::SymbolFlagsMap SymbolFlags, llvm::orc::SymbolStringPtr InitSymbol)
  • private void detachQueryHelper(llvm::orc::AsynchronousSymbolQuery & Q, const llvm::orc::SymbolNameSet & QuerySymbols)
  • public void dump(llvm::raw_ostream & OS)
  • private llvm::Error emit(llvm::orc::MaterializationResponsibility & MR, const llvm::orc::SymbolFlagsMap & Emitted)
  • private static std::pair<AsynchronousSymbolQuerySet, std::shared_ptr<SymbolDependenceMap>> failSymbols(llvm::orc::JITDylib::FailedSymbolsWorklist)
  • public static Expected<std::vector<JITDylibSP>> getDFSLinkOrder(ArrayRef<llvm::orc::JITDylibSP> JDs)
  • public Expected<std::vector<JITDylibSP>> getDFSLinkOrder()
  • public llvm::orc::ResourceTrackerSP getDefaultResourceTracker()
  • public llvm::orc::ExecutionSession & getExecutionSession() const
  • private llvm::orc::SymbolNameSet getRequestedSymbols(const llvm::orc::SymbolFlagsMap & SymbolFlags) const
  • public static Expected<std::vector<JITDylibSP>> getReverseDFSLinkOrder(ArrayRef<llvm::orc::JITDylibSP> JDs)
  • public Expected<std::vector<JITDylibSP>> getReverseDFSLinkOrder()
  • private void installMaterializationUnit(std::unique_ptr<MaterializationUnit> MU, llvm::orc::ResourceTracker & RT)
  • public llvm::Error remove(const llvm::orc::SymbolNameSet & Names)
  • public void removeFromLinkOrder(llvm::orc::JITDylib & JD)
  • public void removeGenerator(llvm::orc::DefinitionGenerator & G)
  • private std::pair<AsynchronousSymbolQuerySet, std::shared_ptr<SymbolDependenceMap>> removeTracker(llvm::orc::ResourceTracker & RT)
  • private llvm::Error replace(llvm::orc::MaterializationResponsibility & FromMR, std::unique_ptr<MaterializationUnit> MU)
  • public void replaceInLinkOrder(llvm::orc::JITDylib & OldJD, llvm::orc::JITDylib & NewJD, llvm::orc::JITDylibLookupFlags JDLookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly)
  • private llvm::Error resolve(llvm::orc::MaterializationResponsibility & MR, const llvm::orc::SymbolMap & Resolved)
  • public void setLinkOrder(llvm::orc::JITDylibSearchOrder NewSearchOrder, bool LinkAgainstThisJITDylibFirst = true)
  • private void transferEmittedNodeDependencies(llvm::orc::JITDylib::MaterializingInfo & DependantMI, const llvm::orc::SymbolStringPtr & DependantName, llvm::orc::JITDylib::MaterializingInfo & EmittedMI)
  • private void transferTracker(llvm::orc::ResourceTracker & DstRT, llvm::orc::ResourceTracker & SrcRT)
  • private void unlinkMaterializationResponsibility(llvm::orc::MaterializationResponsibility & MR)
  • public template <typename Func>auto withLinkOrderDo(Func && F) -> decltype(F(std::declval<const llvm::orc::JITDylibSearchOrder &>()))
  • public ~JITDylib()

Inherited from JITLinkDylib:

Methods

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

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:956

Parameters

llvm::orc::JITDylib&&

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

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:954

Parameters

const llvm::orc::JITDylib&

JITDylib(llvm::orc::ExecutionSession& ES,
         std::string Name)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1236

Parameters

llvm::orc::ExecutionSession& ES
std::string Name

void addDependencies(
    const llvm::orc::SymbolStringPtr& Name,
    const llvm::orc::SymbolDependenceMap&
        Dependants)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1266

Parameters

const llvm::orc::SymbolStringPtr& Name
const llvm::orc::SymbolDependenceMap& Dependants

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1007

Templates

GeneratorT

Parameters

std::unique_ptr<GeneratorT> DefGenerator

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1047

Parameters

llvm::orc::JITDylib& JD
llvm::orc::JITDylibLookupFlags JDLookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly

llvm::Error clear()

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:983

llvm::orc::ResourceTrackerSP
createResourceTracker()

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:995

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1100

Templates

MaterializationUnitType

Parameters

std::unique_ptr<MaterializationUnitType>& MU
llvm::orc::ResourceTrackerSP RT = nullptr

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1086

Templates

MaterializationUnitType

Parameters

std::unique_ptr<MaterializationUnitType>&& MU
llvm::orc::ResourceTrackerSP RT = nullptr

llvm::Error defineImpl(
    llvm::orc::MaterializationUnit& MU)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1243

Parameters

llvm::orc::MaterializationUnit& MU

Expected<llvm::orc::SymbolFlagsMap>
defineMaterializing(
    llvm::orc::SymbolFlagsMap SymbolFlags)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1255

Parameters

llvm::orc::SymbolFlagsMap SymbolFlags

Expected<std::unique_ptr<
    MaterializationResponsibility>>
delegate(llvm::orc::MaterializationResponsibility&
             FromMR,
         llvm::orc::SymbolFlagsMap SymbolFlags,
         llvm::orc::SymbolStringPtr InitSymbol)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1261

Parameters

llvm::orc::MaterializationResponsibility& FromMR
llvm::orc::SymbolFlagsMap SymbolFlags
llvm::orc::SymbolStringPtr InitSymbol

void detachQueryHelper(
    llvm::orc::AsynchronousSymbolQuery& Q,
    const llvm::orc::SymbolNameSet& QuerySymbols)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1248

Parameters

llvm::orc::AsynchronousSymbolQuery& Q
const llvm::orc::SymbolNameSet& QuerySymbols

void dump(llvm::raw_ostream& OS)

Description

Dump current JITDylib state to OS. It is legal to call this method on a defunct JITDylib.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:971

Parameters

llvm::raw_ostream& OS

llvm::Error emit(
    llvm::orc::MaterializationResponsibility& MR,
    const llvm::orc::SymbolFlagsMap& Emitted)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1271

Parameters

llvm::orc::MaterializationResponsibility& MR
const llvm::orc::SymbolFlagsMap& Emitted

static std::pair<
    AsynchronousSymbolQuerySet,
    std::shared_ptr<SymbolDependenceMap>>
failSymbols(
    llvm::orc::JITDylib::FailedSymbolsWorklist)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1280

Parameters

llvm::orc::JITDylib::FailedSymbolsWorklist

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1125

Parameters

ArrayRef<llvm::orc::JITDylibSP> JDs

Expected<std::vector<JITDylibSP>>
getDFSLinkOrder()

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1141

llvm::orc::ResourceTrackerSP
getDefaultResourceTracker()

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:989

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:966

llvm::orc::SymbolNameSet getRequestedSymbols(
    const llvm::orc::SymbolFlagsMap& SymbolFlags)
    const

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1264

Parameters

const llvm::orc::SymbolFlagsMap& SymbolFlags

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1134

Parameters

ArrayRef<llvm::orc::JITDylibSP> JDs

Expected<std::vector<JITDylibSP>>
getReverseDFSLinkOrder()

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1148

void installMaterializationUnit(
    std::unique_ptr<MaterializationUnit> MU,
    llvm::orc::ResourceTracker& RT)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1245

Parameters

std::unique_ptr<MaterializationUnit> MU
llvm::orc::ResourceTracker& RT

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1116

Parameters

const llvm::orc::SymbolNameSet& Names

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1065

Parameters

llvm::orc::JITDylib& JD

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1016

Parameters

llvm::orc::DefinitionGenerator& G

std::pair<AsynchronousSymbolQuerySet,
          std::shared_ptr<SymbolDependenceMap>>
removeTracker(llvm::orc::ResourceTracker& RT)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1239

Parameters

llvm::orc::ResourceTracker& RT

llvm::Error replace(
    llvm::orc::MaterializationResponsibility&
        FromMR,
    std::unique_ptr<MaterializationUnit> MU)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1257

Parameters

llvm::orc::MaterializationResponsibility& FromMR
std::unique_ptr<MaterializationUnit> MU

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1056

Parameters

llvm::orc::JITDylib& OldJD
llvm::orc::JITDylib& NewJD
llvm::orc::JITDylibLookupFlags JDLookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly

llvm::Error resolve(
    llvm::orc::MaterializationResponsibility& MR,
    const llvm::orc::SymbolMap& Resolved)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1269

Parameters

llvm::orc::MaterializationResponsibility& MR
const llvm::orc::SymbolMap& Resolved

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1039

Parameters

llvm::orc::JITDylibSearchOrder NewSearchOrder
bool LinkAgainstThisJITDylibFirst = true

void transferEmittedNodeDependencies(
    llvm::orc::JITDylib::MaterializingInfo&
        DependantMI,
    const llvm::orc::SymbolStringPtr&
        DependantName,
    llvm::orc::JITDylib::MaterializingInfo&
        EmittedMI)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1251

Parameters

llvm::orc::JITDylib::MaterializingInfo& DependantMI
const llvm::orc::SymbolStringPtr& DependantName
llvm::orc::JITDylib::MaterializingInfo& EmittedMI

void transferTracker(
    llvm::orc::ResourceTracker& DstRT,
    llvm::orc::ResourceTracker& SrcRT)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1241

Parameters

llvm::orc::ResourceTracker& DstRT
llvm::orc::ResourceTracker& SrcRT

void unlinkMaterializationResponsibility(
    llvm::orc::MaterializationResponsibility& MR)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1273

Parameters

llvm::orc::MaterializationResponsibility& MR

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:1072

Templates

Func

Parameters

Func&& F

~JITDylib()

Declared at: llvm/include/llvm/ExecutionEngine/Orc/Core.h:958