[vmkit-commits] [vmkit] r145503 - in /vmkit/trunk: lib/j3/ClassLib/OpenJDK/OpenJDK.inc tests/FieldWriteTest.java

Will Dietz wdietz2 at illinois.edu
Wed Nov 30 10:17:26 PST 2011


Author: wdietz2
Date: Wed Nov 30 12:17:26 2011
New Revision: 145503

URL: http://llvm.org/viewvc/llvm-project?rev=145503&view=rev
Log:
OpenJDK: Fix race in 'vmThread' field setting.  Fixes FieldWriteTest.

This is particularly important since this field being set properly is how we
determine whether or not a given Thread is alive.

Also, touchup the FieldWriteTest to make it easier to debug.

Now passes mauve's Thread.join test.

Modified:
    vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc
    vmkit/trunk/tests/FieldWriteTest.java

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=145503&r1=145502&r2=145503&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc (original)
+++ vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc Wed Nov 30 12:17:26 2011
@@ -516,10 +516,6 @@
   javaThread = thread->javaThread;
   assert(javaThread && "Didn't fix the javaThread of a j3 thread");
 
-  // Ok, now that the thread is created we can set the the value of eetop
-  // which points from the javaobject to our internal JavaThread
-  vm->upcalls->eetop->setInstanceLongField(javaThread, (long)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);
@@ -583,6 +579,10 @@
 
   JavaThread * newTh = new JavaThread(vm);
   if (!newTh) vm->outOfMemoryError();
+
+  // Set the eetop field
+  vm->upcalls->eetop->setInstanceLongField(thread, (long)newTh);
+
   newTh->start((void (*)(vmkit::Thread*))start);
 
   newTh->initialise(thread, sleepObject);

Modified: vmkit/trunk/tests/FieldWriteTest.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tests/FieldWriteTest.java?rev=145503&r1=145502&r2=145503&view=diff
==============================================================================
--- vmkit/trunk/tests/FieldWriteTest.java (original)
+++ vmkit/trunk/tests/FieldWriteTest.java Wed Nov 30 12:17:26 2011
@@ -16,16 +16,13 @@
   }
 
   public static void main(String[] args) throws Exception {
-    // First time passes, the rest fail.
-    int fail = 0;
     for (int i = 0; i < 100; ++i) {
       FieldWriterThread t = new FieldWriterThread();
       t.start();
+      check(t.isAlive());
       t.join(); // Synchronization point!
-      if (!t.val) ++fail;
+      check(!t.isAlive());
+      check(t.val);
     }
-    if (fail > 0)
-      System.out.println("Failed checks: " + fail);
-    check(fail == 0);
   }
 }





More information about the vmkit-commits mailing list