[vmkit-commits] [vmkit] r77600 - in /vmkit/trunk: include/mvm/JIT.h include/mvm/Threads/Thread.h lib/JnJVM/Compiler/JITInfo.cpp lib/JnJVM/Compiler/JavaJITCompiler.cpp lib/JnJVM/Compiler/JnjvmModule.cpp lib/JnJVM/Compiler/JnjvmModuleProvider.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 09:22:42 PDT 2009


Author: geoffray
Date: Thu Jul 30 11:22:24 2009
New Revision: 77600

URL: http://llvm.org/viewvc/llvm-project?rev=77600&view=rev
Log:
Revert to 77592, releasing the JIT lock before collecting was a stupid idea.


Modified:
    vmkit/trunk/include/mvm/JIT.h
    vmkit/trunk/include/mvm/Threads/Thread.h
    vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.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/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=77600&r1=77599&r2=77600&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Thu Jul 30 11:22:24 2009
@@ -183,7 +183,7 @@
 
    static int disassemble(unsigned int* addr);
   
-   static bool protectIR();
+   static void protectIR();
    static void unprotectIR();
 
    static void copyDefinitions(llvm::Module* Dst, llvm::Module* Src);
@@ -191,8 +191,6 @@
    static void AddStandardCompilePasses();
 
    static const char* getHostTriple();
-
-   static void releaseJITAfterGC(bool);
 };
 
 } // end namespace mvm

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

==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Thu Jul 30 11:22:24 2009
@@ -250,12 +250,7 @@
   /// 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/JITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp?rev=77600&r1=77599&r2=77600&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp Thu Jul 30 11:22:24 2009
@@ -214,7 +214,7 @@
 const llvm::FunctionType* LLVMSignatureInfo::getVirtualType() {
  if (!virtualType) {
     // Lock here because we are called by arbitrary code
-    bool un = mvm::MvmModule::protectIR();
+    mvm::MvmModule::protectIR();
     std::vector<const llvm::Type*> llvmArgs;
     uint32 size = signature->nbArguments;
     Typedef* const* arguments = signature->getArgumentsType();
@@ -234,7 +234,7 @@
     LLVMAssessorInfo& LAI = 
       JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
     virtualType = FunctionType::get(LAI.llvmType, llvmArgs, false);
-    if (un) mvm::MvmModule::unprotectIR();
+    mvm::MvmModule::unprotectIR();
   }
   return virtualType;
 }
@@ -242,7 +242,7 @@
 const llvm::FunctionType* LLVMSignatureInfo::getStaticType() {
  if (!staticType) {
     // Lock here because we are called by arbitrary code
-    bool un = mvm::MvmModule::protectIR();
+    mvm::MvmModule::protectIR();
     std::vector<const llvm::Type*> llvmArgs;
     uint32 size = signature->nbArguments;
     Typedef* const* arguments = signature->getArgumentsType();
@@ -260,7 +260,7 @@
     LLVMAssessorInfo& LAI = 
       JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
     staticType = FunctionType::get(LAI.llvmType, llvmArgs, false);
-    if (un) mvm::MvmModule::unprotectIR();
+    mvm::MvmModule::unprotectIR();
   }
   return staticType;
 }
@@ -268,7 +268,7 @@
 const llvm::FunctionType* LLVMSignatureInfo::getNativeType() {
   if (!nativeType) {
     // Lock here because we are called by arbitrary code
-    bool un = mvm::MvmModule::protectIR();
+    mvm::MvmModule::protectIR();
     std::vector<const llvm::Type*> llvmArgs;
     uint32 size = signature->nbArguments;
     Typedef* const* arguments = signature->getArgumentsType();
@@ -298,7 +298,7 @@
     const llvm::Type* RetType = LAI.llvmType == JnjvmModule::JavaObjectType ?
       LAI.llvmTypePtr : LAI.llvmType;
     nativeType = FunctionType::get(RetType, llvmArgs, false);
-    if (un) mvm::MvmModule::unprotectIR();
+    mvm::MvmModule::unprotectIR();
   }
   return nativeType;
 }
@@ -447,7 +447,7 @@
 const FunctionType* LLVMSignatureInfo::getVirtualBufType() {
   if (!virtualBufType) {
     // Lock here because we are called by arbitrary code
-    bool un = mvm::MvmModule::protectIR();
+    mvm::MvmModule::protectIR();
     std::vector<const llvm::Type*> Args2;
     Args2.push_back(JnjvmModule::ConstantPoolType); // ctp
     Args2.push_back(getVirtualPtrType());
@@ -456,7 +456,7 @@
     LLVMAssessorInfo& LAI = 
       JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
     virtualBufType = FunctionType::get(LAI.llvmType, Args2, false);
-    if (un) mvm::MvmModule::unprotectIR();
+    mvm::MvmModule::unprotectIR();
   }
   return virtualBufType;
 }
