< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page




1596 // Note: JDK1.1 and before had a privateInfo_offset field which was used for the
1597 //       platform thread structure, and a eetop offset which was used for thread
1598 //       local storage (and unused by the HotSpot VM). In JDK1.2 the two structures
1599 //       merged, so in the HotSpot VM we just use the eetop field for the thread
1600 //       instead of the privateInfo_offset.
1601 //
1602 // Note: The stackSize field is only present starting in 1.4.
1603 
1604 int java_lang_Thread::_name_offset = 0;
1605 int java_lang_Thread::_group_offset = 0;
1606 int java_lang_Thread::_contextClassLoader_offset = 0;
1607 int java_lang_Thread::_inheritedAccessControlContext_offset = 0;
1608 int java_lang_Thread::_priority_offset = 0;
1609 int java_lang_Thread::_eetop_offset = 0;
1610 int java_lang_Thread::_daemon_offset = 0;
1611 int java_lang_Thread::_stillborn_offset = 0;
1612 int java_lang_Thread::_stackSize_offset = 0;
1613 int java_lang_Thread::_tid_offset = 0;
1614 int java_lang_Thread::_thread_status_offset = 0;
1615 int java_lang_Thread::_park_blocker_offset = 0;
1616 int java_lang_Thread::_park_event_offset = 0 ;
1617 
1618 #define THREAD_FIELDS_DO(macro) \
1619   macro(_name_offset,          k, vmSymbols::name_name(), string_signature, false); \
1620   macro(_group_offset,         k, vmSymbols::group_name(), threadgroup_signature, false); \
1621   macro(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), classloader_signature, false); \
1622   macro(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), accesscontrolcontext_signature, false); \
1623   macro(_priority_offset,      k, vmSymbols::priority_name(), int_signature, false); \
1624   macro(_daemon_offset,        k, vmSymbols::daemon_name(), bool_signature, false); \
1625   macro(_eetop_offset,         k, "eetop", long_signature, false); \
1626   macro(_stillborn_offset,     k, "stillborn", bool_signature, false); \
1627   macro(_stackSize_offset,     k, "stackSize", long_signature, false); \
1628   macro(_tid_offset,           k, "tid", long_signature, false); \
1629   macro(_thread_status_offset, k, "threadStatus", int_signature, false); \
1630   macro(_park_blocker_offset,  k, "parkBlocker", object_signature, false); \
1631   macro(_park_event_offset,    k, "nativeParkEventPointer", long_signature, false)
1632 
1633 void java_lang_Thread::compute_offsets() {
1634   assert(_group_offset == 0, "offsets should be initialized only once");
1635 
1636   InstanceKlass* k = SystemDictionary::Thread_klass();
1637   THREAD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
1638 }
1639 
1640 #if INCLUDE_CDS
1641 void java_lang_Thread::serialize_offsets(SerializeClosure* f) {
1642   THREAD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
1643 }
1644 #endif
1645 
1646 JavaThread* java_lang_Thread::thread(oop java_thread) {
1647   return (JavaThread*)java_thread->address_field(_eetop_offset);
1648 }
1649 
1650 
1651 void java_lang_Thread::set_thread(oop java_thread, JavaThread* thread) {


1726 // Read thread status value from threadStatus field in java.lang.Thread java class.
1727 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
1728   // Make sure the caller is operating on behalf of the VM or is
1729   // running VM code (state == _thread_in_vm).
1730   assert(Threads_lock->owned_by_self() || Thread::current()->is_VM_thread() ||
1731          JavaThread::current()->thread_state() == _thread_in_vm,
1732          "Java Thread is not running in vm");
1733   return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
1734 }
1735 
1736 
1737 jlong java_lang_Thread::thread_id(oop java_thread) {
1738   return java_thread->long_field(_tid_offset);
1739 }
1740 
1741 oop java_lang_Thread::park_blocker(oop java_thread) {
1742   assert(JDK_Version::current().supports_thread_park_blocker(),
1743          "Must support parkBlocker field");
1744 
1745   return java_thread->obj_field(_park_blocker_offset);
1746 }
1747 
1748 jlong java_lang_Thread::park_event(oop java_thread) {
1749   return java_thread->long_field(_park_event_offset);
1750 }
1751 
1752 bool java_lang_Thread::set_park_event(oop java_thread, jlong ptr) {
1753   java_thread->long_field_put(_park_event_offset, ptr);
1754   return true;
1755 }
1756 
1757 const char* java_lang_Thread::thread_status_name(oop java_thread) {
1758   ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
1759   switch (status) {
1760     case NEW                      : return "NEW";
1761     case RUNNABLE                 : return "RUNNABLE";
1762     case SLEEPING                 : return "TIMED_WAITING (sleeping)";
1763     case IN_OBJECT_WAIT           : return "WAITING (on object monitor)";
1764     case IN_OBJECT_WAIT_TIMED     : return "TIMED_WAITING (on object monitor)";
1765     case PARKED                   : return "WAITING (parking)";
1766     case PARKED_TIMED             : return "TIMED_WAITING (parking)";
1767     case BLOCKED_ON_MONITOR_ENTER : return "BLOCKED (on object monitor)";
1768     case TERMINATED               : return "TERMINATED";
1769     default                       : return "UNKNOWN";
1770   };
1771 }
1772 int java_lang_ThreadGroup::_parent_offset = 0;
1773 int java_lang_ThreadGroup::_name_offset = 0;
1774 int java_lang_ThreadGroup::_threads_offset = 0;




