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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#ifndef LLVM_EXECUTIONENGINE_ORC_LAZYREEXPORTS_H

17#define LLVM_EXECUTIONENGINE_ORC_LAZYREEXPORTS_H

18

25

26namespace llvm {

27

29

30namespace orc {

31

32

33

34

35

36

37

38

39

41public:

44

48

49

50

54

58

60

61protected:

64

69

75

76private:

77 using ReexportsMap = std::map<ExecutorAddr, ReexportsEntry>;

78

79 using NotifiersMap = std::map<ExecutorAddr, NotifyResolvedFunction>;

80

81 std::mutex LCTMMutex;

85 ReexportsMap Reexports;

86 NotifiersMap Notifiers;

87};

88

89

91private:

93

97

98 template Error init() {

102 NotifyLandingResolved) {

104 std::move(NotifyLandingResolved));

105 });

106

107 if (!TP)

108 return TP.takeError();

109

110 this->TP = std::move(*TP);

113 }

114

115 std::unique_ptr TP;

116

117public:

118

119

120 template

123 auto LLCTM = std::unique_ptr(

124 new LocalLazyCallThroughManager(ES, ErrorHandlerAddr));

125

126 if (auto Err = LLCTM->init())

127 return std::move(Err);

128

129 return std::move(LLCTM);

130 }

131};

132

133

134

137 ExecutorAddr ErrorHandlerAddr);

138

139

140

141

142

143

145public:

151

153

154private:

155 void materialize(std::unique_ptr R) override;

159

165};

166

167

168

169

170inline std::unique_ptr

175 return std::make_unique(

176 LCTManager, RSManager, SourceJD, std::move(CallableAliases), SrcJDLoc);

177}

178

180

181 friend std::unique_ptr

183

184public:

190

192 public:

194

196

197

200

201

202

205

206

208

209

210

211

212

214 };

215

217 Expected<std::vector> EntryAddrs)>;

221

222

223

227

230

234

235private:

236 class MU;

238

239 using ResolveSendResultFn =

241

245

246 std::unique_ptr

248

249 void emitReentryTrampolines(std::unique_ptr MR,

251 void emitRedirectableSymbols(

252 std::unique_ptr MR,

254 Expected<std::vector> ReentryPoints);

255 void resolve(ResolveSendResultFn SendResult, ExecutorAddr ReentryStubAddr);

256

261

264};

265

266

267

268

269inline std::unique_ptr

271 return LRM.createLazyReexports(std::move(Reexports));

272}

273

276public:

279

280 static std::shared_ptr

283 public:

285 RecordExecutionFunction RecordExec)

287 };

288

289 auto Instance =

290 std::make_shared<make_shared_helper>(ES, std::move(RecordExec));

291 Instance->WeakThis = Instance;

292 return Instance;

293 }

294

299

302

305

307

309

311 std::vector<std::pair<std::string, SymbolStringPtr>> NewSuggestions);

312

313private:

316 : ES(ES), RecordExec(std::move(RecordExec)) {}

317

318 bool doNextSpeculativeLookup();

319

320 class SpeculateTask;

321

322 using KeyToFunctionBodiesMap =

324

326 RecordExecutionFunction RecordExec;

327 std::weak_ptr WeakThis;

329 std::deque<std::pair<std::string, SymbolStringPtr>> SpeculateSuggestions;

330 bool SpeculateTaskActive = false;

331};

332

333}

334}

335

336#endif

static StringRef getName(Value *V)

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.

StringRef - Represent a constant reference to a string, i.e.

Triple - Helper class for working with autoconf configuration names.

An ExecutionSession represents a running JIT program.

Represents an address in the executor process.

Represents a JIT'd dynamic library.

Manages a set of 'lazy call-through' trampolines.

Definition LazyReexports.h:40

LLVM_ABI ExecutorAddr reportCallThroughError(Error Err)

TrampolinePool::NotifyLandingResolvedFunction NotifyLandingResolvedFunction

Definition LazyReexports.h:62

LLVM_ABI Expected< ReexportsEntry > findReexport(ExecutorAddr TrampolineAddr)

LLVM_ABI Error notifyResolved(ExecutorAddr TrampolineAddr, ExecutorAddr ResolvedAddr)

void setTrampolinePool(TrampolinePool &TP)

Definition LazyReexports.h:74

LLVM_ABI void resolveTrampolineLandingAddress(ExecutorAddr TrampolineAddr, TrampolinePool::NotifyLandingResolvedFunction NotifyLandingResolved)

unique_function< Error(ExecutorAddr ResolvedAddr)> NotifyResolvedFunction

Definition LazyReexports.h:42

virtual ~LazyCallThroughManager()=default

LLVM_ABI LazyCallThroughManager(ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr, TrampolinePool *TP)

LLVM_ABI Expected< ExecutorAddr > getCallThroughTrampoline(JITDylib &SourceJD, SymbolStringPtr SymbolName, NotifyResolvedFunction NotifyResolved)

Definition LazyReexports.h:191

virtual void onLazyReexportCalled(const CallThroughInfo &CTI)=0

Called outside the session lock when a lazy reexport is called.

virtual void onLazyReexportsCreated(JITDylib &JD, ResourceKey K, const SymbolAliasMap &Reexports)=0

