[PATCH] D28568: RuntimeDyld: allow using custom implementation
Eugene Leviant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 11 08:46:59 PST 2017
evgeny777 created this revision.
evgeny777 added reviewers: davide, lhames.
evgeny777 added subscribers: llvm-commits, grimar.
evgeny777 set the repository for this revision to rL LLVM.
This patch allows using custom binary format implementation or tweak behavior in existing ones by deriving a class from RuntimeDyldELF and friends. I personally need this to be able to move jitted code to a different memory location.
Repository:
rL LLVM
https://reviews.llvm.org/D28568
Files:
include/llvm/ExecutionEngine/RuntimeDyld.h
lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
===================================================================
--- lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -996,8 +996,9 @@
void JITSymbolResolver::anchor() {}
RuntimeDyld::RuntimeDyld(RuntimeDyld::MemoryManager &MemMgr,
- JITSymbolResolver &Resolver)
- : MemMgr(MemMgr), Resolver(Resolver) {
+ JITSymbolResolver &Resolver,
+ DyldImplCreateFtor DyldCreator)
+ : DyldCreator(DyldCreator), MemMgr(MemMgr), Resolver(Resolver) {
// FIXME: There's a potential issue lurking here if a single instance of
// RuntimeDyld is used to load multiple objects. The current implementation
// associates a single memory manager with a RuntimeDyld instance. Even
@@ -1048,7 +1049,9 @@
std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
RuntimeDyld::loadObject(const ObjectFile &Obj) {
if (!Dyld) {
- if (Obj.isELF())
+ if (DyldCreator)
+ Dyld = DyldCreator(Obj);
+ else if (Obj.isELF())
Dyld =
createRuntimeDyldELF(static_cast<Triple::ArchType>(Obj.getArch()),
MemMgr, Resolver, ProcessAllSections, Checker);
@@ -1110,6 +1113,8 @@
}
}
+RuntimeDyldImpl *RuntimeDyld::getImpl() { return Dyld.get(); }
+
void RuntimeDyld::registerEHFrames() {
if (Dyld)
Dyld->registerEHFrames();
Index: include/llvm/ExecutionEngine/RuntimeDyld.h
===================================================================
--- include/llvm/ExecutionEngine/RuntimeDyld.h
+++ include/llvm/ExecutionEngine/RuntimeDyld.h
@@ -184,8 +184,13 @@
bool FinalizationLocked = false;
};
+ typedef std::function<std::unique_ptr<RuntimeDyldImpl>(
+ const object::ObjectFile &O)>
+ DyldImplCreateFtor;
+
/// \brief Construct a RuntimeDyld instance.
- RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver);
+ RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver,
+ DyldImplCreateFtor = nullptr);
RuntimeDyld(const RuntimeDyld &) = delete;
void operator=(const RuntimeDyld &) = delete;
~RuntimeDyld();
@@ -256,10 +261,14 @@
///
void finalizeWithMemoryManagerLocking();
+ /// Gets pointer to implementation
+ RuntimeDyldImpl *getImpl();
+
private:
// RuntimeDyldImpl is the actual class. RuntimeDyld is just the public
// interface.
std::unique_ptr<RuntimeDyldImpl> Dyld;
+ DyldImplCreateFtor DyldCreator;
MemoryManager &MemMgr;
JITSymbolResolver &Resolver;
bool ProcessAllSections;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28568.83985.patch
Type: text/x-patch
Size: 2612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170111/2e746f7f/attachment.bin>
More information about the llvm-commits
mailing list