LLVM: include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H

14#define LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H

15

28

29#include

30#include

31#include

32

34

36

37

40public:

41

42

43

44

45

46

47

50 public:

52 explicit operator bool() const { return !!H; }

54 private:

56 : H(std::forward<FnT>(Fn)) {}

57

59 };

60

61

62

63

64

65

66

68 public:

69 template

73 };

74

75

76

77

78

79

81 public:

83

84 template

87 [&D = this->D, Fn = std::move(Fn)]

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

101

106

108 std::unique_ptr D)

110

112

113

114

116 assert(ES && "No ExecutionSession associated yet");

117 return *ES;

118 }

119

120

122

123

125

127

128

130

131

133

134

136

137

142

143

148

149

154

155

159

160

161 template <typename T, typename SPSTagT>

163 Val = std::nullopt;

164

168

169 T Tmp;

175

176 Val = std::move(Tmp);

178 }

179

180

184

185

186

187

189 ArrayRef<std::pair<ExecutorAddr &, StringRef>> Pairs) const {

190 for (const auto &KV : Pairs) {

194 "\" not found "

195 "in bootstrap symbols map",

197

198 KV.first = I->second;

199 }

201 }

202

203

206

207

208

210

211

212

214 int Arg) = 0;

215

216

217

218

219

220

221

222

223

227

228

229

230 template <typename RunPolicyT, typename FnT>

234 WrapperFnAddr, Runner(std::forward(OnComplete)), ArgBuffer);

235 }

236

237

238

239 template

243 std::forward(OnComplete), ArgBuffer);

244 }

245

246

247

248

249

250

251

254 std::promiseshared::WrapperFunctionResult RP;

255 auto RF = RP.get_future();

259 RP.set_value(std::move(R));

260 }, ArgBuffer);

261 return RF.get();

262 }

263

264

265

266 template <typename SPSSignature, typename RunPolicyT, typename SendResultT,

267 typename... ArgTs>

269 SendResultT &&SendResult, const ArgTs &...Args) {

271 [this, WrapperFnAddr, Runner = std::move(Runner)]

272 (auto &&SendResult, const char *ArgData, size_t ArgSize) mutable {

274 std::move(SendResult),

276 },

277 std::forward(SendResult), Args...);

278 }

279

280

281

282 template <typename SPSSignature, typename SendResultT, typename... ArgTs>

284 const ArgTs &...Args) {

286 std::forward(SendResult),

287 Args...);

288 }

289

290

291

292

293

294

295 template <typename SPSSignature, typename... WrapperCallArgTs>

297 WrapperCallArgTs &&...WrapperCallArgs) {

299 [this, WrapperFnAddr](const char *ArgData, size_t ArgSize) {

301 },

302 std::forward(WrapperCallArgs)...);

303 }

304

305

306

307

309

310protected:

311

312 std::shared_ptr SSP;

313 std::unique_ptr D;

323};

324

325}

326

327#endif

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 WrapperFunctionResults – either return values from callWrapper* calls,...

Definition ExecutorProcessControl.h:48

void operator()(shared::WrapperFunctionResult WFR)

Definition ExecutorProcessControl.h:53

IncomingWFRHandler()=default

friend class ExecutorProcessControl

Definition ExecutorProcessControl.h:49

Constructs an IncomingWFRHandler from a function object by creating a new function object that dispat...

Definition ExecutorProcessControl.h:80

IncomingWFRHandler operator()(FnT &&Fn)

Definition ExecutorProcessControl.h:85

RunAsTask(TaskDispatcher &D)

Definition ExecutorProcessControl.h:82

Constructs an IncomingWFRHandler from a function object that is callable as void(shared::WrapperFunct...

Definition ExecutorProcessControl.h:67

IncomingWFRHandler operator()(FnT &&Fn)

Definition ExecutorProcessControl.h:70

jitlink::JITLinkMemoryManager & getMemMgr() const

Return a JITLinkMemoryManager for the target process.

Definition ExecutorProcessControl.h:144

shared::WrapperFunctionResult callWrapper(ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer)

Run a wrapper function in the executor.

Definition ExecutorProcessControl.h:252

void callWrapperAsync(ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)

Run a wrapper function in the executor.

Definition ExecutorProcessControl.h:240

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.

Definition ExecutorProcessControl.h:268

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.

Definition ExecutorProcessControl.h:162

std::unique_ptr< TaskDispatcher > D

Definition ExecutorProcessControl.h:313

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:283

virtual void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer)=0

Run a wrapper function in the executor.

const StringMap< std::vector< char > > & getBootstrapMap() const

Returns the bootstrap map.

Definition ExecutorProcessControl.h:156

JITDispatchInfo JDI

Definition ExecutorProcessControl.h:317

Triple TargetTriple

Definition ExecutorProcessControl.h:315

std::shared_ptr< SymbolStringPool > SSP

Definition ExecutorProcessControl.h:312

const Triple & getTargetTriple() const

Return the Triple for the target process.

Definition ExecutorProcessControl.h:129

StringMap< ExecutorAddr > BootstrapSymbols

Definition ExecutorProcessControl.h:322

SymbolStringPtr intern(StringRef SymName)

Intern a symbol name in the SymbolStringPool.

Definition ExecutorProcessControl.h:121

virtual Error disconnect()=0

Disconnect from the target process.

StringMap< std::vector< char > > BootstrapMap

Definition ExecutorProcessControl.h:321

std::shared_ptr< SymbolStringPool > getSymbolStringPool() const

Return a shared pointer to the SymbolStringPool for this instance.

Definition ExecutorProcessControl.h:124

const StringMap< ExecutorAddr > & getBootstrapSymbolsMap() const

Returns the bootstrap symbol map.

Definition ExecutorProcessControl.h:181

virtual Expected< int32_t > runAsVoidFunction(ExecutorAddr VoidFnAddr)=0

Run function with a int (*)(void) signature.

jitlink::JITLinkMemoryManager * MemMgr

Definition ExecutorProcessControl.h:319

unsigned getPageSize() const

Get the page size for the target process.

Definition ExecutorProcessControl.h:132

unsigned PageSize

Definition ExecutorProcessControl.h:316

const JITDispatchInfo & getJITDispatchInfo() const

Get the JIT dispatch function and context address for the executor.

Definition ExecutorProcessControl.h:135

Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)

Run a wrapper function using SPS to serialize the arguments and deserialize the results.

Definition ExecutorProcessControl.h:296

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:231

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:188

DylibManager * DylibMgr

Definition ExecutorProcessControl.h:320

ExecutionSession & getExecutionSession()

Return the ExecutionSession associated with this instance.

Definition ExecutorProcessControl.h:115

DylibManager & getDylibMgr() const

Return the DylibManager for the target process.

Definition ExecutorProcessControl.h:150

ExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D)

Definition ExecutorProcessControl.h:107

MemoryAccess & getMemoryAccess() const

Return a MemoryAccess object for the target process.

Definition ExecutorProcessControl.h:138

MemoryAccess * MemAccess

Definition ExecutorProcessControl.h:318

friend class ExecutionSession

Definition ExecutorProcessControl.h:39

ExecutionSession * ES

Definition ExecutorProcessControl.h:314

TaskDispatcher & getDispatcher()

Definition ExecutorProcessControl.h:126

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.

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...

Definition ExecutorProcessControl.h:102

ExecutorAddr JITDispatchContext

Definition ExecutorProcessControl.h:104

ExecutorAddr JITDispatchFunction

Definition ExecutorProcessControl.h:103