14#ifndef LLVM_EXECUTIONENGINE_ORC_CALLVIAEPC_H
15#define LLVM_EXECUTIONENGINE_ORC_CALLVIAEPC_H
50 static_assert(std::tuple_size_v<ArgsTuple> == 1,
51 "Handler must take exactly one argument");
54 std::remove_cv_t<std::remove_reference_t<HandlerArgT>>>::value_type;
60template <
typename HandlerFn,
typename Serializer,
typename... ArgTs>
61std::enable_if_t<std::is_invocable_v<HandlerFn, Error>>
66 if (
auto ArgBytes = S.serialize(std::forward<ArgTs>(Args)...))
69 [S = std::move(S),
H = std::forward<HandlerFn>(
H)](
71 if (const char *ErrMsg = R.getOutOfBandError())
72 H(make_error<StringError>(ErrMsg, inconvertibleErrorCode()));
74 H(S.template deserialize<RetT>(std::move(R)));
76 {ArgBytes->data(), ArgBytes->size()});
78 H(ArgBytes.takeError());
88template <
typename PromiseT,
typename Serializer,
typename... ArgTs>
89std::enable_if_t<!std::is_invocable_v<PromiseT, Error>,
90 decltype(std::declval<PromiseT>().get_future().get())>
93 auto F =
P.get_future();
94 using RetT =
decltype(
F.get());
95 callViaEPC([
P = std::move(
P)](RetT R)
mutable {
P.set_value(std::move(R)); },
96 EPC, std::move(S), std::move(Fn), std::forward<ArgTs>(Args)...);
114 template <
typename PromiseOrHandlerT,
typename... ArgTs>
117 return callViaEPC(std::forward<PromiseOrHandlerT>(R), EPC, S, Fn,
118 std::forward<ArgTs>(Args)...);
140 template <
typename PromiseOrHandlerT,
typename... ArgTs>
141 decltype(
auto)
operator()(PromiseOrHandlerT &&R, ArgTs &&...Args) {
142 return Caller(std::forward<PromiseOrHandlerT>(R), Fn,
143 std::forward<ArgTs>(Args)...);
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
EPCCall(ExecutorProcessControl &EPC, Serializer &&S, ExecutorSymbolDef Fn)
decltype(auto) operator()(PromiseOrHandlerT &&R, ArgTs &&...Args)
Encapsulates calls via EPC to any function that's compatible with the given serialization scheme.
decltype(auto) operator()(PromiseOrHandlerT &&R, ExecutorSymbolDef Fn, ArgTs &&...Args)
EPCCaller(ExecutorProcessControl &EPC, Serializer &&S)
ExecutorProcessControl supports interaction with a JIT target process.
virtual void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer)=0
Run a wrapper function in the executor.
Represents a defining location for a JIT symbol.
const ExecutorAddr & getAddress() const
C++ wrapper function result: Same as CWrapperFunctionResult but auto-releases memory.
std::enable_if_t< std::is_invocable_v< HandlerFn, Error > > callViaEPC(HandlerFn &&H, ExecutorProcessControl &EPC, Serializer S, ExecutorSymbolDef Fn, ArgTs &&...Args)
Call a wrapper function via EPC asynchronously.
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.
CallableArgInfo provides typedefs for the return type and argument types (as a tuple) of the given ca...
typename CallViaEPCRetValueTraits< std::remove_cv_t< std::remove_reference_t< HandlerArgT > > >::value_type RetT
std::tuple_element_t< 0, ArgsTuple > HandlerArgT
CallableArgInfo< HandlerT > ArgInfo
typename ArgInfo::ArgsTupleType ArgsTuple