Instantiate a JITMemoryManager for MCJIT Dyld

llvm-svn: 128485
This commit is contained in:
Jim Grosbach 2011-03-29 21:03:05 +00:00
parent 4fe82e640f
commit 30c2338560
5 changed files with 13 additions and 7 deletions

View File

@ -21,6 +21,7 @@ namespace llvm {
class RuntimeDyldImpl; class RuntimeDyldImpl;
class MemoryBuffer; class MemoryBuffer;
class JITMemoryManager;
class RuntimeDyld { class RuntimeDyld {
RuntimeDyld(const RuntimeDyld &); // DO NOT IMPLEMENT RuntimeDyld(const RuntimeDyld &); // DO NOT IMPLEMENT
@ -30,7 +31,7 @@ class RuntimeDyld {
// interface. // interface.
RuntimeDyldImpl *Dyld; RuntimeDyldImpl *Dyld;
public: public:
RuntimeDyld(); RuntimeDyld(JITMemoryManager*);
~RuntimeDyld(); ~RuntimeDyld();
bool loadObject(MemoryBuffer *InputBuffer); bool loadObject(MemoryBuffer *InputBuffer);

View File

@ -67,7 +67,7 @@ ExecutionEngine *MCJIT::createJIT(Module *M,
MCJIT::MCJIT(Module *m, TargetMachine *tm, TargetJITInfo &tji, MCJIT::MCJIT(Module *m, TargetMachine *tm, TargetJITInfo &tji,
JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, JITMemoryManager *JMM, CodeGenOpt::Level OptLevel,
bool AllocateGVsWithCode) 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())); PM.add(new TargetData(*TM->getTargetData()));

View File

@ -18,6 +18,7 @@
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/Object/MachOObject.h" #include "llvm/Object/MachOObject.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
@ -34,6 +35,9 @@ class RuntimeDyldImpl {
unsigned CPUType; unsigned CPUType;
unsigned CPUSubtype; unsigned CPUSubtype;
// The JITMemoryManager to load objects into.
JITMemoryManager *JMM;
// Master symbol table. As modules are loaded and external symbols are // Master symbol table. As modules are loaded and external symbols are
// resolved, their addresses are stored here. // resolved, their addresses are stored here.
StringMap<void*> SymbolTable; StringMap<void*> SymbolTable;
@ -68,7 +72,7 @@ class RuntimeDyldImpl {
const InMemoryStruct<macho::SymtabLoadCommand> &SymtabLC); const InMemoryStruct<macho::SymtabLoadCommand> &SymtabLC);
public: public:
RuntimeDyldImpl() : HasError(false) {} RuntimeDyldImpl(JITMemoryManager *jmm) : JMM(jmm), HasError(false) {}
bool loadObject(MemoryBuffer *InputBuffer); bool loadObject(MemoryBuffer *InputBuffer);
@ -526,8 +530,8 @@ bool RuntimeDyldImpl::loadObject(MemoryBuffer *InputBuffer) {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// RuntimeDyld class implementation // RuntimeDyld class implementation
RuntimeDyld::RuntimeDyld() { RuntimeDyld::RuntimeDyld(JITMemoryManager *JMM) {
Dyld = new RuntimeDyldImpl; Dyld = new RuntimeDyldImpl(JMM);
} }
RuntimeDyld::~RuntimeDyld() { RuntimeDyld::~RuntimeDyld() {

View File

@ -18,6 +18,6 @@ TOOL_NO_EXPORTS = 1
# early so we can set up LINK_COMPONENTS before including Makefile.rules # early so we can set up LINK_COMPONENTS before including Makefile.rules
include $(LEVEL)/Makefile.config 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 include $(LLVM_SRC_ROOT)/Makefile.rules

View File

@ -13,6 +13,7 @@
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/OwningPtr.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/Object/MachOObject.h" #include "llvm/Object/MachOObject.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
@ -60,7 +61,7 @@ static int executeInput() {
return Error("unable to read input: '" + ec.message() + "'"); return Error("unable to read input: '" + ec.message() + "'");
// Instantiate a dynamic linker. // Instantiate a dynamic linker.
RuntimeDyld Dyld; RuntimeDyld Dyld(JITMemoryManager::CreateDefaultMemManager());
// Load the object file into it. // Load the object file into it.
if (Dyld.loadObject(InputBuffer.take())) { if (Dyld.loadObject(InputBuffer.take())) {