[vmkit-commits] [vmkit] r80242 - /vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Aug 27 06:37:15 PDT 2009


Author: geoffray
Date: Thu Aug 27 08:37:14 2009
New Revision: 80242

URL: http://llvm.org/viewvc/llvm-project?rev=80242&view=rev
Log:
Put the thread state consistent, whether matierializeFunction is called
by the jit or the pass manager.


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

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Thu Aug 27 08:37:14 2009
@@ -77,6 +77,15 @@
 bool JnjvmModuleProvider::materializeFunction(Function *F, 
                                               std::string *ErrInfo) {
   
+  // materializeFunction is called by the LLVM JIT, which does not know
+  // about the call stack of jnjvm. Update the call stack if this
+  // function was called by the LLVM JIT. The other place where
+  // materializeFunction is called is in the pass managers; in such
+  // a case, jnjvm has already settled the call stack.
+  JavaThread* th = JavaThread::get();
+  bool isNative = th->isInNative();
+  if (!isNative) th->startNative(5);
+
   // The caller of materializeFunction *must* always hold the JIT lock.
   // Because we are materializing a function here, we must release the
   // JIT lock and get the global vmkit lock to be thread-safe.
@@ -91,6 +100,7 @@
     mvm::MvmModule::unprotectIR(); 
     // Reacquire and go back to the JIT function.
     mvm::MvmModule::executionEngine->lock.acquire();
+    if (!isNative) th->endNative();
     return false;
   }
 
@@ -98,8 +108,10 @@
     mvm::MvmModule::unprotectIR(); 
     // Reacquire and go back to the JIT function.
     mvm::MvmModule::executionEngine->lock.acquire();
+    if (!isNative) th->endNative();
     return false;
   }
+  
 
   JavaMethod* meth = Comp->getJavaMethod(F);
   
@@ -134,7 +146,8 @@
   
   if (F->isDeclaration())
     mvm::MvmModule::executionEngine->updateGlobalMapping(F, val);
-
+  
+  if (!isNative) th->endNative();
 
   return false;
 }





More information about the vmkit-commits mailing list