LLVM  8.0.1
Classes | Public Types | 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"

Public Types

using GeneratorFunction = std::function< SymbolNameSet(JITDylib &Parent, const SymbolNameSet &Names)>
 
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...
 
void setGenerator (GeneratorFunction DefGenerator)
 Set a definition generator. More...
 
void setSearchOrder (JITDylibSearchList NewSearchOrder, bool SearchThisJITDylibFirst=true, bool MatchNonExportedInThisDylib=true)
 Set the search order to be used when fixing up definitions in JITDylib. More...
 
void addToSearchOrder (JITDylib &JD, bool MatcNonExported=false)
 Add the given JITDylib to the search order for definitions in this JITDylib. More...
 
void replaceInSearchOrder (JITDylib &OldJD, JITDylib &NewJD, bool MatchNonExported=false)
 Replace OldJD with NewJD in the search order if OldJD is present. More...
 
void removeFromSearchOrder (JITDylib &JD)
 Remove the given JITDylib from the search order for this JITDylib if it is present. More...
 
template<typename Func >
auto withSearchOrderDo (Func &&F) -> decltype(F(std::declval< const JITDylibSearchList &>()))
 Do something with the search order (run under the session lock). More...
 
template<typename MaterializationUnitType >
Error define (std::unique_ptr< MaterializationUnitType > &&MU)
 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)
 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...
 
SymbolFlagsMap lookupFlags (const SymbolNameSet &Names)
 Search the given JITDylib for the symbols in Symbols. More...
 
void dump (raw_ostream &OS)
 Dump current JITDylib state to OS. More...
 
SymbolNameSet legacyLookup (std::shared_ptr< AsynchronousSymbolQuery > Q, SymbolNameSet Names)
 FIXME: Remove this when we remove the old ORC layers. More...
 

Friends

class AsynchronousSymbolQuery
 
class ExecutionSession
 
class MaterializationResponsibility
 

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 496 of file Core.h.

Member Typedef Documentation

◆ AsynchronousSymbolQuerySet

Definition at line 505 of file Core.h.

◆ GeneratorFunction

Definition at line 502 of file Core.h.

Constructor & Destructor Documentation

◆ JITDylib() [1/2]

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

Referenced by dump().

◆ JITDylib() [2/2]

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

Member Function Documentation

◆ addToSearchOrder()

void llvm::orc::JITDylib::addToSearchOrder ( JITDylib JD,
bool  MatcNonExported = false 
)

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

Definition at line 1062 of file Core.cpp.

◆ define() [1/2]

template<typename MaterializationUnitType >
Error llvm::orc::JITDylib::define ( std::unique_ptr< MaterializationUnitType > &&  MU)

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

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

defineImpl succeeded.

Definition at line 881 of file Core.h.

References assert().

Referenced by llvm::orc::IRLayer::add(), llvm::orc::ObjectLayer::add(), llvm::orc::LocalCXXRuntimeOverrides::enable(), llvm::orc::DynamicLibrarySearchGenerator::operator()(), and llvm::orc::ReexportsGenerator::operator()().

◆ define() [2/2]

template<typename MaterializationUnitType >
Error llvm::orc::JITDylib::define ( std::unique_ptr< MaterializationUnitType > &  MU)

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.

defineImpl succeeded.

Definition at line 897 of file Core.h.

References assert().

◆ dump()

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

◆ getExecutionSession()

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

◆ getName()

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

◆ legacyLookup()

SymbolNameSet llvm::orc::JITDylib::legacyLookup ( std::shared_ptr< AsynchronousSymbolQuery Q,
SymbolNameSet  Names 
)

FIXME: Remove this when we remove the old ORC layers.

Search the given JITDylibs in order for the symbols in Symbols. Results (once they become available) will be returned via the given Query.

If any symbol is not found then the unresolved symbols will be returned, and the query will not be applied. The Query is not failed and can be re-used in a subsequent lookup once the symbols have been added, or manually failed.

Definition at line 1269 of file Core.cpp.

References assert(), D, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::Lock, llvm::JITSymbolFlags::Materializing, MI, Name, and llvm::None.

◆ lookupFlags()

SymbolFlagsMap llvm::orc::JITDylib::lookupFlags ( const SymbolNameSet Names)

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

References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), and llvm::Error::success().

◆ removeFromSearchOrder()

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

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

Otherwise this operation is a no-op.

Definition at line 1081 of file Core.cpp.

References llvm::find_if(), and I.

◆ replaceInSearchOrder()

void llvm::orc::JITDylib::replaceInSearchOrder ( JITDylib OldJD,
JITDylib NewJD,
bool  MatchNonExported = false 
)

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

Otherwise this operation is a no-op.

Definition at line 1068 of file Core.cpp.

References llvm::find_if(), and I.

◆ setGenerator()

void llvm::orc::JITDylib::setGenerator ( GeneratorFunction  DefGenerator)
inline

Set a definition generator.

If set, whenever a symbol fails to resolve within this JITDylib, lookup and lookupFlags will pass the unresolved symbols set to the definition generator. The generator can optionally add a definition for the unresolved symbols to the dylib.

Definition at line 522 of file Core.h.

References llvm::dump(), F(), LLVM_MARK_AS_BITMASK_ENUM, Name, llvm::None, and replace().

◆ setSearchOrder()

void llvm::orc::JITDylib::setSearchOrder ( JITDylibSearchList  NewSearchOrder,
bool  SearchThisJITDylibFirst = true,
bool  MatchNonExportedInThisDylib = true 
)

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

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

If SearchThisJITDylibFirst is set, which by default it is, then this JITDylib will add itself to the beginning of the SearchOrder (Clients should not put this JITDylib in the list in this case, to avoid redundant lookups).

If SearchThisJITDylibFirst is false then the search order will be used as given. The main 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 search 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 1052 of file Core.cpp.

◆ withSearchOrderDo()

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

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

Definition at line 875 of file Core.h.

References F().

Friends And Related Function Documentation

◆ AsynchronousSymbolQuery

friend class AsynchronousSymbolQuery
friend

Definition at line 497 of file Core.h.

◆ ExecutionSession

friend class ExecutionSession
friend

Definition at line 498 of file Core.h.

◆ MaterializationResponsibility

friend class MaterializationResponsibility
friend

Definition at line 499 of file Core.h.


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