[vmkit-commits] [vmkit] r180348 - Fix threading bug in GNU ClassPath and OpenJDK interface code.

Peter Senna Tschudin peter.senna at gmail.com
Thu Apr 25 10:01:40 PDT 2013


Author: peter.senna
Date: Thu Apr 25 12:00:08 2013
New Revision: 180348

URL: http://llvm.org/viewvc/llvm-project?rev=180348&view=rev
Log:
Fix threading bug in GNU ClassPath and OpenJDK interface code.
(cherry picked from commit 766fa9d10356bac3c30555f75dfb75606122de55)

Modified:
    vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathVMThread.inc
    vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc

Modified: vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathVMThread.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathVMThread.inc?rev=180348&r1=180347&r2=180348&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathVMThread.inc (original)
+++ vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathVMThread.inc Thu Apr 25 12:00:08 2013
@@ -56,13 +56,6 @@ void start(JavaThread* thread) {
   
   javaThread = thread->javaThread;
   assert(javaThread && "Didn't fix the javaThread of a j3 thread");
-  // If the thread is not a daemon, it is added to the list of threads to
-  // wait until exit.
-  bool isDaemon = vm->upcalls->daemon->getInstanceInt8Field(javaThread);
-
-  if (!isDaemon) {
-    vm->threadSystem.enter();
-  }
  
   assert(vmThread->getVirtualTable());
   assert(javaThread->getVirtualTable());
@@ -70,6 +63,7 @@ void start(JavaThread* thread) {
   vm->upcalls->runVMThread->invokeIntSpecial(vm, vmthClass, vmThread);
  
   // Remove the thread from the list.
+  bool isDaemon = vm->upcalls->daemon->getInstanceInt8Field(javaThread);
   if (!isDaemon) {
     vm->threadSystem.leave();
   }
@@ -95,6 +89,15 @@ JavaObject* vmThread, sint64 stackSize)
  
   JavaThread* th = new JavaThread(vm);
   if (!th) vm->outOfMemoryError();
+
+  // If the thread is not a daemon, it is added to the list of threads to
+  // wait until exit.
+  bool isDaemon = vm->upcalls->daemon->getInstanceInt8Field(javaThread);
+
+  if (!isDaemon) {
+    vm->threadSystem.enter();
+  }
+
   th->start((void (*)(vmkit::Thread*))start);
   // Now that the thread has been created, initialise its object fields.
   th->initialise(javaThread, vmThread);

Modified: vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc?rev=180348&r1=180347&r2=180348&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc (original)
+++ vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc Thu Apr 25 12:00:08 2013
@@ -535,14 +535,6 @@ void start(JavaThread* thread) {
   javaThread = thread->javaThread;
   assert(javaThread && "Didn't fix the javaThread of a j3 thread");
 
-  // If the thread is not a daemon, it is added to the list of threads to
-  // wait until exit.
-  bool isDaemon = vm->upcalls->daemon->getInstanceInt8Field(javaThread);
-
-  if (!isDaemon) {
-    vm->threadSystem.enter();
-  }
-
   assert(javaThread->getVirtualTable());
 
   // Get the class for this Thread
@@ -592,6 +584,7 @@ void start(JavaThread* thread) {
   JavaObject::release(javaThread);
 
   // Remove the thread from the list.
+  bool isDaemon = vm->upcalls->daemon->getInstanceInt8Field(javaThread);
   if (!isDaemon) {
     vm->threadSystem.leave();
   }
@@ -626,6 +619,14 @@ JVM_StartThread(JNIEnv *env, jobject _th
   // Set the eetop field
   vm->upcalls->eetop->setInstanceLongField(thread, (long)newTh);
 
+  // If the thread is not a daemon, it is added to the list of threads to
+  // wait until exit.
+  bool isDaemon = vm->upcalls->daemon->getInstanceInt8Field(javaThread);
+
+  if (!isDaemon) {
+    vm->threadSystem.enter();
+  }
+
   newTh->start((void (*)(vmkit::Thread*))start);
 
   newTh->initialise(thread, sleepObject);





More information about the vmkit-commits mailing list