LLVM 22.0.0git
CallSPSViaEPC.h
Go to the documentation of this file.
1//===---- CallSPSViaEPC.h - EPCCalls using SPS serialization ----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// EPCCalls using SimplePackedSerialization.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_CALLSPSVIAEPC_H
14#define LLVM_EXECUTIONENGINE_ORC_CALLSPSVIAEPC_H
15
19
20namespace llvm::orc {
21
22namespace detail {
23template <typename SPSRetT, typename... SPSArgTs>
27
28 template <typename... ArgTs>
31 ArgSerialization::size(Args...));
32 shared::SPSOutputBuffer OB(Buffer.data(), Buffer.size());
33 if (!ArgSerialization::serialize(OB, Args...))
34 return make_error<StringError>("Could not serialize arguments",
36 return std::move(Buffer);
37 }
38};
39
40template <typename SPSSig>
42 : public CallableTraitsHelper<detail::SPSCallSerializationImpl, SPSSig> {};
43
44} // namespace detail
45
46/// SPS serialization for non-void calls.
47template <typename SPSSig>
49
50 template <typename RetT>
52 using RetDeserialization =
54 shared::SPSInputBuffer IB(ResultBytes.data(), ResultBytes.size());
55 RetT ReturnValue;
56 if (!RetDeserialization::deserialize(IB, ReturnValue))
57 return make_error<StringError>("Could not deserialize return value",
59 return ReturnValue;
60 }
61};
62
63/// SPS serialization for void calls.
64template <typename... SPSArgTs>
65struct SPSCallSerializer<void(SPSArgTs...)>
66 : public detail::SPSCallSerialization<void(SPSArgTs...)> {
67 template <typename RetT>
68 std::enable_if_t<std::is_void_v<RetT>, Error>
70 if (!ResultBytes.empty())
71 return make_error<StringError>("Could not deserialize return value",
73 return Error::success();
74 }
75};
76
77template <typename SPSSig>
78class SPSEPCCaller : public EPCCaller<SPSCallSerializer<SPSSig>> {
79public:
83};
84
85template <typename SPSSig>
86class SPSEPCCall : public EPCCall<SPSCallSerializer<SPSSig>> {
87public:
91};
92
93} // namespace llvm::orc
94
95#endif // LLVM_EXECUTIONENGINE_ORC_CALLSPSVIAEPC_H
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Tagged union holding either a T or a Error.
Definition Error.h:485
EPCCall(ExecutorProcessControl &EPC, SPSCallSerializer< SPSSig > &&S, ExecutorSymbolDef Fn)
Definition CallViaEPC.h:130
EPCCaller(ExecutorProcessControl &EPC, SPSCallSerializer< SPSSig > &&S)
Definition CallViaEPC.h:104
ExecutorProcessControl supports interaction with a JIT target process.
Represents a defining location for a JIT symbol.
SPSEPCCall(ExecutorProcessControl &EPC, ExecutorSymbolDef Fn)
SPSEPCCaller(ExecutorProcessControl &EPC)
A utility class for serializing to a blob from a variadic list.
Input char buffer with underflow check.
Output char buffer with overflow check.
C++ wrapper function result: Same as CWrapperFunctionResult but auto-releases memory.
static WrapperFunctionResult allocate(size_t Size)
Create a WrapperFunctionResult with the given size and return a pointer to the underlying memory.
bool empty() const
Returns true if this value is equivalent to a default-constructed WrapperFunctionResult.
size_t size() const
Returns the size of the data contained in this instance.
char * data()
Get a pointer to the data contained in this instance.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:98
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1867
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:867
CallableTraitsHelper takes an implementation class template Impl and some callable type C and passes ...
std::enable_if_t< std::is_void_v< RetT >, Error > deserialize(shared::WrapperFunctionResult ResultBytes)
SPS serialization for non-void calls.
Expected< RetT > deserialize(shared::WrapperFunctionResult ResultBytes)
shared::SPSArgList< SPSArgTs... > ArgSerialization
Expected< shared::WrapperFunctionResult > serialize(ArgTs &&...Args)
shared::SPSArgList< SPSRetT > RetSerialization