@@ -464,7 +464,7 @@
 const FunctionType* LLVMSignatureInfo::getStaticBufType() {
   if (!staticBufType) {
     // Lock here because we are called by arbitrary code
-    bool un = mvm::MvmModule::protectIR();
+    mvm::MvmModule::protectIR();
     std::vector<const llvm::Type*> Args;
     Args.push_back(JnjvmModule::ConstantPoolType); // ctp
     Args.push_back(getStaticPtrType());
@@ -472,7 +472,7 @@
     LLVMAssessorInfo& LAI = 
       JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
     staticBufType = FunctionType::get(LAI.llvmType, Args, false);
-    if (un) mvm::MvmModule::unprotectIR();
+    mvm::MvmModule::unprotectIR();
   }
   return staticBufType;
 }
@@ -480,7 +480,7 @@
 Function* LLVMSignatureInfo::getVirtualBuf() {
   // Lock here because we are called by arbitrary code. Also put that here
   // because we are waiting on virtualBufFunction to have an address.
-  bool un = mvm::MvmModule::protectIR();
+  mvm::MvmModule::protectIR();
   if (!virtualBufFunction) {
     virtualBufFunction = createFunctionCallBuf(true);
     if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
@@ -490,14 +490,14 @@
       virtualBufFunction->deleteBody();
     }
   }
-  if (un) mvm::MvmModule::unprotectIR();
+  mvm::MvmModule::unprotectIR();
   return virtualBufFunction;
 }
 
 Function* LLVMSignatureInfo::getVirtualAP() {
   // Lock here because we are called by arbitrary code. Also put that here
   // because we are waiting on virtualAPFunction to have an address.
-  bool un = mvm::MvmModule::protectIR();
+  mvm::MvmModule::protectIR();
   if (!virtualAPFunction) {
     virtualAPFunction = createFunctionCallAP(true);
     if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
@@ -507,14 +507,14 @@
       virtualAPFunction->deleteBody();
     }
   }
-  if (un) mvm::MvmModule::unprotectIR();
+  mvm::MvmModule::unprotectIR();
   return virtualAPFunction;
 }
 
 Function* LLVMSignatureInfo::getStaticBuf() {
   // Lock here because we are called by arbitrary code. Also put that here
   // because we are waiting on staticBufFunction to have an address.
-  bool un = mvm::MvmModule::protectIR();
+  mvm::MvmModule::protectIR();
   if (!staticBufFunction) {
     staticBufFunction = createFunctionCallBuf(false);
     if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
@@ -524,14 +524,14 @@
       staticBufFunction->deleteBody();
     }
   }
-  if (un) mvm::MvmModule::unprotectIR();
+  mvm::MvmModule::unprotectIR();
   return staticBufFunction;
 }
 
 Function* LLVMSignatureInfo::getStaticAP() {
   // Lock here because we are called by arbitrary code. Also put that here
   // because we are waiting on staticAPFunction to have an address.
-  bool un = mvm::MvmModule::protectIR();
+  mvm::MvmModule::protectIR();
   if (!staticAPFunction) {
     staticAPFunction = createFunctionCallAP(false);
     if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
@@ -541,7 +541,7 @@
       staticAPFunction->deleteBody();
     }
   }
-  if (un) mvm::MvmModule::unprotectIR();
+  mvm::MvmModule::unprotectIR();
   return staticAPFunction;
 }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp Thu Jul 30 11:22:24 2009
@@ -209,10 +209,10 @@
 void* JavaJITCompiler::materializeFunction(JavaMethod* meth) {
   Function* func = parseFunction(meth);
  
-  bool un = mvm::MvmModule::protectIR();
+  mvm::MvmModule::protectIR();
   void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
   func->deleteBody();
-  if (un) mvm::MvmModule::unprotectIR();
+  mvm::MvmModule::unprotectIR();
 
   return res;
 }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Thu Jul 30 11:22:24 2009
