LLVM 19.0.0git
ExecutorProcessControl.h
Go to the documentation of this file.
1//===- ExecutorProcessControl.h - Executor process control APIs -*- 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// Utilities for interacting with the executor processes.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
14#define LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
15
16#include "llvm/ADT/StringRef.h"
26
27#include <future>
28#include <mutex>
29#include <vector>
30
31namespace llvm {
32namespace orc {
33
34class ExecutionSession;
35class SymbolLookupSet;
36
37/// ExecutorProcessControl supports interaction with a JIT target process.
39 friend class ExecutionSession;
40public:
41
42 /// A handler or incoming WrapperFunctionResults -- either return values from
43 /// callWrapper* calls, or incoming JIT-dispatch requests.
44 ///
45 /// IncomingWFRHandlers are constructible from
46 /// unique_function<void(shared::WrapperFunctionResult)>s using the
47 /// runInPlace function or a RunWithDispatch object.
50 public:
51 IncomingWFRHandler() = default;
52 explicit operator bool() const { return !!H; }
53 void operator()(shared::WrapperFunctionResult WFR) { H(std::move(WFR)); }
54 private:
55 template <typename FnT> IncomingWFRHandler(FnT &&Fn)
56 : H(std::forward<FnT>(Fn)) {}
57
59 };
60
61 /// Constructs an IncomingWFRHandler from a function object that is callable
62 /// as void(shared::WrapperFunctionResult). The function object will be called
63 /// directly. This should be used with care as it may block listener threads
64 /// in remote EPCs. It is only suitable for simple tasks (e.g. setting a
65 /// future), or for performing some quick analysis before dispatching "real"
66 /// work as a Task.
67 class RunInPlace {
68 public:
69 template <typename FnT>
71 return IncomingWFRHandler(std::forward<FnT>(Fn));
72 }
73 };
74
75 /// Constructs an IncomingWFRHandler from a function object by creating a new
76 /// function object that dispatches the original using a TaskDispatcher,
77 /// wrapping the original as a GenericNamedTask.
78 ///
79 /// This is the default approach for running WFR handlers.
80 class RunAsTask {
81 public:
83
84 template <typename FnT>
86 return IncomingWFRHandler(
87 [&D = this->D, Fn = std::move(Fn)]
88 (shared::WrapperFunctionResult WFR) mutable {
89 D.dispatch(
91 [Fn = std::move(Fn), WFR = std::move(WFR)]() mutable {
92 Fn(std::move(WFR));
93 }, "WFR handler task"));
94 });
95 }
96 private:
98 };
99
100 /// APIs for manipulating memory in the target process.
102 public:
103 /// Callback function for asynchronous writes.
105
106 virtual ~MemoryAccess();
107
109 WriteResultFn OnWriteComplete) = 0;
110
112 WriteResultFn OnWriteComplete) = 0;
113
115 WriteResultFn OnWriteComplete) = 0;
116
118 WriteResultFn OnWriteComplete) = 0;
119
121 WriteResultFn OnWriteComplete) = 0;
122
124 WriteResultFn OnWriteComplete) = 0;
125
127 std::promise<MSVCPError> ResultP;
128 auto ResultF = ResultP.get_future();
130 [&](Error Err) { ResultP.set_value(std::move(Err)); });
131 return ResultF.get();
132 }
133
135 std::promise<MSVCPError> ResultP;
136 auto ResultF = ResultP.get_future();
138 [&](Error Err) { ResultP.set_value(std::move(Err)); });
139 return ResultF.get();
140 }
141
143 std::promise<MSVCPError> ResultP;
144 auto ResultF = ResultP.get_future();
146 [&](Error Err) { ResultP.set_value(std::move(Err)); });
147 return ResultF.get();
148 }
149
151 std::promise<MSVCPError> ResultP;
152 auto ResultF = ResultP.get_future();
154 [&](Error Err) { ResultP.set_value(std::move(Err)); });
155 return ResultF.get();
156 }
157
159 std::promise<MSVCPError> ResultP;
160 auto ResultF = ResultP.get_future();
162 [&](Error Err) { ResultP.set_value(std::move(Err)); });
163 return ResultF.get();
164 }
165
167 std::promise<MSVCPError> ResultP;
168 auto ResultF = ResultP.get_future();
170 [&](Error Err) { ResultP.set_value(std::move(Err)); });
171 return ResultF.get();
172 }
173 };
174
175 /// A pair of a dylib and a set of symbols to be looked up.
181 };
182
183 /// Contains the address of the dispatch function and context that the ORC
184 /// runtime can use to call functions in the JIT.
188 };
189
190 ExecutorProcessControl(std::shared_ptr<SymbolStringPool> SSP,
191 std::unique_ptr<TaskDispatcher> D)
192 : SSP(std::move(SSP)), D(std::move(D)) {}
193
195
196 /// Return the ExecutionSession associated with this instance.
197 /// Not callable until the ExecutionSession has been associated.
199 assert(ES && "No ExecutionSession associated yet");
200 return *ES;
201 }
202
203 /// Intern a symbol name in the SymbolStringPool.
204 SymbolStringPtr intern(StringRef SymName) { return SSP->intern(SymName); }
205
206 /// Return a shared pointer to the SymbolStringPool for this instance.
207 std::shared_ptr<SymbolStringPool> getSymbolStringPool() const { return SSP; }
208
210
211 /// Return the Triple for the target process.
212 const Triple &getTargetTriple() const { return TargetTriple; }
213
214 /// Get the page size for the target process.
215 unsigned getPageSize() const { return PageSize; }
216
217 /// Get the JIT dispatch function and context address for the executor.
218 const JITDispatchInfo &getJITDispatchInfo() const { return JDI; }
219
220 /// Return a MemoryAccess object for the target process.
222 assert(MemAccess && "No MemAccess object set.");
223 return *MemAccess;
224 }
225
226 /// Return a JITLinkMemoryManager for the target process.
228 assert(MemMgr && "No MemMgr object set");
229 return *MemMgr;
230 }
231
232 /// Returns the bootstrap map.
234 return BootstrapMap;
235 }
236
237 /// Look up and SPS-deserialize a bootstrap map value.
238 ///
239 ///
240 template <typename T, typename SPSTagT>
241 Error getBootstrapMapValue(StringRef Key, std::optional<T> &Val) const {
242 Val = std::nullopt;
243
244 auto I = BootstrapMap.find(Key);
245 if (I == BootstrapMap.end())
246 return Error::success();
247
248 T Tmp;
249 shared::SPSInputBuffer IB(I->second.data(), I->second.size());
251 return make_error<StringError>("Could not deserialize value for key " +
252 Key,
254
255 Val = std::move(Tmp);
256 return Error::success();
257 }
258
259 /// Returns the bootstrap symbol map.
261 return BootstrapSymbols;
262 }
263
264 /// For each (ExecutorAddr&, StringRef) pair, looks up the string in the
265 /// bootstrap symbols map and writes its address to the ExecutorAddr if
266 /// found. If any symbol is not found then the function returns an error.
268 ArrayRef<std::pair<ExecutorAddr &, StringRef>> Pairs) const {
269 for (const auto &KV : Pairs) {
270 auto I = BootstrapSymbols.find(KV.second);
271 if (I == BootstrapSymbols.end())
272 return make_error<StringError>("Symbol \"" + KV.second +
273 "\" not found "
274 "in bootstrap symbols map",
276
277 KV.first = I->second;
278 }
279 return Error::success();
280 }
281
282 /// Load the dynamic library at the given path and return a handle to it.
283 /// If LibraryPath is null this function will return the global handle for
284 /// the target process.
285 virtual Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) = 0;
286
287 /// Search for symbols in the target process.
288 ///
289 /// The result of the lookup is a 2-dimensional array of target addresses
290 /// that correspond to the lookup order. If a required symbol is not
291 /// found then this method will return an error. If a weakly referenced
292 /// symbol is not found then it be assigned a '0' value.
295 std::promise<MSVCPExpected<std::vector<tpctypes::LookupResult>>> RP;
296 auto RF = RP.get_future();
297 lookupSymbolsAsync(Request,
298 [&RP](auto Result) { RP.set_value(std::move(Result)); });
299 return RF.get();
300 }
301
303 unique_function<void(Expected<std::vector<tpctypes::LookupResult>>)>;
304
305 /// Search for symbols in the target process.
306 ///
307 /// The result of the lookup is a 2-dimensional array of target addresses
308 /// that correspond to the lookup order. If a required symbol is not
309 /// found then this method will return an error. If a weakly referenced
310 /// symbol is not found then it be assigned a '0' value.
313
314 /// Run function with a main-like signature.
316 ArrayRef<std::string> Args) = 0;
317
318 // TODO: move this to ORC runtime.
319 /// Run function with a int (*)(void) signature.
321
322 // TODO: move this to ORC runtime.
323 /// Run function with a int (*)(int) signature.
325 int Arg) = 0;
326
327 /// Run a wrapper function in the executor. The given WFRHandler will be
328 /// called on the result when it is returned.
329 ///
330 /// The wrapper function should be callable as:
331 ///
332 /// \code{.cpp}
333 /// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
334 /// \endcode{.cpp}
335 virtual void callWrapperAsync(ExecutorAddr WrapperFnAddr,
336 IncomingWFRHandler OnComplete,
337 ArrayRef<char> ArgBuffer) = 0;
338
339 /// Run a wrapper function in the executor using the given Runner to dispatch
340 /// OnComplete when the result is ready.
341 template <typename RunPolicyT, typename FnT>
342 void callWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr,
343 FnT &&OnComplete, ArrayRef<char> ArgBuffer) {
345 WrapperFnAddr, Runner(std::forward<FnT>(OnComplete)), ArgBuffer);
346 }
347
348 /// Run a wrapper function in the executor. OnComplete will be dispatched
349 /// as a GenericNamedTask using this instance's TaskDispatch object.
350 template <typename FnT>
351 void callWrapperAsync(ExecutorAddr WrapperFnAddr, FnT &&OnComplete,
352 ArrayRef<char> ArgBuffer) {
353 callWrapperAsync(RunAsTask(*D), WrapperFnAddr,
354 std::forward<FnT>(OnComplete), ArgBuffer);
355 }
356
357 /// Run a wrapper function in the executor. The wrapper function should be
358 /// callable as:
359 ///
360 /// \code{.cpp}
361 /// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
362 /// \endcode{.cpp}
364 ArrayRef<char> ArgBuffer) {
365 std::promise<shared::WrapperFunctionResult> RP;
366 auto RF = RP.get_future();
368 RunInPlace(), WrapperFnAddr,
370 RP.set_value(std::move(R));
371 }, ArgBuffer);
372 return RF.get();
373 }
374
375 /// Run a wrapper function using SPS to serialize the arguments and
376 /// deserialize the results.
377 template <typename SPSSignature, typename RunPolicyT, typename SendResultT,
378 typename... ArgTs>
379 void callSPSWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr,
380 SendResultT &&SendResult, const ArgTs &...Args) {
382 [this, WrapperFnAddr, Runner = std::move(Runner)]
383 (auto &&SendResult, const char *ArgData, size_t ArgSize) mutable {
384 this->callWrapperAsync(std::move(Runner), WrapperFnAddr,
385 std::move(SendResult),
386 ArrayRef<char>(ArgData, ArgSize));
387 },
388 std::forward<SendResultT>(SendResult), Args...);
389 }
390
391 /// Run a wrapper function using SPS to serialize the arguments and
392 /// deserialize the results.
393 template <typename SPSSignature, typename SendResultT, typename... ArgTs>
394 void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult,
395 const ArgTs &...Args) {
396 callSPSWrapperAsync<SPSSignature>(RunAsTask(*D), WrapperFnAddr,
397 std::forward<SendResultT>(SendResult),
398 Args...);
399 }
400
401 /// Run a wrapper function using SPS to serialize the arguments and
402 /// deserialize the results.
403 ///
404 /// If SPSSignature is a non-void function signature then the second argument
405 /// (the first in the Args list) should be a reference to a return value.
406 template <typename SPSSignature, typename... WrapperCallArgTs>
408 WrapperCallArgTs &&...WrapperCallArgs) {
410 [this, WrapperFnAddr](const char *ArgData, size_t ArgSize) {
411 return callWrapper(WrapperFnAddr, ArrayRef<char>(ArgData, ArgSize));
412 },
413 std::forward<WrapperCallArgTs>(WrapperCallArgs)...);
414 }
415
416 /// Disconnect from the target process.
417 ///
418 /// This should be called after the JIT session is shut down.
419 virtual Error disconnect() = 0;
420
421protected:
422
423 std::shared_ptr<SymbolStringPool> SSP;
424 std::unique_ptr<TaskDispatcher> D;
427 unsigned PageSize = 0;
433};
434
436public:
437 InProcessMemoryAccess(bool IsArch64Bit) : IsArch64Bit(IsArch64Bit) {}
439 WriteResultFn OnWriteComplete) override;
440
442 WriteResultFn OnWriteComplete) override;
443
445 WriteResultFn OnWriteComplete) override;
446
448 WriteResultFn OnWriteComplete) override;
449
451 WriteResultFn OnWriteComplete) override;
452
454 WriteResultFn OnWriteComplete) override;
455
456private:
457 bool IsArch64Bit;
458};
459
460/// A ExecutorProcessControl instance that asserts if any of its methods are
461/// used. Suitable for use is unit tests, and by ORC clients who haven't moved
462/// to ExecutorProcessControl-based APIs yet.
464 private InProcessMemoryAccess {
465public:
467 std::shared_ptr<SymbolStringPool> SSP = nullptr,
468 std::unique_ptr<TaskDispatcher> D = nullptr, const std::string &TT = "",
469 unsigned PageSize = 0)
471 SSP ? std::move(SSP) : std::make_shared<SymbolStringPool>(),
472 D ? std::move(D) : std::make_unique<InPlaceTaskDispatcher>()),
473 InProcessMemoryAccess(Triple(TT).isArch64Bit()) {
474 this->TargetTriple = Triple(TT);
475 this->PageSize = PageSize;
476 this->MemAccess = this;
477 }
478
479 Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) override {
480 llvm_unreachable("Unsupported");
481 }
482
484 SymbolLookupCompleteFn F) override {
485 llvm_unreachable("Unsupported");
486 }
487
489 ArrayRef<std::string> Args) override {
490 llvm_unreachable("Unsupported");
491 }
492
494 llvm_unreachable("Unsupported");
495 }
496
497 Expected<int32_t> runAsIntFunction(ExecutorAddr IntFnAddr, int Arg) override {
498 llvm_unreachable("Unsupported");
499 }
500
501 void callWrapperAsync(ExecutorAddr WrapperFnAddr,
502 IncomingWFRHandler OnComplete,
503 ArrayRef<char> ArgBuffer) override {
504 llvm_unreachable("Unsupported");
505 }
506
507 Error disconnect() override { return Error::success(); }
508};
509
510/// A ExecutorProcessControl implementation targeting the current process.
512 private InProcessMemoryAccess {
513public:
515 std::shared_ptr<SymbolStringPool> SSP, std::unique_ptr<TaskDispatcher> D,
516 Triple TargetTriple, unsigned PageSize,
517 std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr);
518
519 /// Create a SelfExecutorProcessControl with the given symbol string pool and
520 /// memory manager.
521 /// If no symbol string pool is given then one will be created.
522 /// If no memory manager is given a jitlink::InProcessMemoryManager will
523 /// be created and used by default.
525 Create(std::shared_ptr<SymbolStringPool> SSP = nullptr,
526 std::unique_ptr<TaskDispatcher> D = nullptr,
527 std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr = nullptr);
528
529 Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) override;
530
532 SymbolLookupCompleteFn F) override;
533
535 ArrayRef<std::string> Args) override;
536
538
539 Expected<int32_t> runAsIntFunction(ExecutorAddr IntFnAddr, int Arg) override;
540
541 void callWrapperAsync(ExecutorAddr WrapperFnAddr,
542 IncomingWFRHandler OnComplete,
543 ArrayRef<char> ArgBuffer) override;
544
545 Error disconnect() override;
546
547private:
549 jitDispatchViaWrapperFunctionManager(void *Ctx, const void *FnTag,
550 const char *Data, size_t Size);
551
552 std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
553 char GlobalManglingPrefix = 0;
554};
555
556} // end namespace orc
557} // end namespace llvm
558
559#endif // LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
uint64_t Size
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
#define H(x, y, z)
Definition: MD5.cpp:57
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:334
Tagged union holding either a T or a Error.
Definition: Error.h:474
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:128
iterator end()
Definition: StringMap.h:221
iterator find(StringRef Key)
Definition: StringMap.h:234
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
An ExecutionSession represents a running JIT program.
Definition: Core.h:1425
Represents an address in the executor process.
A handler or incoming WrapperFunctionResults – either return values from callWrapper* calls,...
void operator()(shared::WrapperFunctionResult WFR)
APIs for manipulating memory in the target process.
virtual void writePointersAsync(ArrayRef< tpctypes::PointerWrite > Ws, WriteResultFn OnWriteComplete)=0
Error writeUInt64s(ArrayRef< tpctypes::UInt64Write > Ws)
Error writeBuffers(ArrayRef< tpctypes::BufferWrite > Ws)
Error writeUInt32s(ArrayRef< tpctypes::UInt32Write > Ws)
Error writePointers(ArrayRef< tpctypes::PointerWrite > Ws)
Error writeUInt8s(ArrayRef< tpctypes::UInt8Write > Ws)
virtual void writeUInt8sAsync(ArrayRef< tpctypes::UInt8Write > Ws, WriteResultFn OnWriteComplete)=0
Error writeUInt16s(ArrayRef< tpctypes::UInt16Write > Ws)
virtual void writeUInt32sAsync(ArrayRef< tpctypes::UInt32Write > Ws, WriteResultFn OnWriteComplete)=0
unique_function< void(Error)> WriteResultFn
Callback function for asynchronous writes.
virtual void writeBuffersAsync(ArrayRef< tpctypes::BufferWrite > Ws, WriteResultFn OnWriteComplete)=0
virtual void writeUInt16sAsync(ArrayRef< tpctypes::UInt16Write > Ws, WriteResultFn OnWriteComplete)=0
virtual void writeUInt64sAsync(ArrayRef< tpctypes::UInt64Write > Ws, WriteResultFn OnWriteComplete)=0
Constructs an IncomingWFRHandler from a function object by creating a new function object that dispat...
Constructs an IncomingWFRHandler from a function object that is callable as void(shared::WrapperFunct...
ExecutorProcessControl supports interaction with a JIT target process.
jitlink::JITLinkMemoryManager & getMemMgr() const
Return a JITLinkMemoryManager for the target process.
shared::WrapperFunctionResult callWrapper(ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
void callWrapperAsync(ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
virtual Expected< int32_t > runAsIntFunction(ExecutorAddr IntFnAddr, int Arg)=0
Run function with a int (*)(int) signature.
void callSPSWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
virtual Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args)=0
Run function with a main-like signature.
Error getBootstrapMapValue(StringRef Key, std::optional< T > &Val) const
Look up and SPS-deserialize a bootstrap map value.
std::unique_ptr< TaskDispatcher > D
void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
virtual void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer)=0
Run a wrapper function in the executor.
virtual Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath)=0
Load the dynamic library at the given path and return a handle to it.
const StringMap< std::vector< char > > & getBootstrapMap() const
Returns the bootstrap map.
std::shared_ptr< SymbolStringPool > SSP
const Triple & getTargetTriple() const
Return the Triple for the target process.
StringMap< ExecutorAddr > BootstrapSymbols
SymbolStringPtr intern(StringRef SymName)
Intern a symbol name in the SymbolStringPool.
virtual Error disconnect()=0
Disconnect from the target process.
virtual void lookupSymbolsAsync(ArrayRef< LookupRequest > Request, SymbolLookupCompleteFn F)=0
Search for symbols in the target process.
StringMap< std::vector< char > > BootstrapMap
std::shared_ptr< SymbolStringPool > getSymbolStringPool() const
Return a shared pointer to the SymbolStringPool for this instance.
const StringMap< ExecutorAddr > & getBootstrapSymbolsMap() const
Returns the bootstrap symbol map.
virtual Expected< int32_t > runAsVoidFunction(ExecutorAddr VoidFnAddr)=0
Run function with a int (*)(void) signature.
jitlink::JITLinkMemoryManager * MemMgr
unsigned getPageSize() const
Get the page size for the target process.
const JITDispatchInfo & getJITDispatchInfo() const
Get the JIT dispatch function and context address for the executor.
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
void callWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor using the given Runner to dispatch OnComplete when the result ...
Error getBootstrapSymbols(ArrayRef< std::pair< ExecutorAddr &, StringRef > > Pairs) const
For each (ExecutorAddr&, StringRef) pair, looks up the string in the bootstrap symbols map and writes...
ExecutionSession & getExecutionSession()
Return the ExecutionSession associated with this instance.
ExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D)
Expected< std::vector< tpctypes::LookupResult > > lookupSymbols(ArrayRef< LookupRequest > Request)
Search for symbols in the target process.
MemoryAccess & getMemoryAccess() const
Return a MemoryAccess object for the target process.
Runs all tasks on the current thread.
Definition: TaskDispatch.h:107
void writePointersAsync(ArrayRef< tpctypes::PointerWrite > Ws, WriteResultFn OnWriteComplete) override
void writeUInt32sAsync(ArrayRef< tpctypes::UInt32Write > Ws, WriteResultFn OnWriteComplete) override
void writeUInt8sAsync(ArrayRef< tpctypes::UInt8Write > Ws, WriteResultFn OnWriteComplete) override
void writeUInt16sAsync(ArrayRef< tpctypes::UInt16Write > Ws, WriteResultFn OnWriteComplete) override
void writeBuffersAsync(ArrayRef< tpctypes::BufferWrite > Ws, WriteResultFn OnWriteComplete) override
void writeUInt64sAsync(ArrayRef< tpctypes::UInt64Write > Ws, WriteResultFn OnWriteComplete) override
A ExecutorProcessControl implementation targeting the current process.
Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath) override
Load the dynamic library at the given path and return a handle to it.
void lookupSymbolsAsync(ArrayRef< LookupRequest > Request, SymbolLookupCompleteFn F) override
Search for symbols in 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.
Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.
void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) override
Run a wrapper function in the executor.
static Expected< std::unique_ptr< SelfExecutorProcessControl > > Create(std::shared_ptr< SymbolStringPool > SSP=nullptr, std::unique_ptr< TaskDispatcher > D=nullptr, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr=nullptr)
Create a SelfExecutorProcessControl with the given symbol string pool and memory manager.
Expected< int32_t > runAsIntFunction(ExecutorAddr IntFnAddr, int Arg) override
Run function with a int (*)(int) signature.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:183
String pool for symbol names used by the JIT.
Pointer to a pooled string representing a symbol name.
Abstract base for classes that dispatch ORC Tasks.
Definition: TaskDispatch.h:95
virtual void dispatch(std::unique_ptr< Task > T)=0
Run the given task.
A ExecutorProcessControl instance that asserts if any of its methods are used.
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 > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.
UnsupportedExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP=nullptr, std::unique_ptr< TaskDispatcher > D=nullptr, const std::string &TT="", unsigned PageSize=0)
void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) override
Run a wrapper function in the executor.
Error disconnect() override
Disconnect from the target process.
Expected< int32_t > runAsIntFunction(ExecutorAddr IntFnAddr, int Arg) override
Run function with a int (*)(int) signature.
void lookupSymbolsAsync(ArrayRef< LookupRequest > Request, SymbolLookupCompleteFn F) override
Search for symbols in the target process.
Expected< int32_t > runAsVoidFunction(ExecutorAddr VoidFnAddr) override
Run function with a int (*)(void) signature.
A utility class for serializing to a blob from a variadic list.
Input char buffer with underflow check.
C++ wrapper function result: Same as CWrapperFunctionResult but auto-releases memory.
unique_function is a type-erasing functor similar to std::function.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::unique_ptr< GenericNamedTask > makeGenericNamedTask(FnT &&Fn, std::string Desc)
Create a generic named task from a std::string description.
Definition: TaskDispatch.h:78
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:90
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:1858
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
Contains the address of the dispatch function and context that the ORC runtime can use to call functi...
A pair of a dylib and a set of symbols to be looked up.
LookupRequest(tpctypes::DylibHandle Handle, const SymbolLookupSet &Symbols)