llvm.org GIT mirror llvm / fed3099
[ORC] Rename MaterializationResponsibility resolve and emit methods to notifyResolved/notifyEmitted. The 'notify' prefix better describes what these methods do: they update the JIT symbol states and notify any pending queries that the 'resolved' and 'emitted' states have been reached (rather than actually performing the resolution or emission themselves). Since new states are going to be introduced in the near future (to track symbol registration/initialization) it's worth changing the convention pre-emptively to avoid further confusion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363322 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames a month ago
8 changed file(s) with 55 addition(s) and 54 deletion(s). Raw diff Collapse all Expand all
203203 /// symbols must be ones covered by this MaterializationResponsibility
204204 /// instance. Individual calls to this method may resolve a subset of the
205205 /// symbols, but all symbols must have been resolved prior to calling emit.
206 void resolve(const SymbolMap &Symbols);
206 void notifyResolved(const SymbolMap &Symbols);
207207
208208 /// Notifies the target JITDylib (and any pending queries on that JITDylib)
209209 /// that all symbols covered by this MaterializationResponsibility instance
210210 /// have been emitted.
211 void emit();
211 void notifyEmitted();
212212
213213 /// Adds new symbols to the JITDylib and this responsibility instance.
214214 /// JITDylib entries start out in the materializing state.
366366 return JD.getRequestedSymbols(SymbolFlags);
367367 }
368368
369 void MaterializationResponsibility::resolve(const SymbolMap &Symbols) {
370 LLVM_DEBUG(
371 { dbgs() << "In " << JD.getName() << " resolving " << Symbols << "\n"; });
369 void MaterializationResponsibility::notifyResolved(const SymbolMap &Symbols) {
370 LLVM_DEBUG({
371 dbgs() << "In " << JD.getName() << " resolving " << Symbols << "\n";
372 });
372373 #ifndef NDEBUG
373374 for (auto &KV : Symbols) {
374375 auto I = SymbolFlags.find(KV.first);
386387 JD.resolve(Symbols);
387388 }
388389
389 void MaterializationResponsibility::emit() {
390 void MaterializationResponsibility::notifyEmitted() {
390391
391392 LLVM_DEBUG({
392393 dbgs() << "In " << JD.getName() << " emitting " << SymbolFlags << "\n";
483484
484485 void AbsoluteSymbolsMaterializationUnit::materialize(
485486 MaterializationResponsibility R) {
486 R.resolve(Symbols);
487 R.emit();
487 R.notifyResolved(Symbols);
488 R.notifyEmitted();
488489 }
489490
490491 void AbsoluteSymbolsMaterializationUnit::discard(const JITDylib &JD,
631632 ResolutionMap[KV.first] = JITEvaluatedSymbol(
632633 (*Result)[KV.second.Aliasee].getAddress(), KV.second.AliasFlags);
633634 }
634 QueryInfo->R.resolve(ResolutionMap);
635 QueryInfo->R.emit();
635 QueryInfo->R.notifyResolved(ResolutionMap);
636 QueryInfo->R.notifyEmitted();
636637 } else {
637638 auto &ES = QueryInfo->R.getTargetJITDylib().getExecutionSession();
638639 ES.reportError(Result.takeError());
3636 void materialize(MaterializationResponsibility R) override {
3737 SymbolMap Result;
3838 Result[Name] = JITEvaluatedSymbol(Compile(), JITSymbolFlags::Exported);
39 R.resolve(Result);
40 R.emit();
39 R.notifyResolved(Result);
40 R.notifyEmitted();
4141 }
4242
4343 void discard(const JITDylib &JD, const SymbolStringPtr &Name) override {
177177 for (auto &Alias : RequestedAliases)
178178 Stubs[Alias.first] = ISManager.findStub(*Alias.first, false);
179179
180 R.resolve(Stubs);
181 R.emit();
180 R.notifyResolved(Stubs);
181 R.notifyEmitted();
182182 }
183183
184184 void LazyReexportsMaterializationUnit::discard(const JITDylib &JD,
126126 if (auto Err = MR.defineMaterializing(ExtraSymbolsToClaim))
127127 return notifyFailed(std::move(Err));
128128
129 MR.resolve(InternedResult);
129 MR.notifyResolved(InternedResult);
130130
131131 Layer.notifyLoaded(MR);
132132 }
140140
141141 return;
142142 }
143 MR.emit();
143 MR.notifyEmitted();
144144 }
145145
146146 AtomGraphPassFunction getMarkLivePass(const Triple &TT) const override {
183183 if (auto Err = R.defineMaterializing(ExtraSymbolsToClaim))
184184 return Err;
185185
186 R.resolve(Symbols);
186 R.notifyResolved(Symbols);
187187
188188 if (NotifyLoaded)
189189 NotifyLoaded(K, Obj, *LoadedObjInfo);
200200 return;
201201 }
202202
203 R.emit();
203 R.notifyEmitted();
204204
205205 if (NotifyEmitted)
206206 NotifyEmitted(K, std::move(ObjBuffer));
4747
4848 EXPECT_FALSE(OnCompletionRun) << "Should not have been resolved yet";
4949
50 FooMR->resolve({{Foo, FooSym}});
50 FooMR->notifyResolved({{Foo, FooSym}});
5151
5252 EXPECT_FALSE(OnCompletionRun) << "Should not be ready yet";
5353
54 FooMR->emit();
54 FooMR->notifyEmitted();
5555
5656 EXPECT_TRUE(OnCompletionRun) << "Should have been marked ready";
5757 }
108108 SymbolFlagsMap({{Bar, BarSym.getFlags()}}),
109109 [this](MaterializationResponsibility R) {
110110 ADD_FAILURE() << "Unexpected materialization of \"Bar\"";
111 R.resolve({{Bar, BarSym}});
112 R.emit();
111 R.notifyResolved({{Bar, BarSym}});
112 R.notifyEmitted();
113113 },
114114 [&](const JITDylib &JD, const SymbolStringPtr &Name) {
115115 EXPECT_EQ(Name, Bar) << "Expected \"Bar\" to be discarded";
155155 consumeError(std::move(Err));
156156 }
157157
158 BazR->resolve({{Baz, BazSym}});
159 BazR->emit();
158 BazR->notifyResolved({{Baz, BazSym}});
159 BazR->notifyEmitted();
160160 {
161161 // Attempt 3: Search now that all symbols are fully materialized
162162 // (Foo, Baz), or not yet materialized (Bar).
316316 SymbolFlagsMap({{Bar, BarSym.getFlags()}}),
317317 [&](MaterializationResponsibility R) {
318318 BarMaterialized = true;
319 R.resolve({{Bar, BarSym}});
320 R.emit();
319 R.notifyResolved({{Bar, BarSym}});
320 R.notifyEmitted();
321321 });
322322
323323 cantFail(JD.define(BarMU));
371371 ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo}, SymbolState::Ready,
372372 OnCompletion, NoDependenciesToRegister);
373373
374 FooR->resolve({{Foo, FooSym}});
375 FooR->emit();
374 FooR->notifyResolved({{Foo, FooSym}});
375 FooR->notifyEmitted();
376376
377377 EXPECT_TRUE(FooReady)
378378 << "Self-dependency prevented symbol from being marked ready";
485485 EXPECT_FALSE(BazResolved) << "\"Baz\" should not be resolved yet";
486486
487487 // Resolve the symbols (but do not emit them).
488 FooR->resolve({{Foo, FooSym}});
489 BarR->resolve({{Bar, BarSym}});
490 BazR->resolve({{Baz, BazSym}});
488 FooR->notifyResolved({{Foo, FooSym}});
489 BarR->notifyResolved({{Bar, BarSym}});
490 BazR->notifyResolved({{Baz, BazSym}});
491491
492492 // Verify that the symbols have been resolved, but are not ready yet.
493493 EXPECT_TRUE(FooResolved) << "\"Foo\" should be resolved now";
499499 EXPECT_FALSE(BazReady) << "\"Baz\" should not be ready yet";
500500
501501 // Emit two of the symbols.
502 FooR->emit();
503 BarR->emit();
502 FooR->notifyEmitted();
503 BarR->notifyEmitted();
504504
505505 // Verify that nothing is ready until the circular dependence is resolved.
506506 EXPECT_FALSE(FooReady) << "\"Foo\" still should not be ready";
508508 EXPECT_FALSE(BazReady) << "\"Baz\" still should not be ready";
509509
510510 // Emit the last symbol.
511 BazR->emit();
511 BazR->notifyEmitted();
512512
513513 // Verify that everything becomes ready once the circular dependence resolved.
514514 EXPECT_TRUE(FooReady) << "\"Foo\" should be ready now";
557557 SymbolFlagsMap({{Foo, JITSymbolFlags::Exported}, {Bar, WeakExported}}),
558558 [&](MaterializationResponsibility R) {
559559 assert(BarDiscarded && "Bar should have been discarded by this point");
560 R.resolve(SymbolMap({{Foo, FooSym}}));
561 R.emit();
560 R.notifyResolved(SymbolMap({{Foo, FooSym}}));
561 R.notifyEmitted();
562562 FooMaterialized = true;
563563 },
564564 [&](const JITDylib &JD, SymbolStringPtr Name) {
598598 auto MU1 = llvm::make_unique(
599599 SymbolFlagsMap({{Foo, FooSym.getFlags()}, {Bar, BarSym.getFlags()}}),
600600 [&](MaterializationResponsibility R) {
601 R.resolve(SymbolMap({{Foo, FooSym}, {Bar, BarSym}})), R.emit();
601 R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}})), R.notifyEmitted();
602602 BarMaterialized = true;
603603 });
604604
647647 [&](MaterializationResponsibility R) {
648648 cantFail(
649649 R.defineMaterializing(SymbolFlagsMap({{Bar, BarSym.getFlags()}})));
650 R.resolve(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}));
651 R.emit();
650 R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}));
651 R.notifyEmitted();
652652 });
653653
654654 cantFail(JD.define(MU));
721721 auto MU = llvm::make_unique(
722722 SymbolFlagsMap({{Foo, FooSym.getFlags()}, {Bar, BarSym.getFlags()}}),
723723 [&](MaterializationResponsibility R) {
724 R.resolve(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}));
724 R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}));
725725
726726 ES.lookup(
727727 JITDylibSearchList({{&JD, false}}), SymbolNameSet({Baz}),
753753 auto MU = llvm::make_unique(
754754 SymbolFlagsMap({{Foo, JITSymbolFlags::Exported}}),
755755 [&](MaterializationResponsibility R) {
756 R.resolve({{Foo, FooSym}});
757 R.emit();
756 R.notifyResolved({{Foo, FooSym}});
757 R.notifyEmitted();
758758 });
759759
760760 cantFail(JD.define(MU));
812812 auto NewMU = llvm::make_unique(
813813 SymbolFlagsMap({{Bar, BarSym.getFlags()}}),
814814 [&](MaterializationResponsibility R2) {
815 R2.resolve(SymbolMap({{Bar, BarSym}}));
816 R2.emit();
815 R2.notifyResolved(SymbolMap({{Bar, BarSym}}));
816 R2.notifyEmitted();
817817 BarMaterialized = true;
818818 });
819819
820820 R.replace(std::move(NewMU));
821821
822 R.resolve(SymbolMap({{Foo, FooSym}}));
823 R.emit();
822 R.notifyResolved(SymbolMap({{Foo, FooSym}}));
823 R.notifyEmitted();
824824
825825 FooMaterialized = true;
826826 });
851851 [&](MaterializationResponsibility R) {
852852 auto R2 = R.delegate({Bar});
853853
854 R.resolve({{Foo, FooSym}});
855 R.emit();
856 R2.resolve({{Bar, BarSym}});
857 R2.emit();
854 R.notifyResolved({{Foo, FooSym}});
855 R.notifyEmitted();
856 R2.notifyResolved({{Bar, BarSym}});
857 R2.notifyEmitted();
858858 });
859859
860860 cantFail(JD.define(MU));
904904 << "Expected a duplicate definition error";
905905 consumeError(std::move(Err));
906906
907 FooResponsibility->resolve(SymbolMap({{Foo, FooSym}}));
908 FooResponsibility->emit();
907 FooResponsibility->notifyResolved(SymbolMap({{Foo, FooSym}}));
908 FooResponsibility->notifyEmitted();
909909 }
910910
911911 } // namespace
4040 SymbolFlagsMap({{DummyTarget, JITSymbolFlags::Exported}}),
4141 [&](MaterializationResponsibility R) {
4242 DummyTargetMaterialized = true;
43 R.resolve(
43 R.notifyResolved(
4444 {{DummyTarget,
4545 JITEvaluatedSymbol(static_cast(
4646 reinterpret_cast(&dummyTarget)),
4747 JITSymbolFlags::Exported)}});
48 R.emit();
48 R.notifyEmitted();
4949 })));
5050
5151 unsigned NotifyResolvedCount = 0;