aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ExecutionEngine
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-22 02:50:12 +0000
committerChris Lattner <sabre@nondot.org>2007-10-22 02:50:12 +0000
commit5c50760d3294419f42a78d0518395b584336c045 (patch)
tree1ab0a8fc513ee27f87b8f0a4c992a933df0a4677 /lib/ExecutionEngine
parentca6b6a4738a9843531272d455ac6c4e7a6716d3c (diff)
downloadexternal_llvm-5c50760d3294419f42a78d0518395b584336c045.zip
external_llvm-5c50760d3294419f42a78d0518395b584336c045.tar.gz
external_llvm-5c50760d3294419f42a78d0518395b584336c045.tar.bz2
add a mechanism for the JIT to invoke a function to lazily create functions as they are referenced.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43210 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r--lib/ExecutionEngine/ExecutionEngine.cpp4
-rw-r--r--lib/ExecutionEngine/JIT/Intercept.cpp5
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index 2129dd5..d89a9bb 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -33,13 +33,13 @@ STATISTIC(NumGlobals , "Number of global vars initialized");
ExecutionEngine::EECtorFn ExecutionEngine::JITCtor = 0;
ExecutionEngine::EECtorFn ExecutionEngine::InterpCtor = 0;
-ExecutionEngine::ExecutionEngine(ModuleProvider *P) {
+ExecutionEngine::ExecutionEngine(ModuleProvider *P) : LazyFunctionCreator(0) {
LazyCompilationDisabled = false;
Modules.push_back(P);
assert(P && "ModuleProvider is null?");
}
-ExecutionEngine::ExecutionEngine(Module *M) {
+ExecutionEngine::ExecutionEngine(Module *M) : LazyFunctionCreator(0) {
LazyCompilationDisabled = false;
assert(M && "Module is null?");
Modules.push_back(new ExistingModuleProvider(M));
diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp
index 61035c2..318d606 100644
--- a/lib/ExecutionEngine/JIT/Intercept.cpp
+++ b/lib/ExecutionEngine/JIT/Intercept.cpp
@@ -101,6 +101,11 @@ void *JIT::getPointerToNamedFunction(const std::string &Name) {
Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr+1);
if (Ptr) return Ptr;
}
+
+ /// If a LazyFunctionCreator is installed, use it to get/create the function.
+ if (LazyFunctionCreator)
+ if (void *RP = LazyFunctionCreator(Name))
+ return RP;
cerr << "ERROR: Program used external function '" << Name
<< "' which could not be resolved!\n";