13#ifndef LLVM_EXECUTIONENGINE_ORC_SIMPLEREMOTEEPC_H
14#define LLVM_EXECUTIONENGINE_ORC_SIMPLEREMOTEEPC_H
33 template <
typename TransportT,
typename... TransportTCtorArgTs>
36 TransportTCtorArgTs &&...TransportTCtorArgs) {
37 std::unique_ptr<SimpleRemoteEPC> SREPC(
40 auto T = TransportT::Create(
41 *SREPC, std::forward<TransportTCtorArgTs>(TransportTCtorArgs)...);
44 SREPC->T = std::move(*T);
45 if (
auto Err = SREPC->setup())
46 return joinErrors(std::move(Err), SREPC->disconnect());
47 return std::move(SREPC);
84 std::unique_ptr<TaskDispatcher>
D)
103 uint64_t getNextSeqNo() {
return NextSeqNo++; }
104 void releaseSeqNo(
uint64_t SeqNo) {}
106 using PendingCallWrapperResultsMap =
107 DenseMap<uint64_t, IncomingWFRHandler>;
109 std::mutex SimpleRemoteEPCMutex;
110 std::condition_variable DisconnectCV;
111 bool Disconnected =
false;
112 Error DisconnectErr = Error::success();
114 std::unique_ptr<SimpleRemoteEPCTransport>
T;
116 ExecutorAddr RunAsMainAddr;
117 ExecutorAddr RunAsVoidFunctionAddr;
118 ExecutorAddr RunAsIntFunctionAddr;
121 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.
Tagged union holding either a T or a Error.
Represents an address in the executor process.
A handler or incoming WrapperFunctionBuffers – either return values from callWrapper* calls,...
std::unique_ptr< TaskDispatcher > D
std::shared_ptr< SymbolStringPool > SSP
ExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D)
void handleDisconnect(Error Err) override
Handle a disconnection from the underlying transport.
SimpleRemoteEPC & operator=(const SimpleRemoteEPC &)=delete
Expected< std::unique_ptr< MemoryAccess > > createDefaultMemoryAccess() override
Create a default MemoryAccess for the target process.
Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.
Expected< std::unique_ptr< jitlink::JITLinkMemoryManager > > createDefaultMemoryManager() override
Create a default JITLinkMemoryManager for the target process.
SimpleRemoteEPC(const SimpleRemoteEPC &)=delete
static Expected< std::unique_ptr< SimpleRemoteEPC > > Create(std::unique_ptr< TaskDispatcher > D, TransportTCtorArgTs &&...TransportTCtorArgs)
Create a SimpleRemoteEPC using the given transport type and args.
Expected< HandleMessageAction > handleMessage(SimpleRemoteEPCOpcode OpC, uint64_t SeqNo, ExecutorAddr TagAddr, shared::WrapperFunctionBuffer ArgBytes) override
Handle receipt of a message.
Expected< std::unique_ptr< DylibManager > > createDefaultDylibMgr() override
Create a default DylibManager for the target process.
Error disconnect() override
Disconnect from the target process.
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.
C++ wrapper function buffer: Same as CWrapperFunctionBuffer but auto-releases memory.
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.