llvm.org GIT mirror llvm / 73bcd8b
[ORC] Create a new SymbolStringPool by default in ExecutionSession constructor. This makes the common case of constructing an ExecutionSession tidier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329013 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 1 year, 3 months ago
16 changed file(s) with 29 addition(s) and 57 deletion(s). Raw diff Collapse all Expand all
3737
3838 class KaleidoscopeJIT {
3939 private:
40 SymbolStringPool SSP;
4140 ExecutionSession ES;
4241 std::shared_ptr Resolver;
4342 std::unique_ptr TM;
4746
4847 public:
4948 KaleidoscopeJIT()
50 : ES(SSP),
51 Resolver(createLegacyLookupResolver(
49 : Resolver(createLegacyLookupResolver(
5250 [this](const std::string &Name) -> JITSymbol {
5351 if (auto Sym = CompileLayer.findSymbol(Name, false))
5452 return Sym;
4141
4242 class KaleidoscopeJIT {
4343 private:
44 SymbolStringPool SSP;
4544 ExecutionSession ES;
4645 std::shared_ptr Resolver;
4746 std::unique_ptr TM;
5655
5756 public:
5857 KaleidoscopeJIT()
59 : ES(SSP),
60 Resolver(createLegacyLookupResolver(
58 : Resolver(createLegacyLookupResolver(
6159 [this](const std::string &Name) -> JITSymbol {
6260 if (auto Sym = OptimizeLayer.findSymbol(Name, false))
6361 return Sym;
4545
4646 class KaleidoscopeJIT {
4747 private:
48 SymbolStringPool SSP;
4948 ExecutionSession ES;
5049 std::map> Resolvers;
5150 std::unique_ptr TM;
6362
6463 public:
6564 KaleidoscopeJIT()
66 : ES(SSP), TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
65 : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
6766 ObjectLayer(ES,
6867 [this](VModuleKey K) {
6968 return RTDyldObjectLinkingLayer::Resources{
7171
7272 class KaleidoscopeJIT {
7373 private:
74 SymbolStringPool SSP;
7574 ExecutionSession ES;
7675 std::shared_ptr Resolver;
7776 std::unique_ptr TM;
8988
9089 public:
9190 KaleidoscopeJIT()
92 : ES(SSP),
93 Resolver(createLegacyLookupResolver(
91 : Resolver(createLegacyLookupResolver(
9492 [this](const std::string &Name) -> JITSymbol {
9593 if (auto Sym = IndirectStubsMgr->findStub(Name, false))
9694 return Sym;
7676
7777 class KaleidoscopeJIT {
7878 private:
79 SymbolStringPool SSP;
8079 ExecutionSession ES;
8180 std::shared_ptr Resolver;
8281 std::unique_ptr TM;
9594
9695 public:
9796 KaleidoscopeJIT(MyRemote &Remote)
98 : ES(SSP),
99 Resolver(createLegacyLookupResolver(
97 : Resolver(createLegacyLookupResolver(
10098 [this](const std::string &Name) -> JITSymbol {
10199 if (auto Sym = IndirectStubsMgr->findStub(Name, false))
102100 return Sym;
4343 using CompileLayerT = IRCompileLayer;
4444
4545 KaleidoscopeJIT()
46 : ES(SSP),
47 Resolver(createLegacyLookupResolver(
46 : Resolver(createLegacyLookupResolver(
4847 [this](const std::string &Name) {
4948 return ObjectLayer.findSymbol(Name, true);
5049 },
125124 return nullptr;
126125 }
127126
128 SymbolStringPool SSP;
129127 ExecutionSession ES;
130128 std::shared_ptr Resolver;
131129 std::unique_ptr TM;
326326 /// @brief Construct an ExecutionEngine.
327327 ///
328328 /// SymbolStringPools may be shared between ExecutionSessions.
329 ExecutionSession(SymbolStringPool &SSP);
329 ExecutionSession(std::shared_ptr SSP = nullptr)
330 : SSP(std::move(SSP)) {}
330331
331332 /// @brief Returns the SymbolStringPool for this ExecutionSession.
332 SymbolStringPool &getSymbolStringPool() const { return SSP; }
333 SymbolStringPool &getSymbolStringPool() const { return *SSP; }
333334
334335 /// @brief Set the error reporter function.
335336 void setErrorReporter(ErrorReporter ReportError) {
342343 void reportError(Error Err) { ReportError(std::move(Err)); }
343344
344345 /// @brief Allocate a module key for a new module to add to the JIT.
345 VModuleKey allocateVModule();
346 VModuleKey allocateVModule() { return ++LastKey; }
346347
347348 /// @brief Return a module key to the ExecutionSession so that it can be
348349 /// re-used. This should only be done once all resources associated
349350 //// with the original key have been released.
350 void releaseVModule(VModuleKey Key);
351 void releaseVModule(VModuleKey Key) { /* FIXME: Recycle keys */ }
351352
352353 public:
353354 static void logErrorsToStdErr(Error Err);
354355
355 SymbolStringPool &SSP;
356 std::shared_ptr SSP;
356357 VModuleKey LastKey = 0;
357358 ErrorReporter ReportError = logErrorsToStdErr;
358359 };
525525 return ResultMap.takeError();
526526 }
527527
528 ExecutionSession::ExecutionSession(SymbolStringPool &SSP) : SSP(SSP) {}
529
530 VModuleKey ExecutionSession::allocateVModule() { return ++LastKey; }
531
532 void ExecutionSession::releaseVModule(VModuleKey VMod) {
533 // FIXME: Recycle keys.
534 }
535
536528 void ExecutionSession::logErrorsToStdErr(Error Err) {
537529 logAllUnhandledErrors(std::move(Err), errs(), "JIT session error: ");
538530 }
199199 OrcCBindingsStack(TargetMachine &TM,
200200 std::unique_ptr CCMgr,
201201 IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
202 : ES(SSP), DL(TM.createDataLayout()),
202 : DL(TM.createDataLayout()),
203203 IndirectStubsMgr(IndirectStubsMgrBuilder()), CCMgr(std::move(CCMgr)),
204204 ObjectLayer(ES,
205205 [this](orc::VModuleKey K) {
420420 logAllUnhandledErrors(std::move(Err), errs(), "ORC error: ");
421421 };
422422
423 orc::SymbolStringPool SSP;
424423 orc::ExecutionSession ES;
425424
426425 DataLayout DL;
224224 OrcMCJITReplacement(std::shared_ptr MemMgr,
225225 std::shared_ptr ClientResolver,
226226 std::unique_ptr TM)
227 : ExecutionEngine(TM->createDataLayout()), ES(SSP), TM(std::move(TM)),
227 : ExecutionEngine(TM->createDataLayout()),
228 TM(std::move(TM)),
228229 MemMgr(
229230 std::make_shared(*this, std::move(MemMgr))),
230231 Resolver(std::make_shared(*this)),
449450 using CompileLayerT = IRCompileLayer;
450451 using LazyEmitLayerT = LazyEmittingLayer;
451452
452 SymbolStringPool SSP;
453453 ExecutionSession ES;
454454
455455 std::unique_ptr TM;
5959 std::unique_ptr CCMgr,
6060 IndirectStubsManagerBuilder IndirectStubsMgrBuilder,
6161 bool InlineStubs)
62 : ES(SSP), TM(std::move(TM)), DL(this->TM->createDataLayout()),
62 : TM(std::move(TM)),
63 DL(this->TM->createDataLayout()),
6364 CCMgr(std::move(CCMgr)),
6465 ObjectLayer(ES,
6566 [this](orc::VModuleKey K) {
5858
5959 DummyCallbackManager CallbackMgr;
6060
61 SymbolStringPool SSP;
62 ExecutionSession ES(SSP);
61 ExecutionSession ES(std::make_shared());
6362
6463 auto GetResolver =
6564 [](orc::VModuleKey) -> std::shared_ptr {
334334 constexpr JITTargetAddress FakeFooAddr = 0xdeadbeef;
335335 JITEvaluatedSymbol FooSym(FakeFooAddr, JITSymbolFlags::Exported);
336336
337 SymbolStringPool SSP;
338 auto Foo = SSP.intern("foo");
337 ExecutionSession ES(std::make_shared());
338 auto Foo = ES.getSymbolStringPool().intern("foo");
339339
340340 auto MU = llvm::make_unique(
341341 [=]() {
354354
355355 cantFail(V.defineLazy(std::move(MU)));
356356
357 ExecutionSession ES(SSP);
358357 auto FooLookupResult =
359358 cantFail(lookup({&V}, Foo, MaterializeOnCurrentThread(ES)));
360359
369368 constexpr JITTargetAddress FakeFooAddr = 0xdeadbeef;
370369 JITEvaluatedSymbol FooSym(FakeFooAddr, JITSymbolFlags::Exported);
371370
372 SymbolStringPool SSP;
373 auto Foo = SSP.intern("foo");
371 ExecutionSession ES(std::make_shared());
372 auto Foo = ES.getSymbolStringPool().intern("foo");
374373
375374 auto MU = llvm::make_unique(
376375 [=]() {
388387 VSO V;
389388
390389 cantFail(V.defineLazy(std::move(MU)));
391
392 ExecutionSession ES(SSP);
393390
394391 std::thread MaterializationThread;
395392 auto MaterializeOnNewThread = [&](VSO &V,
1717
1818 TEST(LegacyAPIInteropTest, QueryAgainstVSO) {
1919
20 SymbolStringPool SP;
21 ExecutionSession ES(SP);
22 auto Foo = SP.intern("foo");
20 ExecutionSession ES(std::make_shared());
21 auto Foo = ES.getSymbolStringPool().intern("foo");
2322
2423 VSO V;
2524 SymbolMap Defs;
178178 TEST(ObjectTransformLayerTest, Main) {
179179 MockBaseLayer M;
180180
181 SymbolStringPool SSP;
182 ExecutionSession ES(SSP);
181 ExecutionSession ES(std::make_shared());
183182
184183 // Create one object transform layer using a transform (as a functor)
185184 // that allocates new objects, and deals in unique pointers.
6666 bool DebugSectionSeen = false;
6767 auto MM = std::make_shared(DebugSectionSeen);
6868
69 SymbolStringPool SSP;
70 ExecutionSession ES(SSP);
69 ExecutionSession ES(std::make_shared());
7170
7271 RTDyldObjectLinkingLayer ObjLayer(ES, [&MM](VModuleKey) {
7372 return RTDyldObjectLinkingLayer::Resources{
123122 if (!SupportsJIT)
124123 return;
125124
126 SymbolStringPool SSP;
127 ExecutionSession ES(SSP);
125 ExecutionSession ES(std::make_shared());
128126
129127 auto MM = std::make_shared();
130128
208206 if (!SupportsJIT)
209207 return;
210208
211 SymbolStringPool SSP;
212 ExecutionSession ES(SSP);
209 ExecutionSession ES(std::make_shared());
213210
214211 auto MM = std::make_shared();
215212
270267 }
271268
272269 TEST_F(RTDyldObjectLinkingLayerExecutionTest, TestNotifyLoadedSignature) {
273 SymbolStringPool SSP;
274 ExecutionSession ES(SSP);
270 ExecutionSession ES(std::make_shared());
275271 RTDyldObjectLinkingLayer ObjLayer(
276272 ES,
277273 [](VModuleKey) {