summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-10-14 21:37:41 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-10-14 21:37:41 +0000
commit005e5e9a482674b648ff8595c65239efab9b6276 (patch)
tree71ab02ce6dd17e8f7b9943cd96ffb06db5e5fe12 /lib
parent7b2b40f9ac21e7349735dd7a5096f29a35d8cd02 (diff)
downloadllvm-005e5e9a482674b648ff8595c65239efab9b6276.tar.gz
llvm-005e5e9a482674b648ff8595c65239efab9b6276.tar.bz2
llvm-005e5e9a482674b648ff8595c65239efab9b6276.tar.xz
Enabling incremental bytecode loading in the JIT:
* 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
Diffstat (limited to 'lib')
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp15
-rw-r--r--lib/ExecutionEngine/JIT/JIT.h4
-rw-r--r--lib/ExecutionEngine/JIT/VM.cpp3
-rw-r--r--lib/ExecutionEngine/JIT/VM.h4
4 files changed, 17 insertions, 9 deletions
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index d2de0a8b50..9bdaa57017 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -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
diff --git a/lib/ExecutionEngine/JIT/JIT.h b/lib/ExecutionEngine/JIT/JIT.h
index f79be1f349..ddfd8964f8 100644
--- a/lib/ExecutionEngine/JIT/JIT.h
+++ b/lib/ExecutionEngine/JIT/JIT.h
@@ -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.
///
diff --git a/lib/ExecutionEngine/JIT/VM.cpp b/lib/ExecutionEngine/JIT/VM.cpp
index ee7e311ebb..622215b7a7 100644
--- a/lib/ExecutionEngine/JIT/VM.cpp
+++ b/lib/ExecutionEngine/JIT/VM.cpp
@@ -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());
diff --git a/lib/ExecutionEngine/JIT/VM.h b/lib/ExecutionEngine/JIT/VM.h
index f79be1f349..ddfd8964f8 100644
--- a/lib/ExecutionEngine/JIT/VM.h
+++ b/lib/ExecutionEngine/JIT/VM.h
@@ -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.
///