17#ifndef LLVM_EXECUTIONENGINE_ORC_RTBRIDGE_PROXY_H
18#define LLVM_EXECUTIONENGINE_ORC_RTBRIDGE_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!")
Represent a constant reference to an array (0 or more elements consecutively in memory),...
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.
Proxy< void(ArrayRef< tpctypes::PointerWrite >)> MemWritePointersProxy
ProxyInit< FnT > proxyInit(Proxy< FnT > *P, typename Proxy< FnT >::DispatchFn Dispatch, StringRef Name, SymbolLookupFlags LookupFlags=SymbolLookupFlags::RequiredSymbol)
Proxy< std::vector< ExecutorAddr >(ArrayRef< ExecutorAddr >)> MemReadPointersProxy
Proxy< std::vector< uint8_t >(ArrayRef< ExecutorAddr >)> MemReadUInt8sProxy
Proxy< std::vector< uint32_t >(ArrayRef< ExecutorAddr >)> MemReadUInt32sProxy
Proxy< void(ExecutorAddr)> CallVoidVoidProxy
Runtime-agnostic interface for running a void() function in the executor.
Proxy< int32_t(ExecutorAddr, int32_t)> CallInt32Int32Proxy
Runtime-agnostic interface for running an int32_t(int32_t) function in the executor.
Proxy< std::vector< uint64_t >(ArrayRef< ExecutorAddr >)> MemReadUInt64sProxy
Proxy< std::vector< std::vector< uint8_t > >(ArrayRef< ExecutorAddrRange >)> MemReadBuffersProxy
Proxy< int32_t(ExecutorAddr)> CallInt32VoidProxy
Runtime-agnostic interface for running an int32_t() function in the executor.
Proxy< std::vector< std::string >(ArrayRef< ExecutorAddr >)> MemReadStringsProxy
Error buildProxies(JITDylib &JD)
buildProxies base case.
Proxy< void(ArrayRef< tpctypes::UInt64Write >)> MemWriteUInt64sProxy
Proxy< int64_t(ExecutorAddr, ArrayRef< std::string >)> CallMainProxy
Runtime-agnostic interface for running a main-like function (int(int argc, char *argv[])) in the exec...
Proxy< void(ArrayRef< tpctypes::UInt8Write >)> MemWriteUInt8sProxy
Runtime-agnostic interfaces for the memory-access operations.
Proxy< void(ArrayRef< tpctypes::UInt16Write >)> MemWriteUInt16sProxy
Proxy< std::vector< uint16_t >(ArrayRef< ExecutorAddr >)> MemReadUInt16sProxy
Proxy< void(ArrayRef< tpctypes::UInt32Write >)> MemWriteUInt32sProxy
Proxy< void(ArrayRef< tpctypes::BufferWrite >)> MemWriteBuffersProxy
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...