src/hotspot/share/classfile/javaClasses.cpp
changeset 54563 ba8ab3f67aec
parent 54511 fbfcebad8e66
child 54629 9ebb614d293d
equal deleted inserted replaced
54562:1af5c0e68381 54563:ba8ab3f67aec
  1712   return java_thread->obj_field(_inheritedAccessControlContext_offset);
  1712   return java_thread->obj_field(_inheritedAccessControlContext_offset);
  1713 }
  1713 }
  1714 
  1714 
  1715 
  1715 
  1716 jlong java_lang_Thread::stackSize(oop java_thread) {
  1716 jlong java_lang_Thread::stackSize(oop java_thread) {
  1717   if (_stackSize_offset > 0) {
  1717   return java_thread->long_field(_stackSize_offset);
  1718     return java_thread->long_field(_stackSize_offset);
       
  1719   } else {
       
  1720     return 0;
       
  1721   }
       
  1722 }
  1718 }
  1723 
  1719 
  1724 // Write the thread status value to threadStatus field in java.lang.Thread java class.
  1720 // Write the thread status value to threadStatus field in java.lang.Thread java class.
  1725 void java_lang_Thread::set_thread_status(oop java_thread,
  1721 void java_lang_Thread::set_thread_status(oop java_thread,
  1726                                          java_lang_Thread::ThreadStatus status) {
  1722                                          java_lang_Thread::ThreadStatus status) {
  1727   // The threadStatus is only present starting in 1.5
  1723   java_thread->int_field_put(_thread_status_offset, status);
  1728   if (_thread_status_offset > 0) {
       
  1729     java_thread->int_field_put(_thread_status_offset, status);
       
  1730   }
       
  1731 }
  1724 }
  1732 
  1725 
  1733 // Read thread status value from threadStatus field in java.lang.Thread java class.
  1726 // Read thread status value from threadStatus field in java.lang.Thread java class.
  1734 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
  1727 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
  1735   // Make sure the caller is operating on behalf of the VM or is
  1728   // Make sure the caller is operating on behalf of the VM or is
  1736   // running VM code (state == _thread_in_vm).
  1729   // running VM code (state == _thread_in_vm).
  1737   assert(Threads_lock->owned_by_self() || Thread::current()->is_VM_thread() ||
  1730   assert(Threads_lock->owned_by_self() || Thread::current()->is_VM_thread() ||
  1738          JavaThread::current()->thread_state() == _thread_in_vm,
  1731          JavaThread::current()->thread_state() == _thread_in_vm,
  1739          "Java Thread is not running in vm");
  1732          "Java Thread is not running in vm");
  1740   // The threadStatus is only present starting in 1.5
  1733   return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
  1741   if (_thread_status_offset > 0) {
       
  1742     return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
       
  1743   } else {
       
  1744     // All we can easily figure out is if it is alive, but that is
       
  1745     // enough info for a valid unknown status.
       
  1746     // These aren't restricted to valid set ThreadStatus values, so
       
  1747     // use JVMTI values and cast.
       
  1748     JavaThread* thr = java_lang_Thread::thread(java_thread);
       
  1749     if (thr == NULL) {
       
  1750       // the thread hasn't run yet or is in the process of exiting
       
  1751       return NEW;
       
  1752     }
       
  1753     return (java_lang_Thread::ThreadStatus)JVMTI_THREAD_STATE_ALIVE;
       
  1754   }
       
  1755 }
  1734 }
  1756 
  1735 
  1757 
  1736 
  1758 jlong java_lang_Thread::thread_id(oop java_thread) {
  1737 jlong java_lang_Thread::thread_id(oop java_thread) {
  1759   // The thread ID field is only present starting in 1.5
  1738   return java_thread->long_field(_tid_offset);
  1760   if (_tid_offset > 0) {
       
  1761     return java_thread->long_field(_tid_offset);
       
  1762   } else {
       
  1763     return 0;
       
  1764   }
       
  1765 }
  1739 }
  1766 
  1740 
  1767 oop java_lang_Thread::park_blocker(oop java_thread) {
  1741 oop java_lang_Thread::park_blocker(oop java_thread) {
  1768   assert(JDK_Version::current().supports_thread_park_blocker() &&
  1742   assert(JDK_Version::current().supports_thread_park_blocker(),
  1769          _park_blocker_offset != 0, "Must support parkBlocker field");
  1743          "Must support parkBlocker field");
  1770 
  1744 
  1771   if (_park_blocker_offset > 0) {
  1745   return java_thread->obj_field(_park_blocker_offset);
  1772     return java_thread->obj_field(_park_blocker_offset);
       
  1773   }
       
  1774 
       
  1775   return NULL;
       
  1776 }
  1746 }
  1777 
  1747 
  1778 jlong java_lang_Thread::park_event(oop java_thread) {
  1748 jlong java_lang_Thread::park_event(oop java_thread) {
  1779   if (_park_event_offset > 0) {
  1749   return java_thread->long_field(_park_event_offset);
  1780     return java_thread->long_field(_park_event_offset);
       
  1781   }
       
  1782   return 0;
       
  1783 }
  1750 }
  1784 
  1751 
  1785 bool java_lang_Thread::set_park_event(oop java_thread, jlong ptr) {
  1752 bool java_lang_Thread::set_park_event(oop java_thread, jlong ptr) {
  1786   if (_park_event_offset > 0) {
  1753   java_thread->long_field_put(_park_event_offset, ptr);
  1787     java_thread->long_field_put(_park_event_offset, ptr);
  1754   return true;
  1788     return true;
  1755 }
  1789   }
       
  1790   return false;
       
  1791 }
       
  1792 
       
  1793 
  1756 
  1794 const char* java_lang_Thread::thread_status_name(oop java_thread) {
  1757 const char* java_lang_Thread::thread_status_name(oop java_thread) {
  1795   assert(_thread_status_offset != 0, "Must have thread status");
       
  1796   ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
  1758   ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
  1797   switch (status) {
  1759   switch (status) {
  1798     case NEW                      : return "NEW";
  1760     case NEW                      : return "NEW";
  1799     case RUNNABLE                 : return "RUNNABLE";
  1761     case RUNNABLE                 : return "RUNNABLE";
  1800     case SLEEPING                 : return "TIMED_WAITING (sleeping)";
  1762     case SLEEPING                 : return "TIMED_WAITING (sleeping)";