[vmkit-commits] [vmkit] r143835 - in /vmkit/trunk/lib/J3/VMCore: JnjvmClassLoader.cpp JnjvmClassLoader.h

Will Dietz wdietz2 at illinois.edu
Sat Nov 5 14:21:26 PDT 2011


Author: wdietz2
Date: Sat Nov  5 16:21:26 2011
New Revision: 143835

URL: http://llvm.org/viewvc/llvm-project?rev=143835&view=rev
Log:
Add new 'nativesLock' to protect the registerNatives map.

Using the classloader lock, as we did before, causes deadlocks in certain
situations, and this is a cleaner approach anyway.

Modified:
    vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
    vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h

Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=143835&r1=143834&r2=143835&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Sat Nov  5 16:21:26 2011
@@ -1044,17 +1044,17 @@
 }
 
 void JnjvmClassLoader::registerNative(JavaMethod * meth, word_t fnPtr) {
-  lock.lock();
+  nativesLock.lock();
   // Don't support multiple levels of registerNatives
   assert(registeredNatives.find(meth) == registeredNatives.end());
 
   registeredNatives[meth] = fnPtr;
-  lock.unlock();
+  nativesLock.unlock();
 }
 
 word_t JnjvmClassLoader::getRegisteredNative(const JavaMethod * meth) {
-  lock.lock();
+  nativesLock.lock();
   word_t res = registeredNatives[meth];
-  lock.unlock();
+  nativesLock.unlock();
   return res;
 }

Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h?rev=143835&r1=143834&r2=143835&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h Sat Nov  5 16:21:26 2011
@@ -113,6 +113,10 @@
   ///
   std::map<const JavaMethod*,word_t> registeredNatives;
 
+  /// nativesLock - Locks the registeredNatives map above
+  ///
+  mvm::LockRecursive nativesLock;
+
 public:
   
   /// allocator - Reference to the memory allocator, which will allocate UTF8s,





More information about the vmkit-commits mailing list