Go to the documentation of this file.
13 #ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
14 #define LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
34 class ExecutionSession;
35 class SymbolLookupSet;
52 explicit operator bool()
const {
return !!
H; }
56 :
H(
std::forward<FnT>(Fn)) {}
69 template <
typename FnT>
84 template <
typename FnT>
93 },
"WFR handler task"));
124 std::promise<MSVCPError> ResultP;
125 auto ResultF = ResultP.get_future();
128 return ResultF.get();
132 std::promise<MSVCPError> ResultP;
133 auto ResultF = ResultP.get_future();
136 return ResultF.get();
140 std::promise<MSVCPError> ResultP;
141 auto ResultF = ResultP.get_future();
144 return ResultF.get();
148 std::promise<MSVCPError> ResultP;
149 auto ResultF = ResultP.get_future();
152 return ResultF.get();
156 std::promise<MSVCPError> ResultP;
157 auto ResultF = ResultP.get_future();
160 return ResultF.get();
180 std::unique_ptr<TaskDispatcher>
D)
188 assert(
ES &&
"No ExecutionSession associated yet");
230 ArrayRef<std::pair<ExecutorAddr &, StringRef>> Pairs)
const {
231 for (
const auto &KV : Pairs) {
234 return make_error<StringError>(
"Symbol \"" + KV.second +
236 "in bootstrap symbols map",
239 KV.first =
I->second;
280 IncomingWFRHandler OnComplete,
285 template <
typename RunPolicyT,
typename FnT>
289 WrapperFnAddr, Runner(std::forward<FnT>(OnComplete)), ArgBuffer);
294 template <
typename FnT>
298 std::forward<FnT>(OnComplete), ArgBuffer);
309 std::promise<shared::WrapperFunctionResult>
RP;
310 auto RF =
RP.get_future();
321 template <
typename SPSSignature,
typename RunPolicyT,
typename SendResultT,
324 SendResultT &&SendResult,
const ArgTs &...
Args) {
326 [
this, WrapperFnAddr, Runner =
std::move(Runner)]
327 (
auto &&SendResult,
const char *ArgData,
size_t ArgSize)
mutable {
332 std::forward<SendResultT>(SendResult),
Args...);
337 template <
typename SPSSignature,
typename SendResultT,
typename... ArgTs>
339 const ArgTs &...
Args) {
340 callSPSWrapperAsync<SPSSignature>(
RunAsTask(*
D), WrapperFnAddr,
341 std::forward<SendResultT>(SendResult),
350 template <
typename SPSSignature,
typename... WrapperCallArgTs>
352 WrapperCallArgTs &&...WrapperCallArgs) {
354 [
this, WrapperFnAddr](
const char *ArgData,
size_t ArgSize) {
357 std::forward<WrapperCallArgTs>(WrapperCallArgs)...);
367 std::shared_ptr<SymbolStringPool>
SSP;
368 std::unique_ptr<TaskDispatcher>
D;
384 std::shared_ptr<SymbolStringPool>
SSP =
nullptr,
385 std::unique_ptr<TaskDispatcher>
D =
nullptr,
386 const std::string &TT =
"",
unsigned PageSize = 0)
432 std::shared_ptr<SymbolStringPool>
SSP, std::unique_ptr<TaskDispatcher>
D,
434 std::unique_ptr<jitlink::JITLinkMemoryManager>
MemMgr);
442 Create(std::shared_ptr<SymbolStringPool>
SSP =
nullptr,
443 std::unique_ptr<TaskDispatcher>
D =
nullptr,
444 std::unique_ptr<jitlink::JITLinkMemoryManager>
MemMgr =
nullptr);
481 jitDispatchViaWrapperFunctionManager(
void *Ctx,
const void *FnTag,
482 const char *
Data,
size_t Size);
484 std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
485 char GlobalManglingPrefix = 0;
491 #endif // LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
Represents an address in the executor process.
jitlink::JITLinkMemoryManager * MemMgr
This is an optimization pass for GlobalISel generic memory operations.
std::unique_ptr< GenericNamedTask > makeGenericNamedTask(FnT &&Fn, std::string Desc)
Create a generic named task from a std::string description.
unique_function is a type-erasing functor similar to std::function.
void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
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...
MemoryAccess & getMemoryAccess() const
Return a MemoryAccess object for the target process.
LookupRequest(tpctypes::DylibHandle Handle, const SymbolLookupSet &Symbols)
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Pointer to a pooled string representing a symbol name.
Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath) override
Load the dynamic library at the given path and return a handle to it.
static ErrorSuccess success()
Create a success value.
Triple - Helper class for working with autoconf configuration names.
Error disconnect() override
Disconnect from the target process.
ExecutionSession & getExecutionSession()
Return the ExecutionSession associated with this instance.
Abstract base for classes that dispatch ORC Tasks.
ExecutorProcessControl supports interaction with a JIT target process.
ExecutorAddr JITDispatchFunction
Runs all tasks on the current thread.
std::shared_ptr< SymbolStringPool > SSP
Manages allocations of JIT memory.
Tagged union holding either a T or a Error.
virtual Error disconnect()=0
Disconnect from the target process.
tpctypes::DylibHandle Handle
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
UnsupportedExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP=nullptr, std::unique_ptr< TaskDispatcher > D=nullptr, const std::string &TT="", unsigned PageSize=0)
jitlink::JITLinkMemoryManager & getMemMgr() const
Return a JITLinkMemoryManager for the target process.
String pool for symbol names used by the JIT.
ExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D)
virtual void writeBuffersAsync(ArrayRef< tpctypes::BufferWrite > Ws, WriteResultFn OnWriteComplete)=0
virtual void writeUInt8sAsync(ArrayRef< tpctypes::UInt8Write > Ws, WriteResultFn OnWriteComplete)=0
Error writeUInt8s(ArrayRef< tpctypes::UInt8Write > Ws)
void operator()(shared::WrapperFunctionResult WFR)
const SymbolLookupSet & Symbols
A handler or incoming WrapperFunctionResults – either return values from callWrapper* calls,...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
virtual Expected< int32_t > runAsIntFunction(ExecutorAddr IntFnAddr, int Arg)=0
Run function with a int (*)(int) signature.
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 ...
Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath) override
Load the dynamic library at the given path and return a handle to it.
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.
virtual void writeUInt32sAsync(ArrayRef< tpctypes::UInt32Write > Ws, WriteResultFn OnWriteComplete)=0
C++ wrapper function result: Same as CWrapperFunctionResult but auto-releases memory.
Expected< int32_t > runAsVoidFunction(ExecutorAddr VoidFnAddr) override
Run function with a int (*)(void) signature.
TaskDispatcher & getDispatcher()
Error disconnect() override
Disconnect from the target process.
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
Expected< int32_t > runAsIntFunction(ExecutorAddr IntFnAddr, int Arg) override
Run function with a int (*)(int) signature.
virtual void writeUInt64sAsync(ArrayRef< tpctypes::UInt64Write > Ws, WriteResultFn OnWriteComplete)=0
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)
virtual void dispatch(std::unique_ptr< Task > T)=0
Run the given task.
virtual Expected< int32_t > runAsVoidFunction(ExecutorAddr VoidFnAddr)=0
Run function with a int (*)(void) signature.
ExecutorAddr JITDispatchContext
Constructs an IncomingWFRHandler from a function object that is callable as void(shared::WrapperFunct...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Error writeUInt64s(ArrayRef< tpctypes::UInt64Write > Ws)
void callWrapperAsync(ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) override
Run a wrapper function in the executor.
Error writeUInt32s(ArrayRef< tpctypes::UInt32Write > Ws)
A ExecutorProcessControl implementation targeting the current process.
virtual void writeUInt16sAsync(ArrayRef< tpctypes::UInt16Write > Ws, WriteResultFn OnWriteComplete)=0
Error writeUInt16s(ArrayRef< tpctypes::UInt16Write > Ws)
virtual Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args)=0
Run function with a main-like signature.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
IncomingWFRHandler()=default
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
IncomingWFRHandler operator()(FnT &&Fn)
SelfExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D, Triple TargetTriple, unsigned PageSize, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr)
Expected< int32_t > runAsIntFunction(ExecutorAddr IntFnAddr, int Arg) override
Run function with a int (*)(int) signature.
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
StringMap< ExecutorAddr > BootstrapSymbols
Error writeBuffers(ArrayRef< tpctypes::BufferWrite > Ws)
Expected< std::vector< tpctypes::LookupResult > > lookupSymbols(ArrayRef< LookupRequest > Request) override
Search for symbols in the target process.
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.
APIs for manipulating memory in the target process.
const StringMap< ExecutorAddr > & getBootstrapSymbolsMap() const
Returns the bootstrap symbol map.
A ExecutorProcessControl instance that asserts if any of its methods are used.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
const Triple & getTargetTriple() const
Return the Triple for the target process.
Lightweight error class with error context and mandatory checking.
An ExecutionSession represents a running JIT program.
virtual Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath)=0
Load the dynamic library at the given path and return a handle to it.
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.
virtual void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer)=0
Run a wrapper function in the executor.
std::shared_ptr< SymbolStringPool > getSymbolStringPool() const
Return a shared pointer to the SymbolStringPool for this instance.
std::unique_ptr< TaskDispatcher > D
virtual ~ExecutorProcessControl()
Constructs an IncomingWFRHandler from a function object by creating a new function object that dispat...
Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.
Expected< std::vector< tpctypes::LookupResult > > lookupSymbols(ArrayRef< LookupRequest > Request) override
Search for symbols in the target process.
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.
IncomingWFRHandler operator()(FnT &&Fn)
RunAsTask(TaskDispatcher &D)
virtual Expected< std::vector< tpctypes::LookupResult > > lookupSymbols(ArrayRef< LookupRequest > Request)=0
Search for symbols in the target process.
void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) override
Run a wrapper function in the executor.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
shared::WrapperFunctionResult callWrapper(ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
Expected< int32_t > runAsVoidFunction(ExecutorAddr VoidFnAddr) override
Run function with a int (*)(void) signature.
SymbolStringPtr intern(StringRef SymName)
Intern a symbol name in the SymbolStringPool.
Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.