[vmkit-commits] [vmkit] r77595 - in /vmkit/trunk: include/mvm/JIT.h lib/JnJVM/Compiler/JnjvmModuleProvider.cpp lib/Mvm/Compiler/JIT.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Jul 30 06:18:18 PDT 2009


Author: geoffray
Date: Thu Jul 30 08:18:13 2009
New Revision: 77595

URL: http://llvm.org/viewvc/llvm-project?rev=77595&view=rev
Log:
When entering JnjvmModuleProvider::materializeFunction, the JIT
lock must be held.


Modified:
    vmkit/trunk/include/mvm/JIT.h
    vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp
    vmkit/trunk/lib/Mvm/Compiler/JIT.cpp

Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=77595&r1=77594&r2=77595&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Thu Jul 30 08:18:13 2009
@@ -191,6 +191,8 @@
    static void AddStandardCompilePasses();
 
    static const char* getHostTriple();
+
+   static void releaseJITAfterGC(bool);
 };
 
 } // end namespace mvm

Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp?rev=77595&r1=77594&r2=77595&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Thu Jul 30 08:18:13 2009
@@ -92,7 +92,11 @@
 
 bool JnjvmModuleProvider::materializeFunction(Function *F, 
                                               std::string *ErrInfo) {
-  
+
+  // When the thread enters here, it _must_ hold the JIT lock.
+  mvm::Thread* th = mvm::Thread::get();
+  th->releaseJIT = mvm::MvmModule::releaseJITAfterGC;
+
   if (!(F->hasNotBeenReadFromBitcode())) 
     return false;
  

Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=77595&r1=77594&r2=77595&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Thu Jul 30 08:18:13 2009
@@ -298,7 +298,7 @@
   
 }
 
-static void releaseJIT(bool goBack) {
+void MvmModule::releaseJITAfterGC(bool goBack) {
   if (MvmModule::executionEngine) {
     if (goBack) MvmModule::executionEngine->lock.acquire();
     else MvmModule::executionEngine->lock.release();
@@ -317,7 +317,7 @@
     th->enterUncooperativeCode();
     executionEngine->lock.acquire();
     th->leaveUncooperativeCode();
-    if (th->isMvmThread()) th->releaseJIT = releaseJIT;
+    if (th->isMvmThread()) th->releaseJIT = releaseJITAfterGC;
   }
   return true;
 }
@@ -325,7 +325,7 @@
 void MvmModule::unprotectIR() {
   if (executionEngine) executionEngine->lock.release();
   Thread* th = Thread::get();
-  if (th->isMvmThread()) th->releaseJIT = releaseJIT;
+  if (th->isMvmThread()) th->releaseJIT = 0;
 }
 
 





More information about the vmkit-commits mailing list