summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/Orc/Core.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-01-05 22:50:43 +0000
committerLang Hames <lhames@gmail.com>2018-01-05 22:50:43 +0000
commit1097dc47eb69b0e488767cb3f0362c10d5e642e2 (patch)
tree54acc218584cf871d06077e64bc6ee721979cc09 /llvm/lib/ExecutionEngine/Orc/Core.cpp
parentb96a3a4fe55d65bb9e595410ca682892e271624f (diff)
downloadbcm5719-llvm-1097dc47eb69b0e488767cb3f0362c10d5e642e2.tar.gz
bcm5719-llvm-1097dc47eb69b0e488767cb3f0362c10d5e642e2.zip
[ORC] Re-apply just the AsynchronousSymbolLookup class from r321838 while I
investigate builder / test failures. llvm-svn: 321910
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/Core.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/Orc/Core.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
new file mode 100644
index 00000000000..4c1ed18d4d1
--- /dev/null
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -0,0 +1,67 @@
+//===--------- Core.cpp - Core ORC APIs (SymbolSource, VSO, etc.) ---------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ExecutionEngine/Orc/Core.h"
+#include "llvm/ExecutionEngine/Orc/OrcError.h"
+
+namespace llvm {
+namespace orc {
+
+AsynchronousSymbolQuery::AsynchronousSymbolQuery(
+ const SymbolNameSet &Symbols,
+ SymbolsResolvedCallback NotifySymbolsResolved,
+ SymbolsReadyCallback NotifySymbolsReady)
+ : NotifySymbolsResolved(std::move(NotifySymbolsResolved)),
+ NotifySymbolsReady(std::move(NotifySymbolsReady)) {
+ assert(this->NotifySymbolsResolved &&
+ "Symbols resolved callback must be set");
+ assert(this->NotifySymbolsReady && "Symbols ready callback must be set");
+ OutstandingResolutions = OutstandingFinalizations = Symbols.size();
+}
+
+void AsynchronousSymbolQuery::setFailed(Error Err) {
+ OutstandingResolutions = OutstandingFinalizations = 0;
+ if (NotifySymbolsResolved)
+ NotifySymbolsResolved(std::move(Err));
+ else
+ NotifySymbolsReady(std::move(Err));
+}
+
+void AsynchronousSymbolQuery::setDefinition(SymbolStringPtr Name,
+ JITSymbol Sym) {
+ // If OutstandingResolutions is zero we must have errored out already. Just
+ // ignore this.
+ if (OutstandingResolutions == 0)
+ return;
+
+ assert(!Symbols.count(Name) &&
+ "Symbol has already been assigned an address");
+ Symbols.insert(std::make_pair(std::move(Name), std::move(Sym)));
+ --OutstandingResolutions;
+ if (OutstandingResolutions == 0) {
+ NotifySymbolsResolved(std::move(Symbols));
+ // Null out NotifySymbolsResolved to indicate that we've already called it.
+ NotifySymbolsResolved = {};
+ }
+}
+
+void AsynchronousSymbolQuery::notifySymbolFinalized() {
+ // If OutstandingFinalizations is zero we must have errored out already. Just
+ // ignore this.
+ if (OutstandingFinalizations == 0)
+ return;
+
+ assert(OutstandingFinalizations > 0 && "All symbols already finalized");
+ --OutstandingFinalizations;
+ if (OutstandingFinalizations == 0)
+ NotifySymbolsReady(Error::success());
+}
+
+} // End namespace orc.
+} // End namespace llvm.
OpenPOWER on IntegriCloud