13#ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
14#define LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
57 explicit operator bool()
const {
return !!H; }
74 template <
typename FnT>
89 template <
typename FnT>
92 [&D = this->D, Fn = std::move(Fn)]
96 [Fn = std::move(Fn), WFR = std::move(WFR)]()
mutable {
98 },
"WFR handler task"));
113 std::unique_ptr<TaskDispatcher>
D)
121 assert(
ES &&
"No ExecutionSession associated yet");
159 template <
typename T,
typename SPSTagT>
174 Val = std::move(Tmp);
187 ArrayRef<std::pair<ExecutorAddr &, StringRef>> Pairs)
const {
188 for (
const auto &KV : Pairs) {
193 "in bootstrap symbols map",
196 KV.first =
I->second;
228 template <
typename RunPolicyT,
typename FnT>
232 WrapperFnAddr, Runner(std::forward<FnT>(OnComplete)), ArgBuffer);
237 template <
typename FnT>
241 std::forward<FnT>(OnComplete), ArgBuffer);
252 std::promise<shared::WrapperFunctionBuffer> RP;
253 auto RF = RP.get_future();
257 RP.set_value(std::move(R));
264 template <
typename SPSSignature,
typename RunPolicyT,
typename SendResultT,
267 SendResultT &&SendResult,
const ArgTs &...Args) {
269 [
this, WrapperFnAddr, Runner = std::move(Runner)]
270 (
auto &&SendResult,
const char *ArgData,
size_t ArgSize)
mutable {
272 std::move(SendResult),
275 std::forward<SendResultT>(SendResult), Args...);
280 template <
typename SPSSignature,
typename SendResultT,
typename... ArgTs>
282 const ArgTs &...Args) {
284 std::forward<SendResultT>(SendResult),
293 template <
typename SPSSignature,
typename... WrapperCallArgTs>
295 WrapperCallArgTs &&...WrapperCallArgs) {
297 [
this, WrapperFnAddr](
const char *ArgData,
size_t ArgSize) {
300 std::forward<WrapperCallArgTs>(WrapperCallArgs)...);
310 std::shared_ptr<SymbolStringPool>
SSP;
311 std::unique_ptr<TaskDispatcher>
D;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
Manages allocations of JIT memory.
An ExecutionSession represents a running JIT program.
Represents an address in the executor process.
A handler or incoming WrapperFunctionBuffers – either return values from callWrapper* calls,...
void operator()(shared::WrapperFunctionBuffer WFR)
IncomingWFRHandler()=default
friend class ExecutorProcessControl
Constructs an IncomingWFRHandler from a function object by creating a new function object that dispat...
IncomingWFRHandler operator()(FnT &&Fn)
RunAsTask(TaskDispatcher &D)
Constructs an IncomingWFRHandler from a function object that is callable as void(shared::WrapperFunct...
IncomingWFRHandler operator()(FnT &&Fn)
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< std::unique_ptr< MemoryAccess > > createDefaultMemoryAccess()=0
Create a default MemoryAccess for the target process.
const StringMap< std::vector< char > > & getBootstrapMap() const
Returns the bootstrap map.
virtual Expected< std::unique_ptr< DylibManager > > createDefaultDylibMgr()=0
Create a default DylibManager for the target process.
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.
shared::WrapperFunctionBuffer callWrapper(ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
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.
unsigned getPageSize() const
Get the page size for the target process.
virtual Expected< std::unique_ptr< jitlink::JITLinkMemoryManager > > createDefaultMemoryManager()=0
Create a default JITLinkMemoryManager 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)
friend class ExecutionSession
TaskDispatcher & getDispatcher()
virtual ~ExecutorProcessControl()
APIs for manipulating memory in the target process.
Pointer to a pooled string representing a symbol name.
Abstract base for classes that dispatch ORC Tasks.
A utility class for serializing to a blob from a variadic list.
C++ wrapper function buffer: Same as CWrapperFunctionBuffer but auto-releases memory.
unique_function is a type-erasing functor similar to std::function.
std::unique_ptr< GenericNamedTask > makeGenericNamedTask(FnT &&Fn, std::string Desc)
Create a generic named task from a std::string description.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
Contains the address of the dispatch function and context that the ORC runtime can use to call functi...
ExecutorAddr JITDispatchContext
ExecutorAddr JITDispatchFunction