< prev index next >

src/hotspot/share/prims/unsafe.cpp

Print this page




 932       if (isAbsolute != 0) {
 933         post_thread_park_event(&event, obj, min_jlong, time);
 934       } else {
 935         post_thread_park_event(&event, obj, time, min_jlong);
 936       }
 937     }
 938   }
 939   HOTSPOT_THREAD_PARK_END((uintptr_t) thread->parker());
 940 } UNSAFE_END
 941 
 942 UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread)) {
 943   Parker* p = NULL;
 944 
 945   if (jthread != NULL) {
 946     ThreadsListHandle tlh;
 947     JavaThread* thr = NULL;
 948     oop java_thread = NULL;
 949     (void) tlh.cv_internal_thread_to_JavaThread(jthread, &thr, &java_thread);
 950     if (java_thread != NULL) {
 951       // This is a valid oop.
 952       jlong lp = java_lang_Thread::park_event(java_thread);
 953       if (lp != 0) {
 954         // This cast is OK even though the jlong might have been read
 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       }
 970     }
 971   } // ThreadsListHandle is destroyed here.
 972 



 973   if (p != NULL) {
 974     HOTSPOT_THREAD_UNPARK((uintptr_t) p);
 975     p->unpark();
 976   }
 977 } UNSAFE_END
 978 
 979 UNSAFE_ENTRY(jint, Unsafe_GetLoadAverage0(JNIEnv *env, jobject unsafe, jdoubleArray loadavg, jint nelem)) {
 980   const int max_nelem = 3;
 981   double la[max_nelem];
 982   jint ret;
 983 
 984   typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(loadavg));
 985   assert(a->is_typeArray(), "must be type array");
 986 
 987   ret = os::loadavg(la, nelem);
 988   if (ret == -1) {
 989     return -1;
 990   }
 991 
 992   // if successful, ret is the number of samples actually retrieved.




 932       if (isAbsolute != 0) {
 933         post_thread_park_event(&event, obj, min_jlong, time);
 934       } else {
 935         post_thread_park_event(&event, obj, time, min_jlong);
 936       }
 937     }
 938   }
 939   HOTSPOT_THREAD_PARK_END((uintptr_t) thread->parker());
 940 } UNSAFE_END
 941 
 942 UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread)) {
 943   Parker* p = NULL;
 944 
 945   if (jthread != NULL) {
 946     ThreadsListHandle tlh;
 947     JavaThread* thr = NULL;
 948     oop java_thread = NULL;
 949     (void) tlh.cv_internal_thread_to_JavaThread(jthread, &thr, &java_thread);
 950     if (java_thread != NULL) {
 951       // This is a valid oop.









 952       if (thr != NULL) {
 953         // The JavaThread is alive.
 954         p = thr->parker();





 955       }
 956     }
 957   } // ThreadsListHandle is destroyed here.
 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.
 962   if (p != NULL) {
 963     HOTSPOT_THREAD_UNPARK((uintptr_t) p);
 964     p->unpark();
 965   }
 966 } UNSAFE_END
 967 
 968 UNSAFE_ENTRY(jint, Unsafe_GetLoadAverage0(JNIEnv *env, jobject unsafe, jdoubleArray loadavg, jint nelem)) {
 969   const int max_nelem = 3;
 970   double la[max_nelem];
 971   jint ret;
 972 
 973   typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(loadavg));
 974   assert(a->is_typeArray(), "must be type array");
 975 
 976   ret = os::loadavg(la, nelem);
 977   if (ret == -1) {
 978     return -1;
 979   }
 980 
 981   // if successful, ret is the number of samples actually retrieved.


< prev index next >