LLVM  14.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"
17 #include "llvm/ADT/Triple.h"
26 
27 #include <future>
28 #include <mutex>
29 #include <vector>
30 
31 namespace llvm {
32 namespace orc {
33 
34 class ExecutionSession;
35 class SymbolLookupSet;
36 
37 /// ExecutorProcessControl supports interaction with a JIT target process.
39  friend class ExecutionSession;
40 public:
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.
49  friend class ExecutorProcessControl;
50  public:
51  IncomingWFRHandler() = default;
52  explicit operator bool() const { return !!H; }
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:
82  RunAsTask(TaskDispatcher &D) : D(D) {}
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:
97  TaskDispatcher &D;
98  };
99 
100  /// APIs for manipulating memory in the target process.
101  class MemoryAccess {
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  std::promise<MSVCPError> ResultP;
125  auto ResultF = ResultP.get_future();
126  writeUInt8sAsync(Ws,
127  [&](Error Err) { ResultP.set_value(std::move(Err)); });
128  return ResultF.get();
129  }
130 
132  std::promise<MSVCPError> ResultP;
133  auto ResultF = ResultP.get_future();
135  [&](Error Err) { ResultP.set_value(std::move(Err)); });
136  return ResultF.get();
137  }
138 
140  std::promise<MSVCPError> ResultP;
141  auto ResultF = ResultP.get_future();
143  [&](Error Err) { ResultP.set_value(std::move(Err)); });
144  return ResultF.get();
145  }
146 
148  std::promise<MSVCPError> ResultP;
149  auto ResultF = ResultP.get_future();
151  [&](Error Err) { ResultP.set_value(std::move(Err)); });
152  return ResultF.get();
153  }
154 
156  std::promise<MSVCPError> ResultP;
157  auto ResultF = ResultP.get_future();
159  [&](Error Err) { ResultP.set_value(std::move(Err)); });
160  return ResultF.get();
161  }
162  };
163 
164  /// A pair of a dylib and a set of symbols to be looked up.
165  struct LookupRequest {
167  : Handle(Handle), Symbols(Symbols) {}
170  };
171 
172  /// Contains the address of the dispatch function and context that the ORC
173  /// runtime can use to call functions in the JIT.
177  };
178 
179  ExecutorProcessControl(std::shared_ptr<SymbolStringPool> SSP,
180  std::unique_ptr<TaskDispatcher> D)
181  : SSP(std::move(SSP)), D(std::move(D)) {}
182 
183  virtual ~ExecutorProcessControl();
184 
185  /// Return the ExecutionSession associated with this instance.
186  /// Not callable until the ExecutionSession has been associated.
188  assert(ES && "No ExecutionSession associated yet");
189  return *ES;
190  }
191 
192  /// Intern a symbol name in the SymbolStringPool.
193  SymbolStringPtr intern(StringRef SymName) { return SSP->intern(SymName); }
194 
195  /// Return a shared pointer to the SymbolStringPool for this instance.
196  std::shared_ptr<SymbolStringPool> getSymbolStringPool() const { return SSP; }
197 
199 
200  /// Return the Triple for the target process.
201  const Triple &getTargetTriple() const { return TargetTriple; }
202 
203  /// Get the page size for the target process.
204  unsigned getPageSize() const { return PageSize; }
205 
206  /// Get the JIT dispatch function and context address for the executor.
207  const JITDispatchInfo &getJITDispatchInfo() const { return JDI; }
208 
209  /// Return a MemoryAccess object for the target process.
211  assert(MemAccess && "No MemAccess object set.");
212  return *MemAccess;
213  }
214 
215  /// Return a JITLinkMemoryManager for the target process.
217  assert(MemMgr && "No MemMgr object set");
218  return *MemMgr;
219  }
220 
221  /// Returns the bootstrap symbol map.
223  return BootstrapSymbols;
224  }
225 
226  /// For each (ExecutorAddr&, StringRef) pair, looks up the string in the
227  /// bootstrap symbols map and writes its address to the ExecutorAddr if
228  /// found. If any symbol is not found then the function returns an error.
230  ArrayRef<std::pair<ExecutorAddr &, StringRef>> Pairs) const {
231  for (auto &KV : Pairs) {
232  auto I = BootstrapSymbols.find(KV.second);
233  if (I == BootstrapSymbols.end())
234  return make_error<StringError>("Symbol \"" + KV.second +
235  "\" not found "
236  "in bootstrap symbols map",
238 
239  KV.first = I->second;
240  }
241  return Error::success();
242  }
243 
244  /// Load the dynamic library at the given path and return a handle to it.
245  /// If LibraryPath is null this function will return the global handle for
246  /// the target process.
247  virtual Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) = 0;
248 
249  /// Search for symbols in the target process.
250  ///
251  /// The result of the lookup is a 2-dimentional array of target addresses
252  /// that correspond to the lookup order. If a required symbol is not
253  /// found then this method will return an error. If a weakly referenced
254  /// symbol is not found then it be assigned a '0' value.
257 
258  /// Run function with a main-like signature.
259  virtual Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
261 
262  /// Run a wrapper function in the executor. The given WFRHandler will be
263  /// called on the result when it is returned.
264  ///
265  /// The wrapper function should be callable as:
266  ///
267  /// \code{.cpp}
268  /// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
269  /// \endcode{.cpp}
270  virtual void callWrapperAsync(ExecutorAddr WrapperFnAddr,
271  IncomingWFRHandler OnComplete,
272  ArrayRef<char> ArgBuffer) = 0;
273 
274  /// Run a wrapper function in the executor using the given Runner to dispatch
275  /// OnComplete when the result is ready.
276  template <typename RunPolicyT, typename FnT>
277  void callWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr,
278  FnT &&OnComplete, ArrayRef<char> ArgBuffer) {
280  WrapperFnAddr, Runner(std::forward<FnT>(OnComplete)), ArgBuffer);
281  }
282 
283  /// Run a wrapper function in the executor. OnComplete will be dispatched
284  /// as a GenericNamedTask using this instance's TaskDispatch object.
285  template <typename FnT>
286  void callWrapperAsync(ExecutorAddr WrapperFnAddr, FnT &&OnComplete,
287  ArrayRef<char> ArgBuffer) {
288  callWrapperAsync(RunAsTask(*D), WrapperFnAddr,
289  std::forward<FnT>(OnComplete), ArgBuffer);
290  }
291 
292  /// Run a wrapper function in the executor. The wrapper function should be
293  /// callable as:
294  ///
295  /// \code{.cpp}
296  /// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
297  /// \endcode{.cpp}
299  ArrayRef<char> ArgBuffer) {
300  std::promise<shared::WrapperFunctionResult> RP;
301  auto RF = RP.get_future();
303  RunInPlace(), WrapperFnAddr,
305  RP.set_value(std::move(R));
306  }, ArgBuffer);
307  return RF.get();
308  }
309 
310  /// Run a wrapper function using SPS to serialize the arguments and
311  /// deserialize the results.
312  template <typename SPSSignature, typename RunPolicyT, typename SendResultT,
313  typename... ArgTs>
314  void callSPSWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr,
315  SendResultT &&SendResult, const ArgTs &...Args) {
317  [this, WrapperFnAddr, Runner = std::move(Runner)]
318  (auto &&SendResult, const char *ArgData, size_t ArgSize) mutable {
319  this->callWrapperAsync(std::move(Runner), WrapperFnAddr,
320  std::move(SendResult),
321  ArrayRef<char>(ArgData, ArgSize));
322  },
323  std::forward<SendResultT>(SendResult), Args...);
324  }
325 
326  /// Run a wrapper function using SPS to serialize the arguments and
327  /// deserialize the results.
328  template <typename SPSSignature, typename SendResultT, typename... ArgTs>
329  void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult,
330  const ArgTs &...Args) {
331  callSPSWrapperAsync<SPSSignature>(RunAsTask(*D), WrapperFnAddr,
332  std::forward<SendResultT>(SendResult),
333  Args...);
334  }
335 
336  /// Run a wrapper function using SPS to serialize the arguments and
337  /// deserialize the results.
338  ///
339  /// If SPSSignature is a non-void function signature then the second argument
340  /// (the first in the Args list) should be a reference to a return value.
341  template <typename SPSSignature, typename... WrapperCallArgTs>
343  WrapperCallArgTs &&...WrapperCallArgs) {
345  [this, WrapperFnAddr](const char *ArgData, size_t ArgSize) {
346  return callWrapper(WrapperFnAddr, ArrayRef<char>(ArgData, ArgSize));
347  },
348  std::forward<WrapperCallArgTs>(WrapperCallArgs)...);
349  }
350 
351  /// Disconnect from the target process.
352  ///
353  /// This should be called after the JIT session is shut down.
354  virtual Error disconnect() = 0;
355 
356 protected:
357 
358  std::shared_ptr<SymbolStringPool> SSP;
359  std::unique_ptr<TaskDispatcher> D;
360  ExecutionSession *ES = nullptr;
362  unsigned PageSize = 0;
367 };
368 
369 /// A ExecutorProcessControl instance that asserts if any of its methods are
370 /// used. Suitable for use is unit tests, and by ORC clients who haven't moved
371 /// to ExecutorProcessControl-based APIs yet.
373 public:
375  std::shared_ptr<SymbolStringPool> SSP = nullptr,
376  std::unique_ptr<TaskDispatcher> D = nullptr,
377  const std::string &TT = "", unsigned PageSize = 0)
379  : std::make_shared<SymbolStringPool>(),
380  D ? std::move(D)
381  : std::make_unique<InPlaceTaskDispatcher>()) {
382  this->TargetTriple = Triple(TT);
383  this->PageSize = PageSize;
384  }
385 
386  Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) override {
387  llvm_unreachable("Unsupported");
388  }
389 
392  llvm_unreachable("Unsupported");
393  }
394 
396  ArrayRef<std::string> Args) override {
397  llvm_unreachable("Unsupported");
398  }
399 
400  void callWrapperAsync(ExecutorAddr WrapperFnAddr,
401  IncomingWFRHandler OnComplete,
402  ArrayRef<char> ArgBuffer) override {
403  llvm_unreachable("Unsupported");
404  }
405 
406  Error disconnect() override { return Error::success(); }
407 };
408 
409 /// A ExecutorProcessControl implementation targeting the current process.
411  : public ExecutorProcessControl,
413 public:
415  std::shared_ptr<SymbolStringPool> SSP, std::unique_ptr<TaskDispatcher> D,
416  Triple TargetTriple, unsigned PageSize,
417  std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr);
418 
419  /// Create a SelfExecutorProcessControl with the given symbol string pool and
420  /// memory manager.
421  /// If no symbol string pool is given then one will be created.
422  /// If no memory manager is given a jitlink::InProcessMemoryManager will
423  /// be created and used by default.
425  Create(std::shared_ptr<SymbolStringPool> SSP = nullptr,
426  std::unique_ptr<TaskDispatcher> D = nullptr,
427  std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr = nullptr);
428 
429  Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) override;
430 
432  lookupSymbols(ArrayRef<LookupRequest> Request) override;
433 
435  ArrayRef<std::string> Args) override;
436 
437  void callWrapperAsync(ExecutorAddr WrapperFnAddr,
438  IncomingWFRHandler OnComplete,
439  ArrayRef<char> ArgBuffer) override;
440 
441  Error disconnect() override;
442 
443 private:
444  void writeUInt8sAsync(ArrayRef<tpctypes::UInt8Write> Ws,
445  WriteResultFn OnWriteComplete) override;
446 
447  void writeUInt16sAsync(ArrayRef<tpctypes::UInt16Write> Ws,
448  WriteResultFn OnWriteComplete) override;
449 
450  void writeUInt32sAsync(ArrayRef<tpctypes::UInt32Write> Ws,
451  WriteResultFn OnWriteComplete) override;
452 
453  void writeUInt64sAsync(ArrayRef<tpctypes::UInt64Write> Ws,
454  WriteResultFn OnWriteComplete) override;
455 
456  void writeBuffersAsync(ArrayRef<tpctypes::BufferWrite> Ws,
457  WriteResultFn OnWriteComplete) override;
458 
460  jitDispatchViaWrapperFunctionManager(void *Ctx, const void *FnTag,
461  const char *Data, size_t Size);
462 
463  std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
464  char GlobalManglingPrefix = 0;
465  std::vector<std::unique_ptr<sys::DynamicLibrary>> DynamicLibraries;
466 };
467 
468 } // end namespace orc
469 } // end namespace llvm
470 
471 #endif // LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::orc::ExecutorAddr
Represents an address in the executor process.
Definition: ExecutorAddress.h:37
llvm::orc::ExecutorProcessControl::MemMgr
jitlink::JITLinkMemoryManager * MemMgr
Definition: ExecutorProcessControl.h:365
TargetProcessControlTypes.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::orc::shared::CWrapperFunctionResult
Definition: WrapperFunctionUtils.h:33
llvm::orc::ExecutorProcessControl::ES
ExecutionSession * ES
Definition: ExecutorProcessControl.h:360
llvm::orc::makeGenericNamedTask
std::unique_ptr< GenericNamedTask > makeGenericNamedTask(FnT &&Fn, std::string Desc)
Create a generic named task from a std::string description.
Definition: TaskDispatch.h:78
llvm::unique_function
unique_function is a type-erasing functor similar to std::function.
Definition: FunctionExtras.h:56
llvm::orc::ExecutorProcessControl::MemoryAccess::~MemoryAccess
virtual ~MemoryAccess()
Definition: ExecutorProcessControl.cpp:22
llvm::orc::ExecutorProcessControl::callSPSWrapperAsync
void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition: ExecutorProcessControl.h:329
llvm::orc::ExecutorProcessControl::getBootstrapSymbols
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...
Definition: ExecutorProcessControl.h:229
llvm::orc::ExecutorProcessControl::getMemoryAccess
MemoryAccess & getMemoryAccess() const
Return a MemoryAccess object for the target process.
Definition: ExecutorProcessControl.h:210
StringRef.h
llvm::orc::ExecutorProcessControl::LookupRequest::LookupRequest
LookupRequest(tpctypes::DylibHandle Handle, const SymbolLookupSet &Symbols)
Definition: ExecutorProcessControl.h:166
llvm::orc::SymbolLookupSet
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:175
llvm::orc::SymbolStringPtr
Pointer to a pooled string representing a symbol name.
Definition: SymbolStringPool.h:50
llvm::orc::shared::WrapperFunction
Definition: WrapperFunctionUtils.h:425
llvm::orc::UnsupportedExecutorProcessControl::loadDylib
Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath) override
Load the dynamic library at the given path and return a handle to it.
Definition: ExecutorProcessControl.h:386
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::orc::ExecutorProcessControl::TargetTriple
Triple TargetTriple
Definition: ExecutorProcessControl.h:361
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::orc::SelfExecutorProcessControl::disconnect
Error disconnect() override
Disconnect from the target process.
Definition: ExecutorProcessControl.cpp:133
llvm::orc::ExecutorProcessControl::getExecutionSession
ExecutionSession & getExecutionSession()
Return the ExecutionSession associated with this instance.
Definition: ExecutorProcessControl.h:187
WrapperFunctionUtils.h
DynamicLibrary.h
llvm::orc::TaskDispatcher
Abstract base for classes that dispatch ORC Tasks.
Definition: TaskDispatch.h:95
llvm::orc::ExecutorProcessControl
ExecutorProcessControl supports interaction with a JIT target process.
Definition: ExecutorProcessControl.h:38
llvm::orc::ExecutorProcessControl::JITDispatchInfo::JITDispatchFunction
ExecutorAddr JITDispatchFunction
Definition: ExecutorProcessControl.h:175
MSVCErrorWorkarounds.h
llvm::orc::InPlaceTaskDispatcher
Runs all tasks on the current thread.
Definition: TaskDispatch.h:107
llvm::orc::ExecutorProcessControl::SSP
std::shared_ptr< SymbolStringPool > SSP
Definition: ExecutorProcessControl.h:358
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::orc::ExecutorProcessControl::disconnect
virtual Error disconnect()=0
Disconnect from the target process.
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::orc::ExecutorProcessControl::LookupRequest::Handle
tpctypes::DylibHandle Handle
Definition: ExecutorProcessControl.h:168
llvm::orc::UnsupportedExecutorProcessControl::UnsupportedExecutorProcessControl
UnsupportedExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP=nullptr, std::unique_ptr< TaskDispatcher > D=nullptr, const std::string &TT="", unsigned PageSize=0)
Definition: ExecutorProcessControl.h:374
SymbolStringPool.h
llvm::orc::ExecutorProcessControl::getMemMgr
jitlink::JITLinkMemoryManager & getMemMgr() const
Return a JITLinkMemoryManager for the target process.
Definition: ExecutorProcessControl.h:216
llvm::AArch64::RP
@ RP
Definition: AArch64ISelLowering.h:477
llvm::orc::SymbolStringPool
String pool for symbol names used by the JIT.
Definition: SymbolStringPool.h:27
llvm::orc::ExecutorProcessControl::ExecutorProcessControl
ExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D)
Definition: ExecutorProcessControl.h:179
llvm::orc::ExecutorProcessControl::MemoryAccess::writeBuffersAsync
virtual void writeBuffersAsync(ArrayRef< tpctypes::BufferWrite > Ws, WriteResultFn OnWriteComplete)=0
llvm::orc::ExecutorProcessControl::MemoryAccess::writeUInt8sAsync
virtual void writeUInt8sAsync(ArrayRef< tpctypes::UInt8Write > Ws, WriteResultFn OnWriteComplete)=0
llvm::orc::ExecutorProcessControl::MemoryAccess::writeUInt8s
Error writeUInt8s(ArrayRef< tpctypes::UInt8Write > Ws)
Definition: ExecutorProcessControl.h:123
llvm::orc::ExecutorProcessControl::IncomingWFRHandler::operator()
void operator()(shared::WrapperFunctionResult WFR)
Definition: ExecutorProcessControl.h:53
llvm::orc::ExecutorProcessControl::LookupRequest::Symbols
const SymbolLookupSet & Symbols
Definition: ExecutorProcessControl.h:169
llvm::orc::ExecutorProcessControl::MemAccess
MemoryAccess * MemAccess
Definition: ExecutorProcessControl.h:364
llvm::orc::ExecutorProcessControl::JDI
JITDispatchInfo JDI
Definition: ExecutorProcessControl.h:363
llvm::orc::ExecutorProcessControl::IncomingWFRHandler
A handler or incoming WrapperFunctionResults – either return values from callWrapper* calls,...
Definition: ExecutorProcessControl.h:48
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:108
llvm::orc::ExecutorProcessControl::callWrapperAsync
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 ...
Definition: ExecutorProcessControl.h:277
llvm::orc::SelfExecutorProcessControl::loadDylib
Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath) override
Load the dynamic library at the given path and return a handle to it.
Definition: ExecutorProcessControl.cpp:76
llvm::orc::ExecutorProcessControl::JITDispatchInfo
Contains the address of the dispatch function and context that the ORC runtime can use to call functi...
Definition: ExecutorProcessControl.h:174
llvm::orc::ExecutorProcessControl::LookupRequest
A pair of a dylib and a set of symbols to be looked up.
Definition: ExecutorProcessControl.h:165
llvm::orc::ExecutorProcessControl::MemoryAccess::writeUInt32sAsync
virtual void writeUInt32sAsync(ArrayRef< tpctypes::UInt32Write > Ws, WriteResultFn OnWriteComplete)=0
llvm::orc::shared::WrapperFunctionResult
C++ wrapper function result: Same as CWrapperFunctionResult but auto-releases memory.
Definition: WrapperFunctionUtils.h:40
uint64_t
llvm::orc::ExecutorProcessControl::getDispatcher
TaskDispatcher & getDispatcher()
Definition: ExecutorProcessControl.h:198
llvm::orc::UnsupportedExecutorProcessControl::disconnect
Error disconnect() override
Disconnect from the target process.
Definition: ExecutorProcessControl.h:406
move
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
Definition: README.txt:546
llvm::orc::ExecutorProcessControl::MemoryAccess::writeUInt64sAsync
virtual void writeUInt64sAsync(ArrayRef< tpctypes::UInt64Write > Ws, WriteResultFn OnWriteComplete)=0
I
#define I(x, y, z)
Definition: MD5.cpp:59
call
S is passed via registers r2 But gcc stores them to the and then reload them to and r3 before issuing the call(r0 contains the address of the format string)
Definition: README.txt:190
llvm::orc::TaskDispatcher::dispatch
virtual void dispatch(std::unique_ptr< Task > T)=0
Run the given task.
llvm::orc::ExecutorProcessControl::JITDispatchInfo::JITDispatchContext
ExecutorAddr JITDispatchContext
Definition: ExecutorProcessControl.h:176
llvm::orc::ExecutorProcessControl::RunInPlace
Constructs an IncomingWFRHandler from a function object that is callable as void(shared::WrapperFunct...
Definition: ExecutorProcessControl.h:67
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
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:1658
llvm::orc::ExecutorProcessControl::MemoryAccess::writeUInt64s
Error writeUInt64s(ArrayRef< tpctypes::UInt64Write > Ws)
Definition: ExecutorProcessControl.h:147
llvm::orc::ExecutorProcessControl::callWrapperAsync
void callWrapperAsync(ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
Definition: ExecutorProcessControl.h:286
llvm::orc::SelfExecutorProcessControl::callWrapperAsync
void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) override
Run a wrapper function in the executor.
Definition: ExecutorProcessControl.cpp:124
llvm::orc::ExecutorProcessControl::MemoryAccess::writeUInt32s
Error writeUInt32s(ArrayRef< tpctypes::UInt32Write > Ws)
Definition: ExecutorProcessControl.h:139
llvm::orc::SelfExecutorProcessControl
A ExecutorProcessControl implementation targeting the current process.
Definition: ExecutorProcessControl.h:410
llvm::orc::ExecutorProcessControl::MemoryAccess::writeUInt16sAsync
virtual void writeUInt16sAsync(ArrayRef< tpctypes::UInt16Write > Ws, WriteResultFn OnWriteComplete)=0
Triple.h
llvm::orc::ExecutorProcessControl::MemoryAccess::writeUInt16s
Error writeUInt16s(ArrayRef< tpctypes::UInt16Write > Ws)
Definition: ExecutorProcessControl.h:131
llvm::orc::ExecutorProcessControl::runAsMain
virtual Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args)=0
Run function with a main-like signature.
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::orc::ExecutorProcessControl::IncomingWFRHandler::IncomingWFRHandler
IncomingWFRHandler()=default
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
llvm::orc::ExecutorProcessControl::RunInPlace::operator()
IncomingWFRHandler operator()(FnT &&Fn)
Definition: ExecutorProcessControl.h:70
JITLinkMemoryManager.h
llvm::orc::SelfExecutorProcessControl::SelfExecutorProcessControl
SelfExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D, Triple TargetTriple, unsigned PageSize, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr)
Definition: ExecutorProcessControl.cpp:26
llvm::orc::ExecutorProcessControl::callSPSWrapper
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition: ExecutorProcessControl.h:342
llvm::orc::ExecutorProcessControl::BootstrapSymbols
StringMap< ExecutorAddr > BootstrapSymbols
Definition: ExecutorProcessControl.h:366
llvm::orc::ExecutorProcessControl::MemoryAccess::writeBuffers
Error writeBuffers(ArrayRef< tpctypes::BufferWrite > Ws)
Definition: ExecutorProcessControl.h:155
llvm::orc::SelfExecutorProcessControl::lookupSymbols
Expected< std::vector< tpctypes::LookupResult > > lookupSymbols(ArrayRef< LookupRequest > Request) override
Search for symbols in the target process.
Definition: ExecutorProcessControl.cpp:87
llvm::orc::SelfExecutorProcessControl::Create
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.
Definition: ExecutorProcessControl.cpp:48
llvm::orc::ExecutorProcessControl::MemoryAccess
APIs for manipulating memory in the target process.
Definition: ExecutorProcessControl.h:101
llvm::orc::ExecutorProcessControl::getBootstrapSymbolsMap
const StringMap< ExecutorAddr > & getBootstrapSymbolsMap() const
Returns the bootstrap symbol map.
Definition: ExecutorProcessControl.h:222
llvm::orc::UnsupportedExecutorProcessControl
A ExecutorProcessControl instance that asserts if any of its methods are used.
Definition: ExecutorProcessControl.h:372
std
Definition: BitVector.h:838
H
#define H(x, y, z)
Definition: MD5.cpp:58
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:77
ExecutorAddress.h
llvm::orc::ExecutorProcessControl::getTargetTriple
const Triple & getTargetTriple() const
Return the Triple for the target process.
Definition: ExecutorProcessControl.h:201
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1346
llvm::orc::ExecutorProcessControl::loadDylib
virtual Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath)=0
Load the dynamic library at the given path and return a handle to it.
llvm::orc::ExecutorProcessControl::getPageSize
unsigned getPageSize() const
Get the page size for the target process.
Definition: ExecutorProcessControl.h:204
llvm::orc::ExecutorProcessControl::getJITDispatchInfo
const JITDispatchInfo & getJITDispatchInfo() const
Get the JIT dispatch function and context address for the executor.
Definition: ExecutorProcessControl.h:207
llvm::orc::ExecutorProcessControl::callWrapperAsync
virtual void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer)=0
Run a wrapper function in the executor.
llvm::orc::ExecutorProcessControl::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool() const
Return a shared pointer to the SymbolStringPool for this instance.
Definition: ExecutorProcessControl.h:196
llvm::orc::ExecutorProcessControl::D
std::unique_ptr< TaskDispatcher > D
Definition: ExecutorProcessControl.h:359
llvm::orc::ExecutorProcessControl::~ExecutorProcessControl
virtual ~ExecutorProcessControl()
Definition: ExecutorProcessControl.cpp:24
llvm::orc::ExecutorProcessControl::RunAsTask
Constructs an IncomingWFRHandler from a function object by creating a new function object that dispat...
Definition: ExecutorProcessControl.h:80
llvm::orc::ExecutorProcessControl::PageSize
unsigned PageSize
Definition: ExecutorProcessControl.h:362
llvm::orc::UnsupportedExecutorProcessControl::runAsMain
Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.
Definition: ExecutorProcessControl.h:395
TaskDispatch.h
llvm::orc::UnsupportedExecutorProcessControl::lookupSymbols
Expected< std::vector< tpctypes::LookupResult > > lookupSymbols(ArrayRef< LookupRequest > Request) override
Search for symbols in the target process.
Definition: ExecutorProcessControl.h:391
llvm::orc::ExecutorProcessControl::callSPSWrapperAsync
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.
Definition: ExecutorProcessControl.h:314
llvm::orc::ExecutorProcessControl::RunAsTask::operator()
IncomingWFRHandler operator()(FnT &&Fn)
Definition: ExecutorProcessControl.h:85
llvm::orc::ExecutorProcessControl::RunAsTask::RunAsTask
RunAsTask(TaskDispatcher &D)
Definition: ExecutorProcessControl.h:82
llvm::orc::ExecutorProcessControl::lookupSymbols
virtual Expected< std::vector< tpctypes::LookupResult > > lookupSymbols(ArrayRef< LookupRequest > Request)=0
Search for symbols in the target process.
llvm::orc::UnsupportedExecutorProcessControl::callWrapperAsync
void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) override
Run a wrapper function in the executor.
Definition: ExecutorProcessControl.h:400
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::orc::ExecutorProcessControl::callWrapper
shared::WrapperFunctionResult callWrapper(ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
Definition: ExecutorProcessControl.h:298
llvm::orc::ExecutorProcessControl::intern
SymbolStringPtr intern(StringRef SymName)
Intern a symbol name in the SymbolStringPool.
Definition: ExecutorProcessControl.h:193
llvm::orc::SelfExecutorProcessControl::runAsMain
Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.
Definition: ExecutorProcessControl.cpp:118