[vmkit-commits] [vmkit] r62230 - in /vmkit/trunk/lib/JnJVM/VMCore: JnjvmModule.cpp JnjvmModuleProvider.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Jan 14 07:40:57 PST 2009


Author: geoffray
Date: Wed Jan 14 09:40:57 2009
New Revision: 62230

URL: http://llvm.org/viewvc/llvm-project?rev=62230&view=rev
Log:
Don't reference the executionEngine when it does not exist.


Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Wed Jan 14 09:40:57 2009
@@ -1833,11 +1833,12 @@
     // Lock here because we are called by arbitrary code
     mvm::MvmModule::protectIR.lock();
     virtualBufFunction = createFunctionCallBuf(true);
-    signature->setVirtualCallBuf((intptr_t)
-      mvm::MvmModule::executionEngine->getPointerToGlobal(virtualBufFunction));
-    if (!signature->initialLoader->getModule()->isStaticCompiling())
+    if (!signature->initialLoader->getModule()->isStaticCompiling()) {
+      signature->setVirtualCallBuf((intptr_t)
+        mvm::MvmModule::executionEngine->getPointerToGlobal(virtualBufFunction));
       // Now that it's compiled, we don't need the IR anymore
       virtualBufFunction->deleteBody();
+    }
     mvm::MvmModule::protectIR.unlock();
   }
   return virtualBufFunction;
@@ -1848,11 +1849,12 @@
     // Lock here because we are called by arbitrary code
     mvm::MvmModule::protectIR.lock();
     virtualAPFunction = createFunctionCallAP(true);
-    signature->setVirtualCallAP((intptr_t)
-      mvm::MvmModule::executionEngine->getPointerToGlobal(virtualAPFunction));
-    if (!signature->initialLoader->getModule()->isStaticCompiling())
+    if (!signature->initialLoader->getModule()->isStaticCompiling()) {
+      signature->setVirtualCallAP((intptr_t)
+        mvm::MvmModule::executionEngine->getPointerToGlobal(virtualAPFunction));
       // Now that it's compiled, we don't need the IR anymore
       virtualAPFunction->deleteBody();
+    }
     mvm::MvmModule::protectIR.unlock();
   }
   return virtualAPFunction;
@@ -1863,11 +1865,12 @@
     // Lock here because we are called by arbitrary code
     mvm::MvmModule::protectIR.lock();
     staticBufFunction = createFunctionCallBuf(false);
-    signature->setStaticCallBuf((intptr_t)
-      mvm::MvmModule::executionEngine->getPointerToGlobal(staticBufFunction));
-    if (!signature->initialLoader->getModule()->isStaticCompiling())
+    if (!signature->initialLoader->getModule()->isStaticCompiling()) {
+      signature->setStaticCallBuf((intptr_t)
+        mvm::MvmModule::executionEngine->getPointerToGlobal(staticBufFunction));
       // Now that it's compiled, we don't need the IR anymore
       staticBufFunction->deleteBody();
+    }
     mvm::MvmModule::protectIR.unlock();
   }
   return staticBufFunction;
@@ -1878,11 +1881,12 @@
     // Lock here because we are called by arbitrary code
     mvm::MvmModule::protectIR.lock();
     staticAPFunction = createFunctionCallAP(false);
-    signature->setStaticCallAP((intptr_t)
-      mvm::MvmModule::executionEngine->getPointerToGlobal(staticAPFunction));
-    if (!signature->initialLoader->getModule()->isStaticCompiling())
+    if (!signature->initialLoader->getModule()->isStaticCompiling()) {
+      signature->setStaticCallAP((intptr_t)
+        mvm::MvmModule::executionEngine->getPointerToGlobal(staticAPFunction));
       // Now that it's compiled, we don't need the IR anymore
       staticAPFunction->deleteBody();
+    }
     mvm::MvmModule::protectIR.unlock();
   }
   return staticAPFunction;
@@ -2083,7 +2087,7 @@
   Function* func = getMethodInfo(meth)->getMethod();
   func->setName(name);
   assert(ptr && "No value given");
-  executionEngine->addGlobalMapping(func, ptr);
+  if (executionEngine) executionEngine->addGlobalMapping(func, ptr);
   func->setLinkage(GlobalValue::ExternalLinkage);
 }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Wed Jan 14 09:40:57 2009
@@ -180,9 +180,11 @@
 
 JnjvmModuleProvider::JnjvmModuleProvider(JnjvmModule *m) {
   TheModule = (Module*)m;
-  mvm::MvmModule::protectEngine.lock();
-  mvm::MvmModule::executionEngine->addModuleProvider(this);
-  mvm::MvmModule::protectEngine.unlock();
+  if (m->executionEngine) {
+    m->protectEngine.lock();
+    m->executionEngine->addModuleProvider(this);
+    m->protectEngine.unlock();
+  }
     
   JavaNativeFunctionPasses = new llvm::FunctionPassManager(this);
   JavaNativeFunctionPasses->add(new llvm::TargetData(m));
@@ -199,9 +201,11 @@
 }
 
 JnjvmModuleProvider::~JnjvmModuleProvider() {
-  mvm::MvmModule::protectEngine.lock();
-  mvm::MvmModule::executionEngine->removeModuleProvider(this);
-  mvm::MvmModule::protectEngine.unlock();
+  if (mvm::MvmModule::executionEngine) {
+    mvm::MvmModule::protectEngine.lock();
+    mvm::MvmModule::executionEngine->removeModuleProvider(this);
+    mvm::MvmModule::protectEngine.unlock();
+  }
   delete TheModule;
   delete JavaNativeFunctionPasses;
   delete JavaFunctionPasses;





More information about the vmkit-commits mailing list