@@ -72,18 +72,18 @@
   
 void JavaLLVMCompiler::resolveVirtualClass(Class* cl) {
   // Lock here because we may be called by a class resolver
-  bool un = mvm::MvmModule::protectIR();
+  mvm::MvmModule::protectIR();
   LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
   LCI->getVirtualType();
-  if (un) mvm::MvmModule::unprotectIR();
+  mvm::MvmModule::unprotectIR();
 }
 
 void JavaLLVMCompiler::resolveStaticClass(Class* cl) {
   // Lock here because we may be called by a class initializer
-  bool un = mvm::MvmModule::protectIR();
+  mvm::MvmModule::protectIR();
   LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
   LCI->getStaticType();
-  if (un) mvm::MvmModule::unprotectIR();
+  mvm::MvmModule::unprotectIR();
 }
 
 
@@ -199,9 +199,9 @@
   
   OffsetIsolateInThreadConstant = ConstantInt::get(Type::Int32Ty, 3);
   OffsetDoYieldInThreadConstant = ConstantInt::get(Type::Int32Ty, 6);
-  OffsetJNIInThreadConstant = ConstantInt::get(Type::Int32Ty, 13);
-  OffsetJavaExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 14);
-  OffsetCXXExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 15);
+  OffsetJNIInThreadConstant = ConstantInt::get(Type::Int32Ty, 12);
+  OffsetJavaExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 13);
+  OffsetCXXExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 14);
   
   ClassReadyConstant = ConstantInt::get(Type::Int8Ty, ready);
   
@@ -332,7 +332,7 @@
   Function* func = LMI->getMethod();
   if (func->hasNotBeenReadFromBitcode()) {
     // We are jitting. Take the lock.
-    bool un = JnjvmModule::protectIR();
+    JnjvmModule::protectIR();
     if (func->hasNotBeenReadFromBitcode()) {
       JavaJIT jit(this, meth, func);
       if (isNative(meth->access)) {
@@ -344,7 +344,7 @@
         JnjvmModule::runPasses(func, JavaFunctionPasses);
       }
     }
-    if (un) JnjvmModule::unprotectIR();
+    JnjvmModule::unprotectIR();
   }
   return func;
 }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Thu Jul 30 11:22:24 2009
@@ -92,20 +92,12 @@
 
 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())) {
-    th->releaseJIT = 0;
+  
+  if (!(F->hasNotBeenReadFromBitcode())) 
     return false;
-  }
  
-  if (mvm::MvmModule::executionEngine->getPointerToGlobalIfAvailable(F)) {
-    th->releaseJIT = 0;
+  if (mvm::MvmModule::executionEngine->getPointerToGlobalIfAvailable(F))
     return false;
-  }
 
   JavaMethod* meth = LLVMMethodInfo::get(F);
   
@@ -135,7 +127,6 @@
     assert(meth->classDef->isInitializing() && "Class not ready");
   }
 
-  th->releaseJIT = 0;
   return false;
 }
 

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=77600&r1=77599&r2=77600&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Thu Jul 30 11:22:24 2009
@@ -46,12 +46,11 @@
 ;;; Field 9: lastSP
 ;;; Field 10: internalThreadID
 ;;; field 11: routine
-;;; field 12: releaseJIT
-;;; field 13: jnienv
-;;; field 14: Java pendingException
-;;; field 15: CXX pendingException
+;;; field 12: jnienv
+;;; field 13: Java pendingException
+;;; field 14: CXX pendingException
 %JavaThread = type { %VT*, %JavaThread*, %JavaThread*, i8*, i8*, i8*, i1, i1,
-                     i1, i8*, i8*, i8*, i8*, i8*, %JavaObject*, i8* }
+                     i1, 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=77600&r1=77599&r2=77600&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Thu Jul 30 11:22:24 2009
@@ -45,9 +45,7 @@
 }
 
 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=77600&r1=77599&r2=77600&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Thu Jul 30 11:22:24 2009
@@ -298,34 +298,19 @@
   
 }
 
-void MvmModule::releaseJITAfterGC(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.
-bool MvmModule::protectIR() {
+void MvmModule::protectIR() {
   if (executionEngine) {
     mvm::Thread* th = mvm::Thread::get();
-    
-    // If we already own the lock, don't lock it again.
-    if (th->isMvmThread() && th->releaseJIT) return false;
-
     th->enterUncooperativeCode();
     executionEngine->lock.acquire();
     th->leaveUncooperativeCode();
-    if (th->isMvmThread()) th->releaseJIT = releaseJITAfterGC;
   }
-  return true;
 }
 
 void MvmModule::unprotectIR() {
   if (executionEngine) executionEngine->lock.release();
-  Thread* th = Thread::get();
-  if (th->isMvmThread()) th->releaseJIT = 0;
 }
 
 





More information about the vmkit-commits mailing list