@@ -47,9 +47,9 @@ class RemoteExecutorProcessControl
47
47
public:
48
48
using BaseT::initializeORCRPCEPCBase;
49
49
50
- RemoteExecutorProcessControl (ExecutionSession &ES ,
51
- std::unique_ptr<RPCChannel> Channel ,
52
- std::unique_ptr<RPCEndpoint> Endpoint );
50
+ RemoteExecutorProcessControl (std::unique_ptr<RPCChannel> Channel ,
51
+ std::unique_ptr<RPCEndpoint> Endpoint ,
52
+ BaseT::ErrorReporter ReportError );
53
53
54
54
void initializeMemoryManagement ();
55
55
Error disconnect () override ;
@@ -64,10 +64,10 @@ class RemoteExecutorProcessControl
64
64
};
65
65
66
66
RemoteExecutorProcessControl::RemoteExecutorProcessControl (
67
- ExecutionSession &ES , std::unique_ptr<RPCChannel> Channel ,
68
- std::unique_ptr<RPCEndpoint> Endpoint )
69
- : BaseT(ES.getSymbolStringPool (), *Endpoint,
70
- [&ES](Error Err) { ES. reportError ( std::move (Err)); } ),
67
+ std::unique_ptr<RPCChannel> Channel , std::unique_ptr<RPCEndpoint> Endpoint ,
68
+ BaseT::ErrorReporter ReportError )
69
+ : BaseT(std::make_shared<SymbolStringPool> (), *Endpoint,
70
+ std::move (ReportError) ),
71
71
Channel(std::move(Channel)), Endpoint(std::move(Endpoint)) {
72
72
73
73
ListenerThread = std::thread ([&]() {
@@ -109,11 +109,17 @@ JITLinkExecutor::~JITLinkExecutor() = default;
109
109
110
110
Expected<std::unique_ptr<ObjectLayer>>
111
111
JITLinkExecutor::operator ()(ExecutionSession &ES, const Triple &TT) {
112
+ assert (EPC && " RemoteExecutorProcessControl must be initialized" );
112
113
return std::make_unique<ObjectLinkingLayer>(ES, EPC->getMemMgr ());
113
114
}
114
115
116
+ std::unique_ptr<ExecutionSession> JITLinkExecutor::startSession () {
117
+ assert (OwnedEPC && " RemoteExecutorProcessControl must be initialized" );
118
+ return std::make_unique<ExecutionSession>(std::move (OwnedEPC));
119
+ }
120
+
115
121
Error JITLinkExecutor::addDebugSupport (ObjectLayer &ObjLayer) {
116
- auto Registrar = createJITLoaderGDBRegistrar (* EPC);
122
+ auto Registrar = createJITLoaderGDBRegistrar (EPC-> getExecutionSession () );
117
123
if (!Registrar)
118
124
return Registrar.takeError ();
119
125
@@ -127,7 +133,8 @@ Error JITLinkExecutor::addDebugSupport(ObjectLayer &ObjLayer) {
127
133
Expected<std::unique_ptr<DefinitionGenerator>>
128
134
JITLinkExecutor::loadDylib (StringRef RemotePath) {
129
135
if (auto Handle = EPC->loadDylib (RemotePath.data ()))
130
- return std::make_unique<EPCDynamicLibrarySearchGenerator>(*EPC, *Handle );
136
+ return std::make_unique<EPCDynamicLibrarySearchGenerator>(
137
+ EPC->getExecutionSession (), *Handle );
131
138
else
132
139
return Handle .takeError ();
133
140
}
@@ -174,7 +181,8 @@ JITLinkExecutor::CreateLocal(std::string ExecutablePath) {
174
181
175
182
TCPSocketJITLinkExecutor::TCPSocketJITLinkExecutor (
176
183
std::unique_ptr<RemoteExecutorProcessControl> EPC) {
177
- this ->EPC = std::move (EPC);
184
+ this ->OwnedEPC = std::move (EPC);
185
+ this ->EPC = this ->OwnedEPC .get ();
178
186
}
179
187
180
188
#ifndef LLVM_ON_UNIX
@@ -197,7 +205,8 @@ JITLinkExecutor::ConnectTCPSocket(StringRef NetworkAddress,
197
205
198
206
#else
199
207
200
- Error ChildProcessJITLinkExecutor::launch (ExecutionSession &ES) {
208
+ Error ChildProcessJITLinkExecutor::launch (
209
+ unique_function<void (Error)> ErrorReporter) {
201
210
constexpr int ReadEnd = 0 ;
202
211
constexpr int WriteEnd = 1 ;
203
212
@@ -252,13 +261,14 @@ Error ChildProcessJITLinkExecutor::launch(ExecutionSession &ES) {
252
261
auto Endpoint = std::make_unique<RemoteExecutorProcessControl::RPCEndpoint>(
253
262
*Channel, true );
254
263
255
- EPC = std::make_unique<RemoteExecutorProcessControl>(ES, std::move (Channel),
256
- std::move (Endpoint));
264
+ OwnedEPC = std::make_unique<RemoteExecutorProcessControl>(
265
+ std::move (Channel), std::move (Endpoint), std::move (ErrorReporter ));
257
266
258
- if (auto Err = EPC ->initializeORCRPCEPCBase ())
259
- return joinErrors (std::move (Err), EPC ->disconnect ());
267
+ if (auto Err = OwnedEPC ->initializeORCRPCEPCBase ())
268
+ return joinErrors (std::move (Err), OwnedEPC ->disconnect ());
260
269
261
- EPC->initializeMemoryManagement ();
270
+ OwnedEPC->initializeMemoryManagement ();
271
+ EPC = OwnedEPC.get ();
262
272
263
273
shared::registerStringError<RPCChannel>();
264
274
return Error::success ();
@@ -305,7 +315,7 @@ static Expected<int> connectTCPSocketImpl(std::string Host,
305
315
306
316
Expected<std::unique_ptr<TCPSocketJITLinkExecutor>>
307
317
JITLinkExecutor::ConnectTCPSocket (StringRef NetworkAddress,
308
- ExecutionSession &ES ) {
318
+ unique_function< void (Error)> ErrorReporter ) {
309
319
auto CreateErr = [NetworkAddress](StringRef Details) {
310
320
return make_error<StringError>(
311
321
formatv (" Failed to connect TCP socket '{0}': {1}" , NetworkAddress,
@@ -332,7 +342,7 @@ JITLinkExecutor::ConnectTCPSocket(StringRef NetworkAddress,
332
342
*Channel, true );
333
343
334
344
auto EPC = std::make_unique<RemoteExecutorProcessControl>(
335
- ES, std::move (Channel), std::move (Endpoint));
345
+ std::move (Channel), std::move (Endpoint), std::move (ErrorReporter ));
336
346
337
347
if (auto Err = EPC->initializeORCRPCEPCBase ())
338
348
return joinErrors (std::move (Err), EPC->disconnect ());
0 commit comments