13#ifndef LLVM_EXECUTIONENGINE_ORC_SIMPLEREMOTEEPC_H
14#define LLVM_EXECUTIONENGINE_ORC_SIMPLEREMOTEEPC_H
49 template <
typename TransportT,
typename... TransportTCtorArgTs>
52 TransportTCtorArgTs &&...TransportTCtorArgs) {
53 std::unique_ptr<SimpleRemoteEPC> SREPC(
56 auto T = TransportT::Create(
57 *SREPC, std::forward<TransportTCtorArgTs>(TransportTCtorArgs)...);
60 SREPC->T = std::move(*
T);
61 if (
auto Err = SREPC->setup(std::move(S)))
62 return joinErrors(std::move(Err), SREPC->disconnect());
63 return std::move(SREPC);
98 std::unique_ptr<TaskDispatcher>
D)
111 Error setup(Setup S);
119 uint64_t getNextSeqNo() {
return NextSeqNo++; }
120 void releaseSeqNo(
uint64_t SeqNo) {}
122 using PendingCallWrapperResultsMap =
123 DenseMap<uint64_t, IncomingWFRHandler>;
125 std::mutex SimpleRemoteEPCMutex;
126 std::condition_variable DisconnectCV;
127 bool Disconnected =
false;
130 std::unique_ptr<SimpleRemoteEPCTransport>
T;
131 std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
132 std::unique_ptr<MemoryAccess> OwnedMemAccess;
134 std::unique_ptr<EPCGenericDylibManager> DylibMgr;
135 ExecutorAddr RunAsMainAddr;
136 ExecutorAddr RunAsVoidFunctionAddr;
137 ExecutorAddr RunAsIntFunctionAddr;
140 PendingCallWrapperResultsMap PendingCallWrapperResults;
This file defines the DenseMap class.
ArrayRef - 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.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represents an address in the executor process.
A handler or incoming WrapperFunctionResults – either return values from callWrapper* calls,...
ExecutorProcessControl supports interaction with a JIT target process.
std::unique_ptr< TaskDispatcher > D
std::shared_ptr< SymbolStringPool > SSP
void lookupSymbolsAsync(ArrayRef< LookupRequest > Request, SymbolLookupCompleteFn F) override
Search for symbols in the target process.
void handleDisconnect(Error Err) override
Handle a disconnection from the underlying transport.
SimpleRemoteEPC & operator=(const SimpleRemoteEPC &)=delete
Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.
static Expected< std::unique_ptr< SimpleRemoteEPC > > Create(std::unique_ptr< TaskDispatcher > D, Setup S, TransportTCtorArgTs &&...TransportTCtorArgs)
Create a SimpleRemoteEPC using the given transport type and args.
Expected< HandleMessageAction > handleMessage(SimpleRemoteEPCOpcode OpC, uint64_t SeqNo, ExecutorAddr TagAddr, SimpleRemoteEPCArgBytesVector ArgBytes) override
Handle receipt of a message.
SimpleRemoteEPC(const SimpleRemoteEPC &)=delete
Error disconnect() override
Disconnect from the target process.
Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath) override
Load the dynamic library at the given path and return a handle to it.
Expected< int32_t > runAsVoidFunction(ExecutorAddr VoidFnAddr) override
Run function with a int (*)(void) signature.
SimpleRemoteEPC(SimpleRemoteEPC &&)=delete
SimpleRemoteEPC & operator=(SimpleRemoteEPC &&)=delete
void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) override
Run a wrapper function in the executor.
Expected< int32_t > runAsIntFunction(ExecutorAddr IntFnAddr, int Arg) override
Run function with a int (*)(int) signature.
unique_function is a type-erasing functor similar to std::function.
This is an optimization pass for GlobalISel generic memory operations.
Error joinErrors(Error E1, Error E2)
Concatenate errors.
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.
A setup object containing callbacks to construct a memory manager and memory access object.
Expected< std::unique_ptr< jitlink::JITLinkMemoryManager > >(SimpleRemoteEPC &) CreateMemoryManagerFn
unique_function< CreateMemoryManagerFn > CreateMemoryManager
unique_function< CreateMemoryAccessFn > CreateMemoryAccess