16#ifndef LLVM_EXECUTIONENGINE_ORC_LAZYREEXPORTS_H
17#define LLVM_EXECUTIONENGINE_ORC_LAZYREEXPORTS_H
77 using ReexportsMap = std::map<ExecutorAddr, ReexportsEntry>;
79 using NotifiersMap = std::map<ExecutorAddr, NotifyResolvedFunction>;
85 ReexportsMap Reexports;
86 NotifiersMap Notifiers;
98 template <
typename ORCABI>
Error init() {
102 NotifyLandingResolved) {
104 std::move(NotifyLandingResolved));
108 return TP.takeError();
110 this->TP = std::move(*TP);
115 std::unique_ptr<TrampolinePool> TP;
120 template <
typename ORCABI>
123 auto LLCTM = std::unique_ptr<LocalLazyCallThroughManager>(
126 if (
auto Err = LLCTM->init<ORCABI>())
127 return std::move(Err);
129 return std::move(LLCTM);
137 ExecutorAddr ErrorHandlerAddr);
155 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override;
170inline std::unique_ptr<LazyReexportsMaterializationUnit>
175 return std::make_unique<LazyReexportsMaterializationUnit>(
176 LCTManager, RSManager, SourceJD, std::move(CallableAliases), SrcJDLoc);
181 friend std::unique_ptr<MaterializationUnit>
217 Expected<std::vector<ExecutorSymbolDef>> EntryAddrs)>;
246 std::unique_ptr<MaterializationUnit>
249 void emitReentryTrampolines(std::unique_ptr<MaterializationResponsibility> MR,
251 void emitRedirectableSymbols(
252 std::unique_ptr<MaterializationResponsibility> MR,
254 Expected<std::vector<ExecutorSymbolDef>> ReentryPoints);
269inline std::unique_ptr<MaterializationUnit>
271 return LRM.createLazyReexports(std::move(Reexports));
280 static std::shared_ptr<SimpleLazyReexportsSpeculator>
285 RecordExecutionFunction RecordExec)
290 std::make_shared<make_shared_helper>(ES, std::move(RecordExec));
291 Instance->WeakThis = Instance;
310 void addSpeculationSuggestions(
311 std::vector<std::pair<std::string, SymbolStringPtr>> NewSuggestions);
316 : ES(ES), RecordExec(
std::
move(RecordExec)) {}
318 bool doNextSpeculativeLookup();
322 using KeyToFunctionBodiesMap =
326 RecordExecutionFunction RecordExec;
327 std::weak_ptr<SimpleLazyReexportsSpeculator> WeakThis;
329 std::deque<std::pair<std::string, SymbolStringPtr>> SpeculateSuggestions;
330 bool SpeculateTaskActive =
false;
static StringRef getName(Value *V)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
An ExecutionSession represents a running JIT program.
Represents an address in the executor process.
Represents a JIT'd dynamic library.
Manages a set of 'lazy call-through' trampolines.
LLVM_ABI ExecutorAddr reportCallThroughError(Error Err)
LLVM_ABI Expected< ReexportsEntry > findReexport(ExecutorAddr TrampolineAddr)
LLVM_ABI Error notifyResolved(ExecutorAddr TrampolineAddr, ExecutorAddr ResolvedAddr)
void setTrampolinePool(TrampolinePool &TP)
LLVM_ABI void resolveTrampolineLandingAddress(ExecutorAddr TrampolineAddr, TrampolinePool::NotifyLandingResolvedFunction NotifyLandingResolved)
virtual ~LazyCallThroughManager()=default
LLVM_ABI Expected< ExecutorAddr > getCallThroughTrampoline(JITDylib &SourceJD, SymbolStringPtr SymbolName, NotifyResolvedFunction NotifyResolved)
virtual void onLazyReexportCalled(const CallThroughInfo &CTI)=0
Called outside the session lock when a lazy reexport is called.
virtual void onLazyReexportsCreated(JITDylib &JD, ResourceKey K, const SymbolAliasMap &Reexports)=0
Called under the session lock when new lazy reexports are created.
virtual Error onLazyReexportsRemoved(JITDylib &JD, ResourceKey K)=0
Called under the session lock when lazy reexports are removed.
virtual void onLazyReexportsTransfered(JITDylib &JD, ResourceKey DstK, ResourceKey SrcK)=0
Called under the session lock when lazy reexports have their ownership transferred to a new ResourceK...
LazyReexportsManager & operator=(LazyReexportsManager &&)=delete
LazyReexportsManager(LazyReexportsManager &&)=delete
A materialization unit that builds lazy re-exports.
A lazy call-through manager that builds trampolines in the current process.
static Expected< std::unique_ptr< LocalLazyCallThroughManager > > Create(ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr)
Create a LocalLazyCallThroughManager using the given ABI.
static Expected< std::unique_ptr< LocalTrampolinePool > > Create(ResolveLandingFunction ResolveLanding)
Creates a LocalTrampolinePool with the given RunCallback function.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Base class for managing redirectable symbols in which a call gets redirected to another symbol in run...
Listens for ResourceTracker operations.
static std::shared_ptr< SimpleLazyReexportsSpeculator > Create(ExecutionSession &ES, RecordExecutionFunction RecordExec={})
SimpleLazyReexportsSpeculator(SimpleLazyReexportsSpeculator &&)=delete
SimpleLazyReexportsSpeculator & operator=(SimpleLazyReexportsSpeculator &&)=delete
Pointer to a pooled string representing a symbol name.
Base class for pools of compiler re-entry trampolines.
unique_function< void(ExecutorAddr) const > NotifyLandingResolvedFunction
unique_function is a type-erasing functor similar to std::function.
LLVM_ABI Expected< std::unique_ptr< LazyCallThroughManager > > createLocalLazyCallThroughManager(const Triple &T, ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr)
Create a LocalLazyCallThroughManager from the given triple and execution session.
std::unique_ptr< LazyReexportsMaterializationUnit > lazyReexports(LazyCallThroughManager &LCTManager, RedirectableSymbolManager &RSManager, JITDylib &SourceJD, SymbolAliasMap CallableAliases, ImplSymbolMap *SrcJDLoc=nullptr)
Define lazy-reexports based on the given SymbolAliasMap.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
SymbolStringPtr SymbolName