< prev index next >

src/share/vm/classfile/javaClasses.cpp

Print this page
rev 8911 : [jfr] enable thread sampling


1030   // The stackSize field is only present starting in 1.4
1031   if (_stackSize_offset > 0) {
1032     assert(JDK_Version::is_gte_jdk14x_version(), "sanity check");
1033     return java_thread->long_field(_stackSize_offset);
1034   } else {
1035     return 0;
1036   }
1037 }
1038 
1039 // Write the thread status value to threadStatus field in java.lang.Thread java class.
1040 void java_lang_Thread::set_thread_status(oop java_thread,
1041                                          java_lang_Thread::ThreadStatus status) {
1042   // The threadStatus is only present starting in 1.5
1043   if (_thread_status_offset > 0) {
1044     java_thread->int_field_put(_thread_status_offset, status);
1045   }
1046 }
1047 
1048 // Read thread status value from threadStatus field in java.lang.Thread java class.
1049 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
1050   assert(Thread::current()->is_Watcher_thread() || Thread::current()->is_VM_thread() ||



1051          JavaThread::current()->thread_state() == _thread_in_vm,
1052          "Java Thread is not running in vm");
1053   // The threadStatus is only present starting in 1.5
1054   if (_thread_status_offset > 0) {
1055     return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
1056   } else {
1057     // All we can easily figure out is if it is alive, but that is
1058     // enough info for a valid unknown status.
1059     // These aren't restricted to valid set ThreadStatus values, so
1060     // use JVMTI values and cast.
1061     JavaThread* thr = java_lang_Thread::thread(java_thread);
1062     if (thr == NULL) {
1063       // the thread hasn't run yet or is in the process of exiting
1064       return NEW;
1065     }
1066     return (java_lang_Thread::ThreadStatus)JVMTI_THREAD_STATE_ALIVE;
1067   }
1068 }
1069 
1070 




1030   // The stackSize field is only present starting in 1.4
1031   if (_stackSize_offset > 0) {
1032     assert(JDK_Version::is_gte_jdk14x_version(), "sanity check");
1033     return java_thread->long_field(_stackSize_offset);
1034   } else {
1035     return 0;
1036   }
1037 }
1038 
1039 // Write the thread status value to threadStatus field in java.lang.Thread java class.
1040 void java_lang_Thread::set_thread_status(oop java_thread,
1041                                          java_lang_Thread::ThreadStatus status) {
1042   // The threadStatus is only present starting in 1.5
1043   if (_thread_status_offset > 0) {
1044     java_thread->int_field_put(_thread_status_offset, status);
1045   }
1046 }
1047 
1048 // Read thread status value from threadStatus field in java.lang.Thread java class.
1049 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
1050   // Make sure the caller is operating on behalf of the VM or is
1051   // running VM code (state == _thread_in_vm).
1052   assert(Threads_lock->owned_by_self() || Thread::current()->is_Watcher_thread() ||
1053          Thread::current()->is_VM_thread() ||
1054          JavaThread::current()->thread_state() == _thread_in_vm,
1055          "Java Thread is not running in vm");
1056   // The threadStatus is only present starting in 1.5
1057   if (_thread_status_offset > 0) {
1058     return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
1059   } else {
1060     // All we can easily figure out is if it is alive, but that is
1061     // enough info for a valid unknown status.
1062     // These aren't restricted to valid set ThreadStatus values, so
1063     // use JVMTI values and cast.
1064     JavaThread* thr = java_lang_Thread::thread(java_thread);
1065     if (thr == NULL) {
1066       // the thread hasn't run yet or is in the process of exiting
1067       return NEW;
1068     }
1069     return (java_lang_Thread::ThreadStatus)JVMTI_THREAD_STATE_ALIVE;
1070   }
1071 }
1072 
1073 


< prev index next >