]> granicus.if.org Git - llvm/commitdiff
[ORC] Rename MaterializationResponsibility resolve and emit methods to
authorLang Hames <lhames@gmail.com>
Thu, 13 Jun 2019 20:11:23 +0000 (20:11 +0000)
committerLang Hames <lhames@gmail.com>
Thu, 13 Jun 2019 20:11:23 +0000 (20:11 +0000)
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

include/llvm/ExecutionEngine/Orc/Core.h
lib/ExecutionEngine/Orc/Core.cpp
lib/ExecutionEngine/Orc/IndirectionUtils.cpp
lib/ExecutionEngine/Orc/LazyReexports.cpp
lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
unittests/ExecutionEngine/Orc/LazyCallThroughAndReexportsTest.cpp

index c0c54ef55662d0434cdcf18134126dfbb85a746d..016fd829bf98391769b4a1d97a4b228c2d8f67a3 100644 (file)
@@ -204,12 +204,12 @@ public:
   /// symbols must be ones covered by this MaterializationResponsibility
   /// instance. Individual calls to this method may resolve a subset of the
   /// symbols, but all symbols must have been resolved prior to calling emit.
-  void resolve(const SymbolMap &Symbols);
+  void notifyResolved(const SymbolMap &Symbols);
 
   /// Notifies the target JITDylib (and any pending queries on that JITDylib)
   /// that all symbols covered by this MaterializationResponsibility instance
   /// have been emitted.
-  void emit();
+  void notifyEmitted();
 
   /// Adds new symbols to the JITDylib and this responsibility instance.
   ///        JITDylib entries start out in the materializing state.
index e7e8f5caa399ba24463db542a5110d41b365d09d..dac37e030e0cfb84db3fc6e65ec94d8585876e70 100644 (file)
@@ -367,9 +367,10 @@ SymbolNameSet MaterializationResponsibility::getRequestedSymbols() const {
   return JD.getRequestedSymbols(SymbolFlags);
 }
 
