[llvm-commits] [llvm] r49988 - /llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Apr 20 01:33:02 PDT 2008


Author: geoffray
Date: Sun Apr 20 03:33:02 2008
New Revision: 49988

URL: http://llvm.org/viewvc/llvm-project?rev=49988&view=rev
Log:
Do not hold the JIT lock when materializing a function and verify if the
function has already been codegen'd. This is required by the Java class loading
mechanism which executes Java code when materializing a function.


Modified:
    llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=49988&r1=49987&r2=49988&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Sun Apr 20 03:33:02 2008
@@ -301,7 +301,6 @@
 /// specified function, compiling it if neccesary.
 ///
 void *JIT::getPointerToFunction(Function *F) {
-  MutexGuard locked(lock);
 
   if (void *Addr = getPointerToGlobalIfAvailable(F))
     return Addr;   // Check if function already code gen'd
@@ -326,7 +325,13 @@
       abort();
     }
   }
+  
+  if (void *Addr = getPointerToGlobalIfAvailable(F)) {
+    return Addr;
+  }
 
+  MutexGuard locked(lock);
+  
   if (F->isDeclaration()) {
     void *Addr = getPointerToNamedFunction(F->getName());
     addGlobalMapping(F, Addr);





More information about the llvm-commits mailing list