1596 // Note: JDK1.1 and before had a privateInfo_offset field which was used for the
1597 //       platform thread structure, and a eetop offset which was used for thread
1598 //       local storage (and unused by the HotSpot VM). In JDK1.2 the two structures
1599 //       merged, so in the HotSpot VM we just use the eetop field for the thread
1600 //       instead of the privateInfo_offset.
1601 //
1602 // Note: The stackSize field is only present starting in 1.4.
1603 
1604 int java_lang_Thread::_name_offset = 0;
1605 int java_lang_Thread::_group_offset = 0;
1606 int java_lang_Thread::_contextClassLoader_offset = 0;
1607 int java_lang_Thread::_inheritedAccessControlContext_offset = 0;
1608 int java_lang_Thread::_priority_offset = 0;
1609 int java_lang_Thread::_eetop_offset = 0;
1610 int java_lang_Thread::_daemon_offset = 0;
1611 int java_lang_Thread::_stillborn_offset = 0;
1612 int java_lang_Thread::_stackSize_offset = 0;
1613 int java_lang_Thread::_tid_offset = 0;
1614 int java_lang_Thread::_thread_status_offset = 0;
1615 int java_lang_Thread::_park_blocker_offset = 0;

1616 
1617 #define THREAD_FIELDS_DO(macro) \
1618   macro(_name_offset,          k, vmSymbols::name_name(), string_signature, false); \
1619   macro(_group_offset,         k, vmSymbols::group_name(), threadgroup_signature, false); \
1620   macro(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), classloader_signature, false); \
1621   macro(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), accesscontrolcontext_signature, false); \
1622   macro(_priority_offset,      k, vmSymbols::priority_name(), int_signature, false); \
1623   macro(_daemon_offset,        k, vmSymbols::daemon_name(), bool_signature, false); \
1624   macro(_eetop_offset,         k, "eetop", long_signature, false); \
1625   macro(_stillborn_offset,     k, "stillborn", bool_signature, false); \
1626   macro(_stackSize_offset,     k, "stackSize", long_signature, false); \
1627   macro(_tid_offset,           k, "tid", long_signature, false); \
1628   macro(_thread_status_offset, k, "threadStatus", int_signature, false); \
1629   macro(_park_blocker_offset,  k, "parkBlocker", object_signature, false);

1630 
1631 void java_lang_Thread::compute_offsets() {
1632   assert(_group_offset == 0, "offsets should be initialized only once");
1633 
1634   InstanceKlass* k = SystemDictionary::Thread_klass();
1635   THREAD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
1636 }
1637 
1638 #if INCLUDE_CDS
1639 void java_lang_Thread::serialize_offsets(SerializeClosure* f) {
1640   THREAD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
1641 }
1642 #endif
1643 
1644 JavaThread* java_lang_Thread::thread(oop java_thread) {
1645   return (JavaThread*)java_thread->address_field(_eetop_offset);
1646 }
1647 
1648 
1649 void java_lang_Thread::set_thread(oop java_thread, JavaThread* thread) {


1724 // Read thread status value from threadStatus field in java.lang.Thread java class.
1725 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
1726   // Make sure the caller is operating on behalf of the VM or is
1727   // running VM code (state == _thread_in_vm).
1728   assert(Threads_lock->owned_by_self() || Thread::current()->is_VM_thread() ||
1729          JavaThread::current()->thread_state() == _thread_in_vm,
1730          "Java Thread is not running in vm");
1731   return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
1732 }
1733 
1734 
1735 jlong java_lang_Thread::thread_id(oop java_thread) {
1736   return java_thread->long_field(_tid_offset);
1737 }
1738 
1739 oop java_lang_Thread::park_blocker(oop java_thread) {
1740   assert(JDK_Version::current().supports_thread_park_blocker(),
1741          "Must support parkBlocker field");
1742 
1743   return java_thread->obj_field(_park_blocker_offset);









1744 }
1745 
1746 const char* java_lang_Thread::thread_status_name(oop java_thread) {
1747   ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
1748   switch (status) {
1749     case NEW                      : return "NEW";
1750     case RUNNABLE                 : return "RUNNABLE";
1751     case SLEEPING                 : return "TIMED_WAITING (sleeping)";
1752     case IN_OBJECT_WAIT           : return "WAITING (on object monitor)";
1753     case IN_OBJECT_WAIT_TIMED     : return "TIMED_WAITING (on object monitor)";
1754     case PARKED                   : return "WAITING (parking)";
1755     case PARKED_TIMED             : return "TIMED_WAITING (parking)";
1756     case BLOCKED_ON_MONITOR_ENTER : return "BLOCKED (on object monitor)";
1757     case TERMINATED               : return "TERMINATED";
1758     default                       : return "UNKNOWN";
1759   };
1760 }
1761 int java_lang_ThreadGroup::_parent_offset = 0;
1762 int java_lang_ThreadGroup::_name_offset = 0;
1763 int java_lang_ThreadGroup::_threads_offset = 0;


< prev index next >