22#ifndef LLVM_EXECUTIONENGINE_ORC_PROXY_H
23#define LLVM_EXECUTIONENGINE_ORC_PROXY_H
45 explicit operator bool()
const {
return !!CalleeAddr; }
51template <
typename FnT>
class Proxy;
79 using type = std::promise<MSVCPError>;
82 using type = std::promise<MSVCPExpected<T>>;
96template <
typename RetT,
typename... ArgTs>
112 const ArgTs &...Args);
116 :
ProxyBase(CalleeAddr), Dispatch(Dispatch) {}
123 if (!CalleeSyms->empty())
124 return Proxy(Dispatch, CalleeSyms->begin()->second.getAddress());
128 return CalleeSyms.takeError();
140 assert(Dispatch &&
"Proxy's Dispatch member is not set");
148 auto F =
P.get_future();
150 [
P = std::move(
P)](
ErrorRetT R)
mutable {
P.set_value(std::move(R)); },
166template <
typename FnT>
174template <
typename ProxySpecT,
typename FnT>
178 return {
P, ProxySpecT::dispatch, ProxySpecT::Name, LookupFlags};
181template <
typename ProxySpecT,
typename FnT>
185 return {
P, ProxySpecT::dispatch, Name, LookupFlags};
192template <
typename... FnTs>
198template <
typename FnT,
typename... FnTs>
202 *PI.
P = std::move(*POrErr);
204 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.
const ExecutorAddr & calleeAddr() const
Returns the address of the callee in the executor.
ProxyBase(ExecutorAddr CalleeAddr)
void(*)(unique_function< void(ErrorRetT)> OnComplete, ExecutionSession &ES, ExecutorAddr Callee, const ArgTs &...Args) DispatchFn
ErrorRetT operator()(ExecutionSession &ES, const ArgTs &...Args) const
Invoke the operation with the given Args, blocking until its result (or an error) is available.
Proxy(DispatchFn Dispatch, ExecutorAddr CalleeAddr)
static Expected< Proxy > Create(DispatchFn Dispatch, JITDylib &JD, StringRef Name, SymbolLookupFlags LF)
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...
static Expected< Proxy > Create(DispatchFn Dispatch, ExecutionSession &ES, StringRef Name, SymbolLookupFlags LF)
RetT CalleeRetT
The result type produced by the executor-side function itself.
typename detail::ProxyErrorRet< RetT >::type ErrorRetT
The result type delivered to the client: Error when the callee returns void or Error,...
A set of symbols to look up, each associated with a SymbolLookupFlags value.
unique_function is a type-erasing functor similar to std::function.
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...
ProxyInit< FnT > proxyInit(Proxy< FnT > *P, typename Proxy< FnT >::DispatchFn Dispatch, StringRef Name, SymbolLookupFlags LookupFlags=SymbolLookupFlags::RequiredSymbol)
SymbolLookupFlags
Lookup flags that apply to each symbol in a lookup.
Error buildProxies(JITDylib &JD)
buildProxies base case.
Proxy< FnT >::DispatchFn Dispatch
SymbolLookupFlags LookupFlags
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...