Instantiate a JITMemoryManager for MCJIT Dyld

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128485 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Grosbach 2011-03-29 21:03:05 +00:00
parent 23f0bfeda9
commit 5acfa9f0fd
5 changed files with 13 additions and 7 deletions

View 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);

View 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()));

View 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() {

View 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

View 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())) {