src/hotspot/os/posix/os_posix.cpp
changeset 58095 adc72cd1d1f2
parent 57998 849acc346a1d
child 58196 cea6839598e8
--- a/src/hotspot/os/posix/os_posix.cpp	Thu Sep 12 03:21:11 2019 +0200
+++ b/src/hotspot/os/posix/os_posix.cpp	Wed Sep 11 22:09:05 2019 -0400
@@ -645,7 +645,8 @@
 
 void os::interrupt(Thread* thread) {
   debug_only(Thread::check_for_dangling_thread_pointer(thread);)
-
+  assert(thread->is_Java_thread(), "invariant");
+  JavaThread* jt = (JavaThread*) thread;
   OSThread* osthread = thread->osthread();
 
   if (!osthread->interrupted()) {
@@ -654,13 +655,12 @@
     // resulting in multiple notifications.  We do, however, want the store
     // to interrupted() to be visible to other threads before we execute unpark().
     OrderAccess::fence();
-    ParkEvent * const slp = thread->_SleepEvent ;
+    ParkEvent * const slp = jt->_SleepEvent ;
     if (slp != NULL) slp->unpark() ;
   }
 
   // For JSR166. Unpark even if interrupt status already was set
-  if (thread->is_Java_thread())
-    ((JavaThread*)thread)->parker()->unpark();
+  jt->parker()->unpark();
 
   ParkEvent * ev = thread->_ParkEvent ;
   if (ev != NULL) ev->unpark() ;
@@ -682,7 +682,7 @@
   // is allowed and not harmful, and the possibility is so rare that
   // it is not worth the added complexity to add yet another lock.
   // For the sleep event an explicit reset is performed on entry
-  // to os::sleep, so there is no early return. It has also been
+  // to JavaThread::sleep, so there is no early return. It has also been
   // recommended not to put the interrupted flag into the "event"
   // structure because it hides the issue.
   if (interrupted && clear_interrupted) {
@@ -2049,7 +2049,7 @@
   // shake out uses of park() and unpark() without checking state conditions
   // properly. This spurious return doesn't manifest itself in any user code
   // but only in the correctly written condition checking loops of ObjectMonitor,
-  // Mutex/Monitor, Thread::muxAcquire and os::sleep
+  // Mutex/Monitor, Thread::muxAcquire and JavaThread::sleep
 
   if (Atomic::xchg(1, &_event) >= 0) return;