21#ifndef LLVM_EXECUTIONENGINE_ORC_RTBRIDGE_PROXY_H
22#define LLVM_EXECUTIONENGINE_ORC_RTBRIDGE_PROXY_H
44 explicit operator bool()
const {
return !!CalleeAddr; }
50template <
typename FnT>
class Proxy;
78 using type = std::promise<MSVCPError>;
81 using type = std::promise<MSVCPExpected<T>>;
95template <
typename RetT,
typename... ArgTs>
111 const ArgTs &...Args);
115 :
ProxyBase(CalleeAddr), Dispatch(Dispatch) {}
122 if (!CalleeSyms->empty())
123 return Proxy(Dispatch, CalleeSyms->begin()->second.getAddress());
127 return CalleeSyms.takeError();
139 assert(Dispatch &&
"Proxy's Dispatch member is not set");
147 auto F =
P.get_future();
149 [
P = std::move(
P)](
ErrorRetT R)
mutable {
P.set_value(std::move(R)); },
165template <
typename FnT>
173template <
typename ProxySpecT,
typename FnT>
177 return {
P, ProxySpecT::dispatch, ProxySpecT::Name, LookupFlags};
180template <
typename ProxySpecT,
typename FnT>
184 return {
P, ProxySpecT::dispatch, Name, LookupFlags};
191template <
typename... FnTs>
197template <
typename FnT,
typename... FnTs>
201 *PI.
P = std::move(*POrErr);
203 return POrErr.takeError();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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.
Represent a constant reference to a string, i.e.
An ExecutionSession represents a running JIT program.
JITDylib & getBootstrapJITDylib()
Returns a reference to the bootstrap JITDylib.
Represents an address in the executor process.
Represents a JIT'd dynamic library.
ExecutionSession & getExecutionSession() const
Get a reference to the ExecutionSession for this JITDylib.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
ProxyBase(ExecutorAddr CalleeAddr)
const ExecutorAddr & calleeAddr() const
Returns the address of the callee in the executor.
static Expected< Proxy > Create(DispatchFn Dispatch, ExecutionSession &ES, StringRef Name, SymbolLookupFlags LF)
void(*)(unique_function< void(ErrorRetT)> OnComplete, ExecutionSession &ES, ExecutorAddr Callee, const ArgTs &...Args) DispatchFn
Proxy(DispatchFn Dispatch, ExecutorAddr CalleeAddr)
ErrorRetT operator()(ExecutionSession &ES, const ArgTs &...Args) const
Invoke the operation with the given Args, blocking until its result (or an error) is available.
static Expected< Proxy > Create(DispatchFn Dispatch, JITDylib &JD, StringRef Name, SymbolLookupFlags LF)
typename detail::ProxyErrorRet< RetT >::type ErrorRetT
The result type delivered to the client: Error when the callee returns void or Error,...
void operator()(unique_function< void(ErrorRetT)> OnComplete, ExecutionSession &ES, const ArgTs &...Args) const
Asynchronously invoke the operation with the given Args, delivering its result (or an error) to OnCom...
RetT CalleeRetT
The result type produced by the executor-side function itself.
unique_function is a type-erasing functor similar to std::function.
ProxyInit< FnT > proxyInit(Proxy< FnT > *P, typename Proxy< FnT >::DispatchFn Dispatch, StringRef Name, SymbolLookupFlags LookupFlags=SymbolLookupFlags::RequiredSymbol)
Error buildProxies(JITDylib &JD)
buildProxies base case.
JITDylibSearchOrder makeJITDylibSearchOrder(ArrayRef< JITDylib * > JDs, JITDylibLookupFlags Flags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same fla...
SymbolLookupFlags
Lookup flags that apply to each symbol in a lookup.
SymbolLookupFlags LookupFlags
Proxy< FnT >::DispatchFn Dispatch
Maps a proxy's callee return type to the type delivered to the client, so a dispatch failure can alwa...
std::promise< MSVCPError > type
std::promise< MSVCPExpected< T > > type
Maps a proxy's client-facing return type to the std::promise value type used by the blocking call ope...