[Orc] Add a new JITSymbol constructor to build a symbol from an existing address.

This constructor is more efficient for symbols that have already been emitted,
since it avoids the construction/execution of a std::function.

Update the ObjectLinkingLayer to use this new constructor where possible.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229973 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames
2015-02-20 06:48:29 +00:00
parent 587999319a
commit 4dedd90c76
2 changed files with 37 additions and 11 deletions

View File

@@ -213,16 +213,27 @@ public:
/// given object set.
JITSymbol findSymbolIn(ObjSetHandleT H, StringRef Name,
bool ExportedSymbolsOnly) {
if (auto Addr = H->getSymbolAddress(Name, ExportedSymbolsOnly))
return JITSymbol(
[this, Addr, H](){
if (H->NeedsFinalization()) {
H->Finalize();
if (NotifyFinalized)
NotifyFinalized(H);
}
return Addr;
});
if (auto Addr = H->getSymbolAddress(Name, ExportedSymbolsOnly)) {
if (!H->NeedsFinalization()) {
// If this instance has already been finalized then we can just return
// the address.
return JITSymbol(Addr);
} else {
// If this instance needs finalization return a functor that will do it.
// The functor still needs to double-check whether finalization is
// required, in case someone else finalizes this set before the functor
// is called.
return JITSymbol(
[this, Addr, H]() {
if (H->NeedsFinalization()) {
H->Finalize();
if (NotifyFinalized)
NotifyFinalized(H);
}
return Addr;
});
}
}
return nullptr;
}