39 #include "logging/logStream.hpp"
40 #include "memory/heapShared.inline.hpp"
41 #include "memory/metaspaceShared.hpp"
42 #include "memory/oopFactory.hpp"
43 #include "memory/resourceArea.hpp"
44 #include "memory/universe.hpp"
45 #include "oops/fieldStreams.hpp"
46 #include "oops/instanceKlass.hpp"
47 #include "oops/instanceMirrorKlass.hpp"
48 #include "oops/klass.hpp"
49 #include "oops/method.inline.hpp"
50 #include "oops/objArrayOop.inline.hpp"
51 #include "oops/oop.inline.hpp"
52 #include "oops/symbol.hpp"
53 #include "oops/typeArrayOop.inline.hpp"
54 #include "prims/jvmtiExport.hpp"
55 #include "prims/resolvedMethodTable.hpp"
56 #include "runtime/fieldDescriptor.inline.hpp"
57 #include "runtime/frame.inline.hpp"
58 #include "runtime/handles.inline.hpp"
59 #include "runtime/interfaceSupport.inline.hpp"
60 #include "runtime/java.hpp"
61 #include "runtime/javaCalls.hpp"
62 #include "runtime/jniHandles.inline.hpp"
63 #include "runtime/safepoint.hpp"
64 #include "runtime/safepointVerifiers.hpp"
65 #include "runtime/thread.inline.hpp"
66 #include "runtime/vframe.inline.hpp"
67 #include "runtime/vm_version.hpp"
68 #include "utilities/align.hpp"
69 #include "utilities/preserveException.hpp"
70 #include "utilities/utf8.hpp"
71 #if INCLUDE_JVMCI
72 #include "jvmci/jvmciJavaClasses.hpp"
73 #endif
74
75 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java) \
76 klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
77
78 #if INCLUDE_CDS
1617 }
1618
1619 the_class_mirror->int_field_put(classRedefinedCount_offset, value);
1620 }
1621
1622
1623 // Note: JDK1.1 and before had a privateInfo_offset field which was used for the
1624 // platform thread structure, and a eetop offset which was used for thread
1625 // local storage (and unused by the HotSpot VM). In JDK1.2 the two structures
1626 // merged, so in the HotSpot VM we just use the eetop field for the thread
1627 // instead of the privateInfo_offset.
1628 //
1629 // Note: The stackSize field is only present starting in 1.4.
1630
1631 int java_lang_Thread::_name_offset = 0;
1632 int java_lang_Thread::_group_offset = 0;
1633 int java_lang_Thread::_contextClassLoader_offset = 0;
1634 int java_lang_Thread::_inheritedAccessControlContext_offset = 0;
1635 int java_lang_Thread::_priority_offset = 0;
1636 int java_lang_Thread::_eetop_offset = 0;
1637 int java_lang_Thread::_daemon_offset = 0;
1638 int java_lang_Thread::_stillborn_offset = 0;
1639 int java_lang_Thread::_stackSize_offset = 0;
1640 int java_lang_Thread::_tid_offset = 0;
1641 int java_lang_Thread::_thread_status_offset = 0;
1642 int java_lang_Thread::_park_blocker_offset = 0;
1643
1644 #define THREAD_FIELDS_DO(macro) \
1645 macro(_name_offset, k, vmSymbols::name_name(), string_signature, false); \
1646 macro(_group_offset, k, vmSymbols::group_name(), threadgroup_signature, false); \
1647 macro(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), classloader_signature, false); \
1648 macro(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), accesscontrolcontext_signature, false); \
1649 macro(_priority_offset, k, vmSymbols::priority_name(), int_signature, false); \
1650 macro(_daemon_offset, k, vmSymbols::daemon_name(), bool_signature, false); \
1651 macro(_eetop_offset, k, "eetop", long_signature, false); \
1652 macro(_stillborn_offset, k, "stillborn", bool_signature, false); \
1653 macro(_stackSize_offset, k, "stackSize", long_signature, false); \
1654 macro(_tid_offset, k, "tid", long_signature, false); \
1655 macro(_thread_status_offset, k, "threadStatus", int_signature, false); \
1656 macro(_park_blocker_offset, k, "parkBlocker", object_signature, false)
1657
1658 void java_lang_Thread::compute_offsets() {
1659 assert(_group_offset == 0, "offsets should be initialized only once");
1660
1661 InstanceKlass* k = SystemDictionary::Thread_klass();
1662 THREAD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
1663 }
1664
1665 #if INCLUDE_CDS
1666 void java_lang_Thread::serialize_offsets(SerializeClosure* f) {
1667 THREAD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
1668 }
1669 #endif
1670
1671 JavaThread* java_lang_Thread::thread(oop java_thread) {
1672 return (JavaThread*)java_thread->address_field(_eetop_offset);
1673 }
1674
1675
1676 void java_lang_Thread::set_thread(oop java_thread, JavaThread* thread) {
1677 java_thread->address_field_put(_eetop_offset, (address)thread);
1678 }
1679
1680
1681 oop java_lang_Thread::name(oop java_thread) {
1682 return java_thread->obj_field(_name_offset);
1683 }
1684
1685
1686 void java_lang_Thread::set_name(oop java_thread, oop name) {
1687 java_thread->obj_field_put(_name_offset, name);
1688 }
1689
1690
1691 ThreadPriority java_lang_Thread::priority(oop java_thread) {
1692 return (ThreadPriority)java_thread->int_field(_priority_offset);
1693 }
1694
1695
1696 void java_lang_Thread::set_priority(oop java_thread, ThreadPriority priority) {
1697 java_thread->int_field_put(_priority_offset, priority);
|
39 #include "logging/logStream.hpp"
40 #include "memory/heapShared.inline.hpp"
41 #include "memory/metaspaceShared.hpp"
42 #include "memory/oopFactory.hpp"
43 #include "memory/resourceArea.hpp"
44 #include "memory/universe.hpp"
45 #include "oops/fieldStreams.hpp"
46 #include "oops/instanceKlass.hpp"
47 #include "oops/instanceMirrorKlass.hpp"
48 #include "oops/klass.hpp"
49 #include "oops/method.inline.hpp"
50 #include "oops/objArrayOop.inline.hpp"
51 #include "oops/oop.inline.hpp"
52 #include "oops/symbol.hpp"
53 #include "oops/typeArrayOop.inline.hpp"
54 #include "prims/jvmtiExport.hpp"
55 #include "prims/resolvedMethodTable.hpp"
56 #include "runtime/fieldDescriptor.inline.hpp"
57 #include "runtime/frame.inline.hpp"
58 #include "runtime/handles.inline.hpp"
59 #include "runtime/init.hpp"
60 #include "runtime/interfaceSupport.inline.hpp"
61 #include "runtime/java.hpp"
62 #include "runtime/javaCalls.hpp"
63 #include "runtime/jniHandles.inline.hpp"
64 #include "runtime/safepoint.hpp"
65 #include "runtime/safepointVerifiers.hpp"
66 #include "runtime/thread.inline.hpp"
67 #include "runtime/vframe.inline.hpp"
68 #include "runtime/vm_version.hpp"
69 #include "utilities/align.hpp"
70 #include "utilities/preserveException.hpp"
71 #include "utilities/utf8.hpp"
72 #if INCLUDE_JVMCI
73 #include "jvmci/jvmciJavaClasses.hpp"
74 #endif
75
76 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java) \
77 klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
78
79 #if INCLUDE_CDS
1618 }
1619
1620 the_class_mirror->int_field_put(classRedefinedCount_offset, value);
1621 }
1622
1623
1624 // Note: JDK1.1 and before had a privateInfo_offset field which was used for the
1625 // platform thread structure, and a eetop offset which was used for thread
1626 // local storage (and unused by the HotSpot VM). In JDK1.2 the two structures
1627 // merged, so in the HotSpot VM we just use the eetop field for the thread
1628 // instead of the privateInfo_offset.
1629 //
1630 // Note: The stackSize field is only present starting in 1.4.
1631
1632 int java_lang_Thread::_name_offset = 0;
1633 int java_lang_Thread::_group_offset = 0;
1634 int java_lang_Thread::_contextClassLoader_offset = 0;
1635 int java_lang_Thread::_inheritedAccessControlContext_offset = 0;
1636 int java_lang_Thread::_priority_offset = 0;
1637 int java_lang_Thread::_eetop_offset = 0;
1638 int java_lang_Thread::_interrupted_offset = 0;
1639 int java_lang_Thread::_daemon_offset = 0;
1640 int java_lang_Thread::_stillborn_offset = 0;
1641 int java_lang_Thread::_stackSize_offset = 0;
1642 int java_lang_Thread::_tid_offset = 0;
1643 int java_lang_Thread::_thread_status_offset = 0;
1644 int java_lang_Thread::_park_blocker_offset = 0;
1645
1646 #define THREAD_FIELDS_DO(macro) \
1647 macro(_name_offset, k, vmSymbols::name_name(), string_signature, false); \
1648 macro(_group_offset, k, vmSymbols::group_name(), threadgroup_signature, false); \
1649 macro(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), classloader_signature, false); \
1650 macro(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), accesscontrolcontext_signature, false); \
1651 macro(_priority_offset, k, vmSymbols::priority_name(), int_signature, false); \
1652 macro(_daemon_offset, k, vmSymbols::daemon_name(), bool_signature, false); \
1653 macro(_eetop_offset, k, "eetop", long_signature, false); \
1654 macro(_interrupted_offset, k, "interrupted", bool_signature, false); \
1655 macro(_stillborn_offset, k, "stillborn", bool_signature, false); \
1656 macro(_stackSize_offset, k, "stackSize", long_signature, false); \
1657 macro(_tid_offset, k, "tid", long_signature, false); \
1658 macro(_thread_status_offset, k, "threadStatus", int_signature, false); \
1659 macro(_park_blocker_offset, k, "parkBlocker", object_signature, false)
1660
1661 void java_lang_Thread::compute_offsets() {
1662 assert(_group_offset == 0, "offsets should be initialized only once");
1663
1664 InstanceKlass* k = SystemDictionary::Thread_klass();
1665 THREAD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
1666 }
1667
1668 #if INCLUDE_CDS
1669 void java_lang_Thread::serialize_offsets(SerializeClosure* f) {
1670 THREAD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
1671 }
1672 #endif
1673
1674 JavaThread* java_lang_Thread::thread(oop java_thread) {
1675 return (JavaThread*)java_thread->address_field(_eetop_offset);
1676 }
1677
1678
1679 void java_lang_Thread::set_thread(oop java_thread, JavaThread* thread) {
1680 java_thread->address_field_put(_eetop_offset, (address)thread);
1681 }
1682
1683 bool java_lang_Thread::interrupted(oop java_thread) {
1684 #if INCLUDE_JFR
1685 if (java_thread == NULL) {
1686 // can happen from Jfr::on_vm_init leading to call of JavaThread::sleep
1687 assert(!is_init_completed(), "should only happen during init");
1688 return false;
1689 }
1690 #endif
1691 return java_thread->bool_field_volatile(_interrupted_offset);
1692 }
1693
1694 void java_lang_Thread::set_interrupted(oop java_thread, bool val) {
1695 java_thread->bool_field_put_volatile(_interrupted_offset, val);
1696 }
1697
1698
1699 oop java_lang_Thread::name(oop java_thread) {
1700 return java_thread->obj_field(_name_offset);
1701 }
1702
1703
1704 void java_lang_Thread::set_name(oop java_thread, oop name) {
1705 java_thread->obj_field_put(_name_offset, name);
1706 }
1707
1708
1709 ThreadPriority java_lang_Thread::priority(oop java_thread) {
1710 return (ThreadPriority)java_thread->int_field(_priority_offset);
1711 }
1712
1713
1714 void java_lang_Thread::set_priority(oop java_thread, ThreadPriority priority) {
1715 java_thread->int_field_put(_priority_offset, priority);
|