[vmkit-commits] [vmkit] r72884 - /vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Jun 4 12:53:39 PDT 2009


Author: geoffray
Date: Thu Jun  4 14:53:39 2009
New Revision: 72884

URL: http://llvm.org/viewvc/llvm-project?rev=72884&view=rev
Log:
Fix race condition.


Modified:
    vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp Thu Jun  4 14:53:39 2009
@@ -478,9 +478,10 @@
 }
 
 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.
+  mvm::MvmModule::protectIR();
   if (!virtualBufFunction) {
-    // Lock here because we are called by arbitrary code
-    mvm::MvmModule::protectIR();
     virtualBufFunction = createFunctionCallBuf(true);
     if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
       signature->setVirtualCallBuf((intptr_t)
@@ -488,15 +489,16 @@
       // Now that it's compiled, we don't need the IR anymore
       virtualBufFunction->deleteBody();
     }
-    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.
+  mvm::MvmModule::protectIR();
   if (!virtualAPFunction) {
-    // Lock here because we are called by arbitrary code
-    mvm::MvmModule::protectIR();
     virtualAPFunction = createFunctionCallAP(true);
     if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
       signature->setVirtualCallAP((intptr_t)
@@ -504,15 +506,16 @@
       // Now that it's compiled, we don't need the IR anymore
       virtualAPFunction->deleteBody();
     }
-    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.
+  mvm::MvmModule::protectIR();
   if (!staticBufFunction) {
-    // Lock here because we are called by arbitrary code
-    mvm::MvmModule::protectIR();
     staticBufFunction = createFunctionCallBuf(false);
     if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
       signature->setStaticCallBuf((intptr_t)
@@ -520,15 +523,16 @@
       // Now that it's compiled, we don't need the IR anymore
       staticBufFunction->deleteBody();
     }
-    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.
+  mvm::MvmModule::protectIR();
   if (!staticAPFunction) {
-    // Lock here because we are called by arbitrary code
-    mvm::MvmModule::protectIR();
     staticAPFunction = createFunctionCallAP(false);
     if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
       signature->setStaticCallAP((intptr_t)
@@ -536,8 +540,8 @@
       // Now that it's compiled, we don't need the IR anymore
       staticAPFunction->deleteBody();
     }
-    mvm::MvmModule::unprotectIR();
   }
+  mvm::MvmModule::unprotectIR();
   return staticAPFunction;
 }
 





More information about the vmkit-commits mailing list