src/hotspot/share/prims/unsafe.cpp
changeset 54629 9ebb614d293d
parent 54439 d9b46b7de028
child 55490 3f3dc00a69a5
child 58678 9cf78a70fa4f
equal deleted inserted replaced
54628:dcb78d2f07e5 54629:9ebb614d293d
   947     JavaThread* thr = NULL;
   947     JavaThread* thr = NULL;
   948     oop java_thread = NULL;
   948     oop java_thread = NULL;
   949     (void) tlh.cv_internal_thread_to_JavaThread(jthread, &thr, &java_thread);
   949     (void) tlh.cv_internal_thread_to_JavaThread(jthread, &thr, &java_thread);
   950     if (java_thread != NULL) {
   950     if (java_thread != NULL) {
   951       // This is a valid oop.
   951       // This is a valid oop.
   952       jlong lp = java_lang_Thread::park_event(java_thread);
   952       if (thr != NULL) {
   953       if (lp != 0) {
   953         // The JavaThread is alive.
   954         // This cast is OK even though the jlong might have been read
   954         p = thr->parker();
   955         // non-atomically on 32bit systems, since there, one word will
       
   956         // always be zero anyway and the value set is always the same
       
   957         p = (Parker*)addr_from_java(lp);
       
   958       } else {
       
   959         // Not cached in the java.lang.Thread oop yet (could be an
       
   960         // older version of library).
       
   961         if (thr != NULL) {
       
   962           // The JavaThread is alive.
       
   963           p = thr->parker();
       
   964           if (p != NULL) {
       
   965             // Cache the Parker in the java.lang.Thread oop for next time.
       
   966             java_lang_Thread::set_park_event(java_thread, addr_to_java(p));
       
   967           }
       
   968         }
       
   969       }
   955       }
   970     }
   956     }
   971   } // ThreadsListHandle is destroyed here.
   957   } // ThreadsListHandle is destroyed here.
   972 
   958 
       
   959   // 'p' points to type-stable-memory if non-NULL. If the target
       
   960   // thread terminates before we get here the new user of this
       
   961   // Parker will get a 'spurious' unpark - which is perfectly valid.
   973   if (p != NULL) {
   962   if (p != NULL) {
   974     HOTSPOT_THREAD_UNPARK((uintptr_t) p);
   963     HOTSPOT_THREAD_UNPARK((uintptr_t) p);
   975     p->unpark();
   964     p->unpark();
   976   }
   965   }
   977 } UNSAFE_END
   966 } UNSAFE_END