diff options
author | Lang Hames <lhames@gmail.com> | 2018-06-14 15:32:58 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-06-14 15:32:58 +0000 |
commit | 26907984ce2513f2cd0486a541ae2f42db8839a2 (patch) | |
tree | cfd7ef1bd397e1ff0ce696545ea196f9ffb5e458 /lib/ExecutionEngine/Orc | |
parent | 103c75a7dbaa75c1c2540b301cc5ba3df4bed865 (diff) |
[ORC] Add a WaitUntilReady argument to blockingLookup.
If WaitUntilReady is set to true then blockingLookup will return once all
requested symbols are ready. If WaitUntilReady is set to false then
blockingLookup will return as soon as all requested symbols have been
resolved. In the latter case, if any error occurs in finalizing the symbols it
will be reported to the ExecutionSession, rather than returned by
blockingLookup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Orc')
-rw-r--r-- | lib/ExecutionEngine/Orc/Core.cpp | 64 | ||||
-rw-r--r-- | lib/ExecutionEngine/Orc/Legacy.cpp | 4 |
2 files changed, 44 insertions, 24 deletions
diff --git a/lib/ExecutionEngine/Orc/Core.cpp b/lib/ExecutionEngine/Orc/Core.cpp index 5ae65ab2f66..74cb3834b79 100644 --- a/lib/ExecutionEngine/Orc/Core.cpp +++ b/lib/ExecutionEngine/Orc/Core.cpp @@ -937,7 +937,7 @@ VSO &ExecutionSession::createVSO(std::string Name) { Expected<SymbolMap> blockingLookup(ExecutionSessionBase &ES, AsynchronousLookupFunction AsyncLookup, - SymbolNameSet Names, + SymbolNameSet Names, bool WaitUntilReady, MaterializationResponsibility *MR) { #if LLVM_ENABLE_THREADS @@ -963,14 +963,23 @@ Expected<SymbolMap> blockingLookup(ExecutionSessionBase &ES, } }; - auto OnReady = [&](Error Err) { - if (Err) { - ErrorAsOutParameter _(&ReadyError); - std::lock_guard<std::mutex> Lock(ErrMutex); - ReadyError = std::move(Err); - } - PromisedReady.set_value(); - }; + std::function<void(Error)> OnReady; + if (WaitUntilReady) { + OnReady = [&](Error Err) { + if (Err) { + ErrorAsOutParameter _(&ReadyError); + std::lock_guard<std::mutex> Lock(ErrMutex); + ReadyError = std::move(Err); + } + PromisedReady.set_value(); + }; + } else { + OnReady = [&](Error Err) { + if (Err) + ES.reportError(std::move(Err)); + }; + } + #else SymbolMap Result; Error ResolutionError = Error::success(); @@ -986,11 +995,19 @@ Expected<SymbolMap> blockingLookup(ExecutionSessionBase &ES, ResolutionError = R.takeError(); }; - auto OnReady = [&](Error Err) { - ErrorAsOutParameter _(&ReadyError); - if (Err) - ReadyError = std::move(Err); - }; + std::function<void(Error)> OnReady; + if (WaitUntilReady) { + OnReady = [&](Error Err) { + ErrorAsOutParameter _(&ReadyError); + if (Err) + ReadyError = std::move(Err); + }; + } else { + OnReady = [&](Error Err) { + if (Err) + ES.reportError(std::move(Err)); + }; + } #endif auto Query = std::make_shared<AsynchronousSymbolQuery>( @@ -1017,14 +1034,17 @@ Expected<SymbolMap> blockingLookup(ExecutionSessionBase &ES, } } - auto ReadyFuture = PromisedReady.get_future(); - ReadyFuture.get(); + if (WaitUntilReady) { + auto ReadyFuture = PromisedReady.get_future(); + ReadyFuture.get(); - { - std::lock_guard<std::mutex> Lock(ErrMutex); - if (ReadyError) - return std::move(ReadyError); - } + { + std::lock_guard<std::mutex> Lock(ErrMutex); + if (ReadyError) + return std::move(ReadyError); + } + } else + cantFail(std::move(ReadyError)); return std::move(Result); @@ -1060,7 +1080,7 @@ Expected<SymbolMap> lookup(const VSO::VSOList &VSOs, SymbolNameSet Names) { return Unresolved; }; - return blockingLookup(ES, std::move(LookupFn), Names); + return blockingLookup(ES, std::move(LookupFn), Names, true); } /// Look up a symbol by searching a list of VSOs. diff --git a/lib/ExecutionEngine/Orc/Legacy.cpp b/lib/ExecutionEngine/Orc/Legacy.cpp index 3fd53a00a79..795ddd582d8 100644 --- a/lib/ExecutionEngine/Orc/Legacy.cpp +++ b/lib/ExecutionEngine/Orc/Legacy.cpp @@ -27,8 +27,8 @@ JITSymbolResolverAdapter::lookup(const LookupSet &Symbols) { return R.lookup(std::move(Q), std::move(Unresolved)); }; - auto InternedResult = - blockingLookup(ES, std::move(LookupFn), std::move(InternedSymbols), MR); + auto InternedResult = blockingLookup(ES, std::move(LookupFn), + std::move(InternedSymbols), false, MR); if (!InternedResult) return InternedResult.takeError(); |