[vmkit-commits] [vmkit] r105911 - in /vmkit/trunk/lib/J3: Classpath/ClasspathVMThread.inc VMCore/Jnjvm.cpp VMCore/Jnjvm.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Jun 13 01:02:36 PDT 2010


Author: geoffray
Date: Sun Jun 13 03:02:36 2010
New Revision: 105911

URL: http://llvm.org/viewvc/llvm-project?rev=105911&view=rev
Log:
Add an interface for entering and leaving the thread system.


Modified:
    vmkit/trunk/lib/J3/Classpath/ClasspathVMThread.inc
    vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/J3/VMCore/Jnjvm.h

Modified: vmkit/trunk/lib/J3/Classpath/ClasspathVMThread.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathVMThread.inc?rev=105911&r1=105910&r2=105911&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Classpath/ClasspathVMThread.inc (original)
+++ vmkit/trunk/lib/J3/Classpath/ClasspathVMThread.inc Sun Jun 13 03:02:36 2010
@@ -58,9 +58,7 @@
   bool isDaemon = vm->upcalls->daemon->getInstanceInt8Field(javaThread);
 
   if (!isDaemon) {
-    ts.nonDaemonLock.lock();
-    ts.nonDaemonThreads++;
-    ts.nonDaemonLock.unlock();
+    vm->threadSystem.enter();
   }
   
   // Run the VMThread::run function
@@ -68,11 +66,7 @@
  
   // Remove the thread from the list.
   if (!isDaemon) {
-    ts.nonDaemonLock.lock();
-    ts.nonDaemonThreads--;
-    if (ts.nonDaemonThreads == 0)
-      ts.nonDaemonVar.signal();
-    ts.nonDaemonLock.unlock();
+    vm->threadSystem.leave();
   }
 }
 

Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=105911&r1=105910&r2=105911&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Sun Jun 13 03:02:36 2010
@@ -1255,9 +1255,10 @@
   Jnjvm* vm = thread->getJVM();
   vm->argumentsInfo.readArgs(vm);
   if (vm->argumentsInfo.className == NULL) {
-    vm->threadSystem.nonDaemonThreads = 0;
+    vm->threadSystem.leave();
     return;
   }
+
   int pos = vm->argumentsInfo.appArgumentsPos;  
   vm->argumentsInfo.argv = vm->argumentsInfo.argv + pos - 1;
   vm->argumentsInfo.argc = vm->argumentsInfo.argc - pos + 1;
@@ -1298,11 +1299,20 @@
 
     vm->executeClass(info.className, args);
   }
-  vm->threadSystem.nonDaemonLock.lock();
-  --(vm->threadSystem.nonDaemonThreads);
-  if (vm->threadSystem.nonDaemonThreads == 0)
-      vm->threadSystem.nonDaemonVar.signal();
-  vm->threadSystem.nonDaemonLock.unlock();  
+  vm->threadSystem.leave();
+}
+
+void ThreadSystem::leave() {
+  nonDaemonLock.lock();
+  --nonDaemonThreads;
+  if (nonDaemonThreads == 0) nonDaemonVar.signal();
+  nonDaemonLock.unlock();  
+}
+
+void ThreadSystem::enter() {
+  nonDaemonLock.lock();
+  ++nonDaemonThreads;
+  nonDaemonLock.unlock();  
 }
 
 #ifdef SERVICE

Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.h?rev=105911&r1=105910&r2=105911&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.h Sun Jun 13 03:02:36 2010
@@ -79,6 +79,14 @@
   ///
   ~ThreadSystem() {}
 
+  /// leave - A thread calls this function when it leaves the thread system.
+  ///
+  void leave();
+
+  /// enter - A thread calls this function when it enters the thread system.
+  ///
+  void enter();
+
 };
 
 class ClArgumentsInfo {





More information about the vmkit-commits mailing list