src/share/vm/classfile/javaClasses.cpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>


 944   // The stackSize field is only present starting in 1.4
 945   if (_stackSize_offset > 0) {
 946     assert(JDK_Version::is_gte_jdk14x_version(), "sanity check");
 947     return java_thread->long_field(_stackSize_offset);
 948   } else {
 949     return 0;
 950   }
 951 }
 952 
 953 // Write the thread status value to threadStatus field in java.lang.Thread java class.
 954 void java_lang_Thread::set_thread_status(oop java_thread,
 955                                          java_lang_Thread::ThreadStatus status) {
 956   // The threadStatus is only present starting in 1.5
 957   if (_thread_status_offset > 0) {
 958     java_thread->int_field_put(_thread_status_offset, status);
 959   }
 960 }
 961 
 962 // Read thread status value from threadStatus field in java.lang.Thread java class.
 963 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
 964   assert(Thread::current()->is_VM_thread() ||
 965          JavaThread::current()->thread_state() == _thread_in_vm,
 966          "Java Thread is not running in vm");
 967   // The threadStatus is only present starting in 1.5
 968   if (_thread_status_offset > 0) {
 969     return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
 970   } else {
 971     // All we can easily figure out is if it is alive, but that is
 972     // enough info for a valid unknown status.
 973     // These aren't restricted to valid set ThreadStatus values, so
 974     // use JVMTI values and cast.
 975     JavaThread* thr = java_lang_Thread::thread(java_thread);
 976     if (thr == NULL) {
 977       // the thread hasn't run yet or is in the process of exiting
 978       return NEW;
 979     }
 980     return (java_lang_Thread::ThreadStatus)JVMTI_THREAD_STATE_ALIVE;
 981   }
 982 }
 983 
 984 




 944   // The stackSize field is only present starting in 1.4
 945   if (_stackSize_offset > 0) {
 946     assert(JDK_Version::is_gte_jdk14x_version(), "sanity check");
 947     return java_thread->long_field(_stackSize_offset);
 948   } else {
 949     return 0;
 950   }
 951 }
 952 
 953 // Write the thread status value to threadStatus field in java.lang.Thread java class.
 954 void java_lang_Thread::set_thread_status(oop java_thread,
 955                                          java_lang_Thread::ThreadStatus status) {
 956   // The threadStatus is only present starting in 1.5
 957   if (_thread_status_offset > 0) {
 958     java_thread->int_field_put(_thread_status_offset, status);
 959   }
 960 }
 961 
 962 // Read thread status value from threadStatus field in java.lang.Thread java class.
 963 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
 964   assert(Thread::current()->is_Watcher_thread() || Thread::current()->is_VM_thread() ||
 965          JavaThread::current()->thread_state() == _thread_in_vm,
 966          "Java Thread is not running in vm");
 967   // The threadStatus is only present starting in 1.5
 968   if (_thread_status_offset > 0) {
 969     return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
 970   } else {
 971     // All we can easily figure out is if it is alive, but that is
 972     // enough info for a valid unknown status.
 973     // These aren't restricted to valid set ThreadStatus values, so
 974     // use JVMTI values and cast.
 975     JavaThread* thr = java_lang_Thread::thread(java_thread);
 976     if (thr == NULL) {
 977       // the thread hasn't run yet or is in the process of exiting
 978       return NEW;
 979     }
 980     return (java_lang_Thread::ThreadStatus)JVMTI_THREAD_STATE_ALIVE;
 981   }
 982 }
 983 
 984