-void MaterializationResponsibility::resolve(const SymbolMap &Symbols) {
-  LLVM_DEBUG(
-      { dbgs() << "In " << JD.getName() << " resolving " << Symbols << "\n"; });
+void MaterializationResponsibility::notifyResolved(const SymbolMap &Symbols) {
+  LLVM_DEBUG({
+    dbgs() << "In " << JD.getName() << " resolving " << Symbols << "\n";
+  });
 #ifndef NDEBUG
   for (auto &KV : Symbols) {
     auto I = SymbolFlags.find(KV.first);
@@ -387,7 +388,7 @@ void MaterializationResponsibility::resolve(const SymbolMap &Symbols) {
   JD.resolve(Symbols);
 }
 
-void MaterializationResponsibility::emit() {
+void MaterializationResponsibility::notifyEmitted() {
 
   LLVM_DEBUG({
     dbgs() << "In " << JD.getName() << " emitting " << SymbolFlags << "\n";
@@ -484,8 +485,8 @@ StringRef AbsoluteSymbolsMaterializationUnit::getName() const {
 
 void AbsoluteSymbolsMaterializationUnit::materialize(
     MaterializationResponsibility R) {
-  R.resolve(Symbols);
-  R.emit();
+  R.notifyResolved(Symbols);
+  R.notifyEmitted();
 }
 
 void AbsoluteSymbolsMaterializationUnit::discard(const JITDylib &JD,
@@ -632,8 +633,8 @@ void ReExportsMaterializationUnit::materialize(
           ResolutionMap[KV.first] = JITEvaluatedSymbol(
               (*Result)[KV.second.Aliasee].getAddress(), KV.second.AliasFlags);
         }
-        QueryInfo->R.resolve(ResolutionMap);
-        QueryInfo->R.emit();
+        QueryInfo->R.notifyResolved(ResolutionMap);
+        QueryInfo->R.notifyEmitted();
       } else {
         auto &ES = QueryInfo->R.getTargetJITDylib().getExecutionSession();
         ES.reportError(Result.takeError());
index 0b52ba813abecb02b604fd31561fb0628fda1143..cc3656fe5dc51a1693b467c7049a4a10f55004ac 100644 (file)
@@ -37,8 +37,8 @@ private:
   void materialize(MaterializationResponsibility R) override {
     SymbolMap Result;
     Result[Name] = JITEvaluatedSymbol(Compile(), JITSymbolFlags::Exported);
-    R.resolve(Result);
-    R.emit();
+    R.notifyResolved(Result);
+    R.notifyEmitted();
   }
 
   void discard(const JITDylib &JD, const SymbolStringPtr &Name) override {
index b12ef4044fe5b4e8e853ec4e3fb26b3ccd12f01c..fc8205845654aff22f8337f54aaa0b25f5a04cb0 100644 (file)
@@ -178,8 +178,8 @@ void LazyReexportsMaterializationUnit::materialize(
   for (auto &Alias : RequestedAliases)
     Stubs[Alias.first] = ISManager.findStub(*Alias.first, false);
 
-  R.resolve(Stubs);
-  R.emit();
+  R.notifyResolved(Stubs);
+  R.notifyEmitted();
 }
 
 void LazyReexportsMaterializationUnit::discard(const JITDylib &JD,
index c7abce9900217630db4939f71c14134aa1fbfa0e..640d1d922c7b10df34e94a65ba2560f59fddc1d5 100644 (file)
@@ -127,7 +127,7 @@ public:
       if (auto Err = MR.defineMaterializing(ExtraSymbolsToClaim))
         return notifyFailed(std::move(Err));
 
-    MR.resolve(InternedResult);
+    MR.notifyResolved(InternedResult);
 
     Layer.notifyLoaded(MR);
   }
@@ -141,7 +141,7 @@ public:
 
       return;
     }
-    MR.emit();
+    MR.notifyEmitted();
   }
 
   AtomGraphPassFunction getMarkLivePass(const Triple &TT) const override {
index 1a5917ea5abef9316ceac5cbf5e575e398eca8dd..054a2a742904e7d9678762de19a7df9f884c5b5d 100644 (file)
@@ -184,7 +184,7 @@ Error RTDyldObjectLinkingLayer::onObjLoad(
     if (auto Err = R.defineMaterializing(ExtraSymbolsToClaim))
       return Err;
 
-  R.resolve(Symbols);
+  R.notifyResolved(Symbols);
 
   if (NotifyLoaded)
     NotifyLoaded(K, Obj, *LoadedObjInfo);
@@ -201,7 +201,7 @@ void RTDyldObjectLinkingLayer::onObjEmit(
     return;
   }
 
-  R.emit();
+  R.notifyEmitted();
 
   if (NotifyEmitted)
     NotifyEmitted(K, std::move(ObjBuffer));
index 6f9dd1fb4811447b1f7761638cd3ffa8041de422..fb55c4b98efae576621f12eee71ede43f9e9d803 100644 (file)
@@ -48,11 +48,11 @@ TEST_F(CoreAPIsStandardTest, BasicSuccessfulLookup) {
 
   EXPECT_FALSE(OnCompletionRun) << "Should not have been resolved yet";
 
-  FooMR->resolve({{Foo, FooSym}});
+  FooMR->notifyResolved({{Foo, FooSym}});
 
   EXPECT_FALSE(OnCompletionRun) << "Should not be ready yet";
 
-  FooMR->emit();
+  FooMR->notifyEmitted();
 
   EXPECT_TRUE(OnCompletionRun) << "Should have been marked ready";
 }
@@ -109,8 +109,8 @@ TEST_F(CoreAPIsStandardTest, RemoveSymbolsTest) {
       SymbolFlagsMap({{Bar, BarSym.getFlags()}}),
       [this](MaterializationResponsibility R) {
         ADD_FAILURE() << "Unexpected materialization of \"Bar\"";
-        R.resolve({{Bar, BarSym}});
-        R.emit();
+        R.notifyResolved({{Bar, BarSym}});
+        R.notifyEmitted();
       },
       [&](const JITDylib &JD, const SymbolStringPtr &Name) {
         EXPECT_EQ(Name, Bar) << "Expected \"Bar\" to be discarded";
@@ -156,8 +156,8 @@ TEST_F(CoreAPIsStandardTest, RemoveSymbolsTest) {
     consumeError(std::move(Err));
   }
 
-  BazR->resolve({{Baz, BazSym}});
-  BazR->emit();
+  BazR->notifyResolved({{Baz, BazSym}});
+  BazR->notifyEmitted();
   {
     // Attempt 3: Search now that all symbols are fully materialized
     // (Foo, Baz), or not yet materialized (Bar).
@@ -317,8 +317,8 @@ TEST_F(CoreAPIsStandardTest, TestThatReExportsDontUnnecessarilyMaterialize) {
       SymbolFlagsMap({{Bar, BarSym.getFlags()}}),
       [&](MaterializationResponsibility R) {
         BarMaterialized = true;
-        R.resolve({{Bar, BarSym}});
-        R.emit();
+        R.notifyResolved({{Bar, BarSym}});
+        R.notifyEmitted();
       });
 
   cantFail(JD.define(BarMU));
@@ -372,8 +372,8 @@ TEST_F(CoreAPIsStandardTest, TestTrivialCircularDependency) {
   ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo}, SymbolState::Ready,
             OnCompletion, NoDependenciesToRegister);
 
-  FooR->resolve({{Foo, FooSym}});
-  FooR->emit();
+  FooR->notifyResolved({{Foo, FooSym}});
+  FooR->notifyEmitted();
 
   EXPECT_TRUE(FooReady)
     << "Self-dependency prevented symbol from being marked ready";
@@ -486,9 +486,9 @@ TEST_F(CoreAPIsStandardTest, TestCircularDependenceInOneJITDylib) {
   EXPECT_FALSE(BazResolved) << "\"Baz\" should not be resolved yet";
 
   // Resolve the symbols (but do not emit them).
-  FooR->resolve({{Foo, FooSym}});
-  BarR->resolve({{Bar, BarSym}});
-  BazR->resolve({{Baz, BazSym}});
+  FooR->notifyResolved({{Foo, FooSym}});
+  BarR->notifyResolved({{Bar, BarSym}});
+  BazR->notifyResolved({{Baz, BazSym}});
 
   // Verify that the symbols have been resolved, but are not ready yet.
   EXPECT_TRUE(FooResolved) << "\"Foo\" should be resolved now";
@@ -500,8 +500,8 @@ TEST_F(CoreAPIsStandardTest, TestCircularDependenceInOneJITDylib) {
   EXPECT_FALSE(BazReady) << "\"Baz\" should not be ready yet";
 
   // Emit two of the symbols.
-  FooR->emit();
-  BarR->emit();
+  FooR->notifyEmitted();
+  BarR->notifyEmitted();
 
   // Verify that nothing is ready until the circular dependence is resolved.
   EXPECT_FALSE(FooReady) << "\"Foo\" still should not be ready";
@@ -509,7 +509,7 @@ TEST_F(CoreAPIsStandardTest, TestCircularDependenceInOneJITDylib) {
   EXPECT_FALSE(BazReady) << "\"Baz\" still should not be ready";
 
   // Emit the last symbol.
-  BazR->emit();
+  BazR->notifyEmitted();
 
   // Verify that everything becomes ready once the circular dependence resolved.
   EXPECT_TRUE(FooReady) << "\"Foo\" should be ready now";
@@ -558,8 +558,8 @@ TEST_F(CoreAPIsStandardTest, AddAndMaterializeLazySymbol) {
       SymbolFlagsMap({{Foo, JITSymbolFlags::Exported}, {Bar, WeakExported}}),
       [&](MaterializationResponsibility R) {
         assert(BarDiscarded && "Bar should have been discarded by this point");
-        R.resolve(SymbolMap({{Foo, FooSym}}));
-        R.emit();
+        R.notifyResolved(SymbolMap({{Foo, FooSym}}));
+        R.notifyEmitted();
         FooMaterialized = true;
       },
       [&](const JITDylib &JD, SymbolStringPtr Name) {
@@ -599,7 +599,7 @@ TEST_F(CoreAPIsStandardTest, TestBasicWeakSymbolMaterialization) {
   auto MU1 = llvm::make_unique<SimpleMaterializationUnit>(
       SymbolFlagsMap({{Foo, FooSym.getFlags()}, {Bar, BarSym.getFlags()}}),
       [&](MaterializationResponsibility R) {
-        R.resolve(SymbolMap({{Foo, FooSym}, {Bar, BarSym}})), R.emit();
+        R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}})), R.notifyEmitted();
         BarMaterialized = true;
       });
 
@@ -648,8 +648,8 @@ TEST_F(CoreAPIsStandardTest, DefineMaterializingSymbol) {
       [&](MaterializationResponsibility R) {
         cantFail(
             R.defineMaterializing(SymbolFlagsMap({{Bar, BarSym.getFlags()}})));
-        R.resolve(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}));
-        R.emit();
+        R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}));
+        R.notifyEmitted();
       });
 
   cantFail(JD.define(MU));
@@ -722,7 +722,7 @@ TEST_F(CoreAPIsStandardTest, FailEmissionEarly) {
   auto MU = llvm::make_unique<SimpleMaterializationUnit>(
       SymbolFlagsMap({{Foo, FooSym.getFlags()}, {Bar, BarSym.getFlags()}}),
       [&](MaterializationResponsibility R) {
-        R.resolve(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}));
+        R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}));
 
         ES.lookup(
             JITDylibSearchList({{&JD, false}}), SymbolNameSet({Baz}),
@@ -754,8 +754,8 @@ TEST_F(CoreAPIsStandardTest, TestLookupWithUnthreadedMaterialization) {
   auto MU = llvm::make_unique<SimpleMaterializationUnit>(
       SymbolFlagsMap({{Foo, JITSymbolFlags::Exported}}),
       [&](MaterializationResponsibility R) {
-        R.resolve({{Foo, FooSym}});
-        R.emit();
+        R.notifyResolved({{Foo, FooSym}});
+        R.notifyEmitted();
       });
 
   cantFail(JD.define(MU));
@@ -813,15 +813,15 @@ TEST_F(CoreAPIsStandardTest, TestGetRequestedSymbolsAndReplace) {
         auto NewMU = llvm::make_unique<SimpleMaterializationUnit>(
             SymbolFlagsMap({{Bar, BarSym.getFlags()}}),
             [&](MaterializationResponsibility R2) {
-              R2.resolve(SymbolMap({{Bar, BarSym}}));
-              R2.emit();
+              R2.notifyResolved(SymbolMap({{Bar, BarSym}}));
+              R2.notifyEmitted();
               BarMaterialized = true;
             });
 
         R.replace(std::move(NewMU));
 
-        R.resolve(SymbolMap({{Foo, FooSym}}));
-        R.emit();
+        R.notifyResolved(SymbolMap({{Foo, FooSym}}));
+        R.notifyEmitted();
 
         FooMaterialized = true;
       });
@@ -852,10 +852,10 @@ TEST_F(CoreAPIsStandardTest, TestMaterializationResponsibilityDelegation) {
       [&](MaterializationResponsibility R) {
         auto R2 = R.delegate({Bar});
 
-        R.resolve({{Foo, FooSym}});
-        R.emit();
-        R2.resolve({{Bar, BarSym}});
-        R2.emit();
+        R.notifyResolved({{Foo, FooSym}});
+        R.notifyEmitted();
+        R2.notifyResolved({{Bar, BarSym}});
+        R2.notifyEmitted();
       });
 
   cantFail(JD.define(MU));
@@ -905,8 +905,8 @@ TEST_F(CoreAPIsStandardTest, TestMaterializeWeakSymbol) {
       << "Expected a duplicate definition error";
   consumeError(std::move(Err));
 
-  FooResponsibility->resolve(SymbolMap({{Foo, FooSym}}));
-  FooResponsibility->emit();
+  FooResponsibility->notifyResolved(SymbolMap({{Foo, FooSym}}));
+  FooResponsibility->notifyEmitted();
 }
 
 } // namespace
index ebe99d483527cb5f846bb8a4a187e0906ccf3b4f..87d582b3c2726416b397f767ed04ce3a5d38652e 100644 (file)
@@ -41,12 +41,12 @@ TEST_F(LazyReexportsTest, BasicLocalCallThroughManagerOperation) {
       SymbolFlagsMap({{DummyTarget, JITSymbolFlags::Exported}}),
       [&](MaterializationResponsibility R) {
         DummyTargetMaterialized = true;
-        R.resolve(
+        R.notifyResolved(
             {{DummyTarget,
               JITEvaluatedSymbol(static_cast<JITTargetAddress>(
                                      reinterpret_cast<uintptr_t>(&dummyTarget)),
                                  JITSymbolFlags::Exported)}});
-        R.emit();
+        R.notifyEmitted();
       })));
 
   unsigned NotifyResolvedCount = 0;