TheJITResolver = 0;
}
+ /// getFunctionStubIfAvailable - This returns a pointer to a function stub
+ /// if it has already been created.
+ void *getFunctionStubIfAvailable(Function *F);
+
/// getFunctionStub - This returns a pointer to a function stub, creating
/// one on demand as needed.
void *getFunctionStub(Function *F);
JITResolver *JITResolver::TheJITResolver = 0;
+/// getFunctionStubIfAvailable - This returns a pointer to a function stub
+/// if it has already been created.
+void *JITResolver::getFunctionStubIfAvailable(Function *F) {
+ MutexGuard locked(TheJIT->lock);
+
+ // If we already have a stub for this function, recycle it.
+ void *&Stub = state.getFunctionToStubMap(locked)[F];
+ return Stub;
+}
+
/// getFunctionStub - This returns a pointer to a function stub, creating
/// one on demand as needed.
void *JITResolver::getFunctionStub(Function *F) {
// If we have already compiled the function, return a pointer to its body.
Function *F = cast<Function>(V);
- void *ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F);
+ void *ResultPtr;
+ if (!DoesntNeedStub)
+ // Return the function stub if it's already created.
+ ResultPtr = Resolver.getFunctionStubIfAvailable(F);
+ else
+ ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F);
if (ResultPtr) return ResultPtr;
if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode()) {