Called under the session lock when new lazy reexports are created.

virtual Error onLazyReexportsRemoved(JITDylib &JD, ResourceKey K)=0

Called under the session lock when lazy reexports are removed.

LazyReexportsManager::CallThroughInfo CallThroughInfo

Definition LazyReexports.h:193

virtual void onLazyReexportsTransfered(JITDylib &JD, ResourceKey DstK, ResourceKey SrcK)=0

Called under the session lock when lazy reexports have their ownership transferred to a new ResourceK...

void handleTransferResources(JITDylib &JD, ResourceKey DstK, ResourceKey SrcK) override

This function will be called inside the session lock.

unique_function< void( Expected< std::vector< ExecutorSymbolDef > > EntryAddrs)> OnTrampolinesReadyFn

Definition LazyReexports.h:216

friend std::unique_ptr< MaterializationUnit > lazyReexports(LazyReexportsManager &, SymbolAliasMap)

Define lazy-reexports based on the given SymbolAliasMap.

Definition LazyReexports.h:270

Error handleRemoveResources(JITDylib &JD, ResourceKey K) override

This function will be called outside the session lock.

unique_function< void(ResourceTrackerSP RT, size_t NumTrampolines, OnTrampolinesReadyFn OnTrampolinesReady)> EmitTrampolinesFn

Definition LazyReexports.h:218

LazyReexportsManager & operator=(LazyReexportsManager &&)=delete

LazyReexportsManager(LazyReexportsManager &&)=delete

static Expected< std::unique_ptr< LazyReexportsManager > > Create(EmitTrampolinesFn EmitTrampolines, RedirectableSymbolManager &RSMgr, JITDylib &PlatformJD, Listener *L=nullptr)

Create a LazyReexportsManager that uses the ORC runtime for reentry.

LazyReexportsMaterializationUnit(LazyCallThroughManager &LCTManager, RedirectableSymbolManager &RSManager, JITDylib &SourceJD, SymbolAliasMap CallableAliases, ImplSymbolMap *SrcJDLoc)

static Expected< std::unique_ptr< LocalLazyCallThroughManager > > Create(ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr)

Create a LocalLazyCallThroughManager using the given ABI.

Definition LazyReexports.h:122

static Expected< std::unique_ptr< LocalTrampolinePool > > Create(ResolveLandingFunction ResolveLanding)

Creates a LocalTrampolinePool with the given RunCallback function.

MaterializationUnit(Interface I)

Base class for managing redirectable symbols in which a call gets redirected to another symbol in run...

Listens for ResourceTracker operations.

Definition LazyReexports.h:275

Error onLazyReexportsRemoved(JITDylib &JD, ResourceKey K) override

Called under the session lock when lazy reexports are removed.

void onLazyReexportsCreated(JITDylib &JD, ResourceKey K, const SymbolAliasMap &Reexports) override

Called under the session lock when new lazy reexports are created.

void onLazyReexportCalled(const CallThroughInfo &CTI) override

Called outside the session lock when a lazy reexport is called.

void onLazyReexportsTransfered(JITDylib &JD, ResourceKey DstK, ResourceKey SrcK) override

Called under the session lock when lazy reexports have their ownership transferred to a new ResourceK...

static std::shared_ptr< SimpleLazyReexportsSpeculator > Create(ExecutionSession &ES, RecordExecutionFunction RecordExec={})

Definition LazyReexports.h:281

unique_function< void(const CallThroughInfo &CTI)> RecordExecutionFunction

Definition LazyReexports.h:277

SimpleLazyReexportsSpeculator(SimpleLazyReexportsSpeculator &&)=delete

void addSpeculationSuggestions(std::vector< std::pair< std::string, SymbolStringPtr > > NewSuggestions)

SimpleLazyReexportsSpeculator & operator=(SimpleLazyReexportsSpeculator &&)=delete

Pointer to a pooled string representing a symbol name.

Base class for pools of compiler re-entry trampolines.

unique_function< void(ExecutorAddr) const > NotifyLandingResolvedFunction

unique_function is a type-erasing functor similar to std::function.

IntrusiveRefCntPtr< JITDylib > JITDylibSP

IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP

LLVM_ABI Expected< std::unique_ptr< LazyCallThroughManager > > createLocalLazyCallThroughManager(const Triple &T, ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr)

Create a LocalLazyCallThroughManager from the given triple and execution session.

std::unique_ptr< LazyReexportsMaterializationUnit > lazyReexports(LazyCallThroughManager &LCTManager, RedirectableSymbolManager &RSManager, JITDylib &SourceJD, SymbolAliasMap CallableAliases, ImplSymbolMap *SrcJDLoc=nullptr)

Define lazy-reexports based on the given SymbolAliasMap.

Definition LazyReexports.h:171

DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap

A map of Symbols to (Symbol, Flags) pairs.

This is an optimization pass for GlobalISel generic memory operations.

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.

Definition LazyReexports.h:65

JITDylib * SourceJD

Definition LazyReexports.h:66

SymbolStringPtr SymbolName

Definition LazyReexports.h:67

Definition LazyReexports.h:185

JITDylibSP JD

Definition LazyReexports.h:186

SymbolStringPtr BodyName

Definition LazyReexports.h:188

SymbolStringPtr Name

Definition LazyReexports.h:187