Go to the documentation of this file.
13 #ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEREMOTEEPCSERVER_H
14 #define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEREMOTEEPCSERVER_H
18 #include "llvm/Config/llvm-config.h"
27 #include <condition_variable>
48 #if LLVM_ENABLE_THREADS
55 std::mutex DispatchMutex;
57 size_t Outstanding = 0;
58 std::condition_variable OutstandingCV;
68 std::vector<std::unique_ptr<ExecutorBootstrapService>> &
services() {
80 std::vector<std::unique_ptr<ExecutorBootstrapService>> Services;
85 template <
typename TransportT,
typename... TransportTCtorArgTs>
88 TransportTCtorArgTs &&...TransportTCtorArgs) {
89 auto Server = std::make_unique<SimpleRemoteEPCServer>();
91 if (
auto Err = SetupFunction(
S))
96 if (!Server->ReportError)
97 Server->ReportError = [](
Error Err) {
102 auto T = TransportT::Create(
103 *Server, std::forward<TransportTCtorArgTs>(TransportTCtorArgs)...);
105 return T.takeError();
107 if (
auto Err = Server->T->start())
112 Server->Services.push_back(
113 std::make_unique<rt_bootstrap::SimpleExecutorDylibManager>());
114 for (
auto &Service : Server->Services)
115 Service->addBootstrapSymbols(
S.bootstrapSymbols());
117 if (
auto Err = Server->sendSetupMessage(
std::move(
S.BootstrapSymbols)))
124 this->ReportError =
std::move(ReportError);
152 doJITDispatch(
const void *FnTag,
const char *ArgData,
size_t ArgSize);
159 uint64_t getNextSeqNo() {
return NextSeqNo++; }
162 using PendingJITDispatchResultsMap =
163 DenseMap<uint64_t, std::promise<shared::WrapperFunctionResult> *>;
165 std::mutex ServerStateMutex;
166 std::condition_variable ShutdownCV;
167 enum { ServerRunning, ServerShuttingDown, ServerShutDown } RunState;
169 std::unique_ptr<SimpleRemoteEPCTransport>
T;
170 std::unique_ptr<Dispatcher>
D;
171 std::vector<std::unique_ptr<ExecutorBootstrapService>> Services;
175 PendingJITDispatchResultsMap PendingJITDispatchResults;
176 std::vector<sys::DynamicLibrary> Dylibs;
182 #endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEREMOTEEPCSERVER_H
Represents an address in the executor process.
static StringMap< ExecutorAddr > defaultBootstrapSymbols()
This is an optimization pass for GlobalISel generic memory operations.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static ErrorSuccess success()
Create a success value.
Expected< HandleMessageAction > handleMessage(SimpleRemoteEPCOpcode OpC, uint64_t SeqNo, ExecutorAddr TagAddr, SimpleRemoteEPCArgBytesVector ArgBytes) override
Call to handle an incoming message.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Tagged union holding either a T or a Error.
void setDispatcher(std::unique_ptr< Dispatcher > D)
static Expected< std::unique_ptr< SimpleRemoteEPCServer > > Create(unique_function< Error(Setup &S)> SetupFunction, TransportTCtorArgTs &&...TransportTCtorArgs)
void setErrorReporter(unique_function< void(Error)> ReportError)
A simple EPC server implementation.
Dispatches calls to runWrapper.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
unique_function< void(Error)> ReportErrorFunction
C++ wrapper function result: Same as CWrapperFunctionResult but auto-releases memory.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
std::vector< std::unique_ptr< ExecutorBootstrapService > > & services()
void setErrorReporter(ReportErrorFunction ReportError)
Set an error reporter for this server.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
void dispatch(unique_function< void()> Work) override
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
Lightweight error class with error context and mandatory checking.
virtual void shutdown()=0
void handleDisconnect(Error Err) override
Handle a disconnection from the underlying transport.
virtual void dispatch(unique_function< void()> Work)=0
SimpleRemoteEPCServer & server()
Error waitForDisconnect()
StringMap< ExecutorAddr > & bootstrapSymbols()