Instantiate a JITMemoryManager for MCJIT Dyld
authorJim Grosbach <grosbach@apple.com>
Tue, 29 Mar 2011 21:03:05 +0000 (21:03 +0000)
committerJim Grosbach <grosbach@apple.com>
Tue, 29 Mar 2011 21:03:05 +0000 (21:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128485 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ExecutionEngine/RuntimeDyld.h
lib/ExecutionEngine/MCJIT/MCJIT.cpp
lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
tools/llvm-rtdyld/Makefile
tools/llvm-rtdyld/llvm-rtdyld.cpp

index 2b5a69181727c08e8e31b28135696cedb8186410..ade0047a59155bb3b3701ebf83d9d4142c10ed6b 100644 (file)
@@ -21,6 +21,7 @@ namespace llvm {
 
 class RuntimeDyldImpl;
 class MemoryBuffer;
+class JITMemoryManager;
 
 class RuntimeDyld {
   RuntimeDyld(const RuntimeDyld &);     // DO NOT IMPLEMENT
@@ -30,7 +31,7 @@ class RuntimeDyld {
   // interface.
   RuntimeDyldImpl *Dyld;
 public:
-  RuntimeDyld();
+  RuntimeDyld(JITMemoryManager*);
   ~RuntimeDyld();
 
   bool loadObject(MemoryBuffer *InputBuffer);
index f3e6087668465074aad5ba6e5a9a2cacc0c8d823..2e3c9310fb2ce6e63d953438fb0dd57578ce99c8 100644 (file)
@@ -67,7 +67,7 @@ ExecutionEngine *MCJIT::createJIT(Module *M,
 MCJIT::MCJIT(Module *m, TargetMachine *tm, TargetJITInfo &tji,
              JITMemoryManager *JMM, CodeGenOpt::Level OptLevel,
              bool AllocateGVsWithCode)
-  : ExecutionEngine(m), TM(tm), M(m), OS(Buffer) {
+  : ExecutionEngine(m), TM(tm), M(m), OS(Buffer), Dyld(JMM) {
 
   PM.add(new TargetData(*TM->getTargetData()));
 
index c6b6a9ee884c88b97b78fab9406fea3c47af2740..c041c940de9d65d17790e8db532763a0d81c121c 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/ExecutionEngine/RuntimeDyld.h"
+#include "llvm/ExecutionEngine/JITMemoryManager.h"
 #include "llvm/Object/MachOObject.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -34,6 +35,9 @@ class RuntimeDyldImpl {
   unsigned CPUType;
   unsigned CPUSubtype;
 
+  // The JITMemoryManager to load objects into.
+  JITMemoryManager *JMM;
+
   // Master symbol table. As modules are loaded and external symbols are
   // resolved, their addresses are stored here.
   StringMap<void*> SymbolTable;
@@ -68,7 +72,7 @@ class RuntimeDyldImpl {
                      const InMemoryStruct<macho::SymtabLoadCommand> &SymtabLC);
 
 public:
-  RuntimeDyldImpl() : HasError(false) {}
+  RuntimeDyldImpl(JITMemoryManager *jmm) : JMM(jmm), HasError(false) {}
 
   bool loadObject(MemoryBuffer *InputBuffer);
 
@@ -526,8 +530,8 @@ bool RuntimeDyldImpl::loadObject(MemoryBuffer *InputBuffer) {
 
 //===----------------------------------------------------------------------===//
 // RuntimeDyld class implementation
-RuntimeDyld::RuntimeDyld() {
-  Dyld = new RuntimeDyldImpl;
+RuntimeDyld::RuntimeDyld(JITMemoryManager *JMM) {
+  Dyld = new RuntimeDyldImpl(JMM);
 }
 
 RuntimeDyld::~RuntimeDyld() {
index 6a879b3e8c7dd243a6df33c27feb8c92071eafd6..0d57277f08d81ce8b946ea81c96263b71ff3ae16 100644 (file)
@@ -18,6 +18,6 @@ TOOL_NO_EXPORTS = 1
 # early so we can set up LINK_COMPONENTS before including Makefile.rules
 include $(LEVEL)/Makefile.config
 
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) support MC object RuntimeDyld
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) support MC object RuntimeDyld JIT
 
 include $(LLVM_SRC_ROOT)/Makefile.rules
index 286a3f251d8deba1fefaf96144f2c5eeabab0665..a670944235626735c47524498136cf6afa57af81 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/OwningPtr.h"
+#include "llvm/ExecutionEngine/JITMemoryManager.h"
 #include "llvm/ExecutionEngine/RuntimeDyld.h"
 #include "llvm/Object/MachOObject.h"
 #include "llvm/Support/CommandLine.h"
@@ -60,7 +61,7 @@ static int executeInput() {
     return Error("unable to read input: '" + ec.message() + "'");
 
   // Instantiate a dynamic linker.
-  RuntimeDyld Dyld;
+  RuntimeDyld Dyld(JITMemoryManager::CreateDefaultMemManager());
 
   // Load the object file into it.
   if (Dyld.loadObject(InputBuffer.take())) {