[vmkit-commits] [vmkit] r62229 - in /vmkit/trunk: include/mvm/JIT.h lib/JnJVM/VMCore/JnjvmModule.cpp lib/JnJVM/VMCore/JnjvmModuleProvider.cpp lib/Mvm/Runtime/JIT.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Jan 14 07:34:08 PST 2009


Author: geoffray
Date: Wed Jan 14 09:34:07 2009
New Revision: 62229

URL: http://llvm.org/viewvc/llvm-project?rev=62229&view=rev
Log:
Use a specific lock for protecting IR creation, not the JIT lock.


Modified:
    vmkit/trunk/include/mvm/JIT.h
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
    vmkit/trunk/lib/Mvm/Runtime/JIT.cpp

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

==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Wed Jan 14 09:34:07 2009
@@ -33,6 +33,7 @@
 namespace mvm {
 
 class LockNormal;
+class LockRecursive;
 
 const double MaxDouble = +INFINITY; //1.0 / 0.0;
 const double MinDouble = -INFINITY;//-1.0 / 0.0;
@@ -159,6 +160,7 @@
 
   static llvm::ExecutionEngine* executionEngine;
   static mvm::LockNormal protectEngine;
+  static mvm::LockRecursive protectIR;
   static llvm::Module *globalModule;
   static llvm::ExistingModuleProvider *globalModuleProvider;
   static const llvm::TargetData* TheTargetData;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Wed Jan 14 09:34:07 2009
@@ -1581,7 +1581,7 @@
 const llvm::FunctionType* LLVMSignatureInfo::getVirtualType() {
  if (!virtualType) {
     // Lock here because we are called by arbitrary code
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     std::vector<const llvm::Type*> llvmArgs;
     uint32 size = signature->nbArguments;
     Typedef* const* arguments = signature->getArgumentsType();
@@ -1601,6 +1601,7 @@
     LLVMAssessorInfo& LAI = 
       JnjvmModule::getTypedefInfo(signature->getReturnType());
     virtualType = FunctionType::get(LAI.llvmType, llvmArgs, false);
+    mvm::MvmModule::protectIR.unlock();
   }
   return virtualType;
 }
@@ -1608,7 +1609,7 @@
 const llvm::FunctionType* LLVMSignatureInfo::getStaticType() {
  if (!staticType) {
     // Lock here because we are called by arbitrary code
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     std::vector<const llvm::Type*> llvmArgs;
     uint32 size = signature->nbArguments;
     Typedef* const* arguments = signature->getArgumentsType();
@@ -1626,6 +1627,7 @@
     LLVMAssessorInfo& LAI = 
       JnjvmModule::getTypedefInfo(signature->getReturnType());
     staticType = FunctionType::get(LAI.llvmType, llvmArgs, false);
+    mvm::MvmModule::protectIR.unlock();
   }
   return staticType;
 }
@@ -1633,7 +1635,7 @@
 const llvm::FunctionType* LLVMSignatureInfo::getNativeType() {
   if (!nativeType) {
     // Lock here because we are called by arbitrary code
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     std::vector<const llvm::Type*> llvmArgs;
     uint32 size = signature->nbArguments;
     Typedef* const* arguments = signature->getArgumentsType();
@@ -1654,6 +1656,7 @@
     LLVMAssessorInfo& LAI = 
       JnjvmModule::getTypedefInfo(signature->getReturnType());
     nativeType = FunctionType::get(LAI.llvmType, llvmArgs, false);
+    mvm::MvmModule::protectIR.unlock();
   }
   return nativeType;
 }
@@ -1795,7 +1798,7 @@
 const FunctionType* LLVMSignatureInfo::getVirtualBufType() {
   if (!virtualBufType) {
     // Lock here because we are called by arbitrary code
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     std::vector<const llvm::Type*> Args2;
     Args2.push_back(JnjvmModule::ConstantPoolType); // ctp
     Args2.push_back(getVirtualPtrType());
@@ -1804,6 +1807,7 @@
     LLVMAssessorInfo& LAI = 
       JnjvmModule::getTypedefInfo(signature->getReturnType());
     virtualBufType = FunctionType::get(LAI.llvmType, Args2, false);
+    mvm::MvmModule::protectIR.unlock();
   }
   return virtualBufType;
 }
@@ -1811,7 +1815,7 @@
 const FunctionType* LLVMSignatureInfo::getStaticBufType() {
   if (!staticBufType) {
     // Lock here because we are called by arbitrary code
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     std::vector<const llvm::Type*> Args;
     Args.push_back(JnjvmModule::ConstantPoolType); // ctp
     Args.push_back(getStaticPtrType());
@@ -1819,6 +1823,7 @@
     LLVMAssessorInfo& LAI = 
       JnjvmModule::getTypedefInfo(signature->getReturnType());
     staticBufType = FunctionType::get(LAI.llvmType, Args, false);
+    mvm::MvmModule::protectIR.unlock();
   }
   return staticBufType;
 }
@@ -1826,13 +1831,14 @@
 Function* LLVMSignatureInfo::getVirtualBuf() {
   if (!virtualBufFunction) {
     // Lock here because we are called by arbitrary code
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     virtualBufFunction = createFunctionCallBuf(true);
     signature->setVirtualCallBuf((intptr_t)
       mvm::MvmModule::executionEngine->getPointerToGlobal(virtualBufFunction));
     if (!signature->initialLoader->getModule()->isStaticCompiling())
       // Now that it's compiled, we don't need the IR anymore
       virtualBufFunction->deleteBody();
+    mvm::MvmModule::protectIR.unlock();
   }
   return virtualBufFunction;
 }
@@ -1840,13 +1846,14 @@
 Function* LLVMSignatureInfo::getVirtualAP() {
   if (!virtualAPFunction) {
     // Lock here because we are called by arbitrary code
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     virtualAPFunction = createFunctionCallAP(true);
     signature->setVirtualCallAP((intptr_t)
       mvm::MvmModule::executionEngine->getPointerToGlobal(virtualAPFunction));
     if (!signature->initialLoader->getModule()->isStaticCompiling())
       // Now that it's compiled, we don't need the IR anymore
       virtualAPFunction->deleteBody();
+    mvm::MvmModule::protectIR.unlock();
   }
   return virtualAPFunction;
 }
@@ -1854,13 +1861,14 @@
 Function* LLVMSignatureInfo::getStaticBuf() {
   if (!staticBufFunction) {
     // Lock here because we are called by arbitrary code
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     staticBufFunction = createFunctionCallBuf(false);
     signature->setStaticCallBuf((intptr_t)
       mvm::MvmModule::executionEngine->getPointerToGlobal(staticBufFunction));
     if (!signature->initialLoader->getModule()->isStaticCompiling())
       // Now that it's compiled, we don't need the IR anymore
       staticBufFunction->deleteBody();
+    mvm::MvmModule::protectIR.unlock();
   }
   return staticBufFunction;
 }
@@ -1868,29 +1876,32 @@
 Function* LLVMSignatureInfo::getStaticAP() {
   if (!staticAPFunction) {
     // Lock here because we are called by arbitrary code
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     staticAPFunction = createFunctionCallAP(false);
     signature->setStaticCallAP((intptr_t)
       mvm::MvmModule::executionEngine->getPointerToGlobal(staticAPFunction));
     if (!signature->initialLoader->getModule()->isStaticCompiling())
       // Now that it's compiled, we don't need the IR anymore
       staticAPFunction->deleteBody();
+    mvm::MvmModule::protectIR.unlock();
   }
   return staticAPFunction;
 }
 
 void JnjvmModule::resolveVirtualClass(Class* cl) {
   // Lock here because we may be called by a class resolver
-  llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+  mvm::MvmModule::protectIR.lock();
   LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
   LCI->getVirtualType();
+  mvm::MvmModule::protectIR.unlock();
 }
 
 void JnjvmModule::resolveStaticClass(Class* cl) {
   // Lock here because we may be called by a class initializer
-  llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+  mvm::MvmModule::protectIR.lock();
   LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
   LCI->getStaticType();
+  mvm::MvmModule::protectIR.unlock();
 }
 
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Wed Jan 14 09:34:07 2009
@@ -120,7 +120,7 @@
   Function* func = LMI->getMethod();
   if (func->hasNotBeenReadFromBitcode()) {
     // We are jitting. Take the lock.
-    llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+    mvm::MvmModule::protectIR.lock();
     JavaJIT jit(meth, func);
     if (isNative(meth->access)) {
       jit.nativeCompile();
@@ -131,6 +131,7 @@
       mvm::MvmModule::runPasses(func, loader->FunctionPasses);
       mvm::MvmModule::runPasses(func, JavaFunctionPasses);
     }
+    mvm::MvmModule::protectIR.unlock();
   }
   return func;
 }

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

==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/JIT.cpp Wed Jan 14 09:34:07 2009
@@ -235,6 +235,7 @@
 llvm::ExistingModuleProvider *MvmModule::globalModuleProvider;
 llvm::ExecutionEngine* MvmModule::executionEngine;
 mvm::LockNormal MvmModule::protectEngine;
+mvm::LockRecursive MvmModule::protectIR;
 
 
 uint64 MvmModule::getTypeSize(const llvm::Type* type) {





More information about the vmkit-commits mailing list