Enabling incremental bytecode loading in the JIT:
authorMisha Brukman <brukman+llvm@gmail.com>
Tue, 14 Oct 2003 21:37:41 +0000 (21:37 +0000)
committerMisha Brukman <brukman+llvm@gmail.com>
Tue, 14 Oct 2003 21:37:41 +0000 (21:37 +0000)
* The VM is now constructed with a ModuleProvider

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9125 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JIT/JIT.cpp
lib/ExecutionEngine/JIT/JIT.h
lib/ExecutionEngine/JIT/VM.cpp
lib/ExecutionEngine/JIT/VM.h

index d2de0a8b50c1bc832fd4519b7e3165558010cf45..9bdaa57017914a722336123c2e81d8f02f815110 100644 (file)
@@ -45,7 +45,7 @@ namespace {
 /// create - Create an return a new JIT compiler if there is one available
 /// for the current target.  Otherwise, return null.
 ///
-ExecutionEngine *VM::create(Module *M) {
+ExecutionEngine *VM::create(ModuleProvider *MP) {
   TargetMachine* (*TargetMachineAllocator)(const Module &) = 0;
 
   // Allow a command-line switch to override what *should* be the default target
@@ -71,14 +71,16 @@ ExecutionEngine *VM::create(Module *M) {
   }
 
   // Allocate a target...
-  TargetMachine *Target = TargetMachineAllocator(*M);
+  TargetMachine *Target = TargetMachineAllocator(*(MP->getModule()));
   assert(Target && "Could not allocate target machine!");
   
   // Create the virtual machine object...
-  return new VM(M, Target);
+  return new VM(MP, Target);
 }
 
-VM::VM(Module *M, TargetMachine *tm) : ExecutionEngine(M), TM(*tm) {
+VM::VM(ModuleProvider *MP, TargetMachine *tm) : ExecutionEngine(MP), TM(*tm),
+  PM(MP)
+{
   setTargetData(TM.getTargetData());
 
   // Initialize MCE
@@ -94,7 +96,10 @@ VM::VM(Module *M, TargetMachine *tm) : ExecutionEngine(M), TM(*tm) {
     // Specialize LLVM code for this target machine and then
     // run basic dataflow optimizations on LLVM code.
     PM.add(createPreSelectionPass(TM));
-    PM.run(*M);
+    // We cannot utilize function-at-a-time loading here because PreSelection
+    // is a ModulePass.
+    MP->materializeModule();
+    PM.run(*(MP->getModule()));
   }
 #endif
 
index f79be1f34958dd3969c049ac4fdb4a8a0d590599..ddfd8964f8b3aaa64d1a884842bd6a932001c604 100644 (file)
@@ -23,13 +23,13 @@ class VM : public ExecutionEngine {
   MachineCodeEmitter *MCE; // MCE object
 
 public:
-  VM(Module *M, TargetMachine *tm);
+  VM(ModuleProvider *MP, TargetMachine *tm);
   ~VM();
 
   /// create - Create an return a new JIT compiler if there is one available
   /// for the current target.  Otherwise, return null.
   ///
-  static ExecutionEngine *create(Module *M);
+  static ExecutionEngine *create(ModuleProvider *MP);
 
   /// run - Start execution with the specified function and arguments.
   ///
index ee7e311ebbdb4e982720583dc655d7a3ea4fdd5a..622215b7a7b8119b266a64297ea30a38a77e6e14 100644 (file)
@@ -43,6 +43,9 @@ void *VM::getPointerToFunction(Function *F) {
   void *&Addr = GlobalAddress[F];   // Function already code gen'd
   if (Addr) return Addr;
 
+  // Make sure we read in the function if it exists in this Module
+  MP->materializeFunction(F);
+
   if (F->isExternal())
     return Addr = getPointerToNamedFunction(F->getName());
 
index f79be1f34958dd3969c049ac4fdb4a8a0d590599..ddfd8964f8b3aaa64d1a884842bd6a932001c604 100644 (file)
@@ -23,13 +23,13 @@ class VM : public ExecutionEngine {
   MachineCodeEmitter *MCE; // MCE object
 
 public:
-  VM(Module *M, TargetMachine *tm);
+  VM(ModuleProvider *MP, TargetMachine *tm);
   ~VM();
 
   /// create - Create an return a new JIT compiler if there is one available
   /// for the current target.  Otherwise, return null.
   ///
-  static ExecutionEngine *create(Module *M);
+  static ExecutionEngine *create(ModuleProvider *MP);
 
   /// run - Start execution with the specified function and arguments.
   ///