diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-06 01:08:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-06 01:08:09 +0000 |
commit | 9f2f142d255bc96f109dd5c6524a485937b1f3a1 (patch) | |
tree | 60de6e06844b32d1ffd76090df4610c4920bb3cc /lib | |
parent | 7f3a75a5290ba4167403626849d666138383fd74 (diff) |
simplify creation of the interpreter, make ExecutionEngine ctor protected,
delete one ExecutionEngine ctor, minor cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44646 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ExecutionEngine/ExecutionEngine.cpp | 6 | ||||
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Interpreter.cpp | 16 | ||||
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Interpreter.h | 2 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JIT.cpp | 2 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JIT.h | 2 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JITEmitter.cpp | 8 |
6 files changed, 11 insertions, 25 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index cc3cc38305..02b94cc1fd 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -39,12 +39,6 @@ ExecutionEngine::ExecutionEngine(ModuleProvider *P) : LazyFunctionCreator(0) { assert(P && "ModuleProvider is null?"); } -ExecutionEngine::ExecutionEngine(Module *M) : LazyFunctionCreator(0) { - LazyCompilationDisabled = false; - assert(M && "Module is null?"); - Modules.push_back(new ExistingModuleProvider(M)); -} - ExecutionEngine::~ExecutionEngine() { clearAllGlobalMappings(); for (unsigned i = 0, e = Modules.size(); i != e; ++i) diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/lib/ExecutionEngine/Interpreter/Interpreter.cpp index 3a156bf51c..65ca01210a 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.cpp +++ b/lib/ExecutionEngine/Interpreter/Interpreter.cpp @@ -33,26 +33,18 @@ namespace llvm { /// ExecutionEngine *Interpreter::create(ModuleProvider *MP, std::string* ErrStr) { // Tell this ModuleProvide to materialize and release the module - Module *M = MP->releaseModule(ErrStr); - if (!M) + if (!MP->materializeModule(ErrStr)) // We got an error, just return 0 return 0; - // This is a bit nasty, but the ExecutionEngine won't be able to delete the - // module due to use/def issues if we don't delete this MP here. Below we - // construct a new Interpreter with the Module we just got. This creates a - // new ExistingModuleProvider in the EE instance. Consequently, MP is left - // dangling and it contains references into the module which cause problems - // when the module is deleted via the ExistingModuleProvide via EE. - delete MP; - - return new Interpreter(M); + return new Interpreter(MP); } //===----------------------------------------------------------------------===// // Interpreter ctor - Initialize stuff // -Interpreter::Interpreter(Module *M) : ExecutionEngine(M), TD(M) { +Interpreter::Interpreter(ModuleProvider *M) + : ExecutionEngine(M), TD(M->getModule()) { memset(&ExitValue.Untyped, 0, sizeof(ExitValue.Untyped)); setTargetData(&TD); diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h index 9ad837c31b..3c5d4b1256 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.h +++ b/lib/ExecutionEngine/Interpreter/Interpreter.h @@ -94,7 +94,7 @@ class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> { std::vector<Function*> AtExitHandlers; public: - explicit Interpreter(Module *M); + explicit Interpreter(ModuleProvider *M); ~Interpreter(); /// runAtExitHandlers - Run any functions registered by the program's calls to diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 5b04124cd0..b599497502 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -66,7 +66,7 @@ JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji) setTargetData(TM.getTargetData()); // Initialize MCE - MCE = createEmitter(*this); + MCE = createEmitter(*this, 0); // Add target data MutexGuard locked(lock); diff --git a/lib/ExecutionEngine/JIT/JIT.h b/lib/ExecutionEngine/JIT/JIT.h index 5a3d6614db..6453740917 100644 --- a/lib/ExecutionEngine/JIT/JIT.h +++ b/lib/ExecutionEngine/JIT/JIT.h @@ -121,7 +121,7 @@ public: /// getCodeEmitter - Return the code emitter this JIT is emitting into. MachineCodeEmitter *getCodeEmitter() const { return MCE; } private: - static MachineCodeEmitter *createEmitter(JIT &J); + static MachineCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM); void runJITOnFunction (Function *F); }; diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index d08bf0b3cb..a1b4b005c2 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -312,8 +312,8 @@ namespace { /// Resolver - This contains info about the currently resolved functions. JITResolver Resolver; public: - JITEmitter(JIT &jit) : Resolver(jit) { - MemMgr = JITMemoryManager::CreateDefaultMemManager(); + JITEmitter(JIT &jit, JITMemoryManager *JMM) : Resolver(jit) { + MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager(); if (jit.getJITInfo().needsGOT()) { MemMgr->AllocateGOT(); DOUT << "JIT is managing a GOT\n"; @@ -637,8 +637,8 @@ intptr_t JITEmitter::getJumpTableEntryAddress(unsigned Index) const { // Public interface to this file //===----------------------------------------------------------------------===// -MachineCodeEmitter *JIT::createEmitter(JIT &jit) { - return new JITEmitter(jit); +MachineCodeEmitter *JIT::createEmitter(JIT &jit, JITMemoryManager *JMM) { + return new JITEmitter(jit, JMM); } // getPointerToNamedFunction - This function is used as a global wrapper to |