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

Nicolas Geoffray nicolas.geoffray at lip6.fr
Fri Oct 10 01:25:32 PDT 2008


Hi Mon,

We're having a conflict here.

Originally, materializing a function was guarded. However, in Java, 
materializing a function may execute Java code that use locks, hence 
deadlocks can happen.
So I moved the guard after materialization.

On a more general note I *don't* think materializing a function should 
be guarded by the JIT compiler. The JIT's mutex should only protect JIT 
internal data. Materializing a function does not modify any JIT data.

Nicolas


Mon P Wang wrote:
> Author: wangmp
> Date: Thu Oct  9 20:47:42 2008
> New Revision: 57340
>
> URL: http://llvm.org/viewvc/llvm-project?rev=57340&view=rev
> Log:
> Moved guard mutex upwards to guard materializing a function
> in getPointerToFunction
>
>
> 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=57340&r1=57339&r2=57340&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Thu Oct  9 20:47:42 2008
> @@ -489,6 +489,8 @@
>    if (void *Addr = getPointerToGlobalIfAvailable(F))
>      return Addr;   // Check if function already code gen'd
>  
> +  MutexGuard locked(lock);
> +
>    // Make sure we read in the function if it exists in this Module.
>    if (F->hasNotBeenReadFromBitcode()) {
>      // Determine the module provider this function is provided by.
> @@ -509,13 +511,11 @@
>        abort();
>      }
>    }
> -  
> +
>    if (void *Addr = getPointerToGlobalIfAvailable(F)) {
>      return Addr;
>    }
>  
> -  MutexGuard locked(lock);
> -  
>    if (F->isDeclaration()) {
>      void *Addr = getPointerToNamedFunction(F->getName());
>      addGlobalMapping(F, Addr);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>   




More information about the llvm-commits mailing list