[vmkit-commits] [vmkit] r77593 - in /vmkit/trunk: include/mvm/Threads/Thread.h lib/JnJVM/Compiler/JnjvmModule.cpp lib/JnJVM/LLVMRuntime/runtime-default.ll lib/Mvm/CommonThread/ctthread.cpp lib/Mvm/Compiler/JIT.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Jul 30 05:23:55 PDT 2009


Author: geoffray
Date: Thu Jul 30 07:23:55 2009
New Revision: 77593

URL: http://llvm.org/viewvc/llvm-project?rev=77593&view=rev
Log:
Release JIT lock when entering GC. Because we don't want compile-time
dependency with the JIT, we use a function pointer, stored in the thread
class.


Modified:
    vmkit/trunk/include/mvm/Threads/Thread.h
    vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
    vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
    vmkit/trunk/lib/Mvm/Compiler/JIT.cpp

Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=77593&r1=77592&r2=77593&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Thu Jul 30 07:23:55 2009
@@ -250,7 +250,12 @@
   /// routine - The function to invoke when the thread starts.
   ///
   void (*routine)(mvm::Thread*);
- 
+
+  /// releaseJIT - Function to release any locks held while we are trying to
+  /// join a collection.
+  ///
+  void (*releaseJIT)(bool);
+
 #ifdef SERVICE
   /// stoppingService - The service that is currently stopping.
   ///

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Thu Jul 30 07:23:55 2009
@@ -199,9 +199,9 @@
   
   OffsetIsolateInThreadConstant = ConstantInt::get(Type::Int32Ty, 3);
   OffsetDoYieldInThreadConstant = ConstantInt::get(Type::Int32Ty, 6);
-  OffsetJNIInThreadConstant = ConstantInt::get(Type::Int32Ty, 12);
-  OffsetJavaExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 13);
-  OffsetCXXExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 14);
+  OffsetJNIInThreadConstant = ConstantInt::get(Type::Int32Ty, 13);
+  OffsetJavaExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 14);
+  OffsetCXXExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 15);
   
   ClassReadyConstant = ConstantInt::get(Type::Int8Ty, ready);
   

Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=77593&r1=77592&r2=77593&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Thu Jul 30 07:23:55 2009
@@ -46,11 +46,12 @@
 ;;; Field 9: lastSP
 ;;; Field 10: internalThreadID
 ;;; field 11: routine
-;;; field 12: jnienv
-;;; field 13: Java pendingException
-;;; field 14: CXX pendingException
+;;; field 12: releaseJIT
+;;; field 13: jnienv
+;;; field 14: Java pendingException
+;;; field 15: CXX pendingException
 %JavaThread = type { %VT*, %JavaThread*, %JavaThread*, i8*, i8*, i8*, i1, i1,
-                     i1, i8*, i8*, i8*, i8*, %JavaObject*, i8* }
+                     i1, i8*, i8*, i8*, i8*, i8*, %JavaObject*, i8* }
 
 
 %Attribut = type { %UTF8*, i32, i32 }

Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=77593&r1=77592&r2=77593&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Thu Jul 30 07:23:55 2009
@@ -45,7 +45,9 @@
 }
 
 void Thread::joinCollection() {
+  if (releaseJIT) releaseJIT(false);
   Collector::traceStackThread();
+  if (releaseJIT) releaseJIT(true);
 }
 
 

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

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Thu Jul 30 07:23:55 2009
@@ -298,6 +298,13 @@
   
 }
 
+static void releaseJIT(bool goBack) {
+  if (MvmModule::executionEngine) {
+    if (goBack) MvmModule::executionEngine->lock.acquire();
+    else MvmModule::executionEngine->lock.release();
+  }
+}
+
 // We protect the creation of IR with the executionEngine lock because
 // codegen'ing a function may also create IR objects.
 void MvmModule::protectIR() {
@@ -306,11 +313,14 @@
     th->enterUncooperativeCode();
     executionEngine->lock.acquire();
     th->leaveUncooperativeCode();
+    if (th->isMvmThread()) th->releaseJIT = releaseJIT;
   }
 }
 
 void MvmModule::unprotectIR() {
   if (executionEngine) executionEngine->lock.release();
+  Thread* th = Thread::get();
+  if (th->isMvmThread()) th->releaseJIT = releaseJIT;
 }
 
 





More information about the vmkit-commits mailing list