43 #include "runtime/threadHeapSampler.hpp"
44 #include "runtime/threadStatisticalInfo.hpp"
45 #include "utilities/exceptions.hpp"
46 #include "utilities/globalDefinitions.hpp"
47 #include "utilities/macros.hpp"
48 #if INCLUDE_JFR
49 #include "jfr/support/jfrThreadExtension.hpp"
50 #endif
51
52 class AsyncExceptionHandshake;
53 class ContinuationEntry;
54 class DeoptResourceMark;
55 class JNIHandleBlock;
56 class JVMCIRuntime;
57
58 class JvmtiDeferredUpdates;
59 class JvmtiSampledObjectAllocEventCollector;
60 class JvmtiThreadState;
61
62 class Metadata;
63 class OopHandleList;
64 class OopStorage;
65 class OSThread;
66
67 class ThreadsList;
68 class ThreadSafepointState;
69 class ThreadStatistics;
70
71 class vframeArray;
72 class vframe;
73 class javaVFrame;
74
75 class JavaThread;
76 typedef void (*ThreadFunction)(JavaThread*, TRAPS);
77
78 class JavaThread: public Thread {
79 friend class VMStructs;
80 friend class JVMCIVMStructs;
81 friend class WhiteBox;
82 friend class ThreadsSMRSupport; // to access _threadObj for exiting_threads_oops_do
1138
1139 private:
1140 InstanceKlass* _class_to_be_initialized;
1141
1142 // java.lang.Thread.sleep support
1143 ParkEvent * _SleepEvent;
1144 public:
1145 bool sleep(jlong millis);
1146 bool sleep_nanos(jlong nanos);
1147
1148 // java.lang.Thread interruption support
1149 void interrupt();
1150 bool is_interrupted(bool clear_interrupted);
1151
1152 // This is only for use by JVMTI RawMonitorWait. It emulates the actions of
1153 // the Java code in Object::wait which are not present in RawMonitorWait.
1154 bool get_and_clear_interrupted();
1155
1156 private:
1157 LockStack _lock_stack;
1158
1159 public:
1160 LockStack& lock_stack() { return _lock_stack; }
1161
1162 static ByteSize lock_stack_offset() { return byte_offset_of(JavaThread, _lock_stack); }
1163 // Those offsets are used in code generators to access the LockStack that is embedded in this
1164 // JavaThread structure. Those accesses are relative to the current thread, which
1165 // is typically in a dedicated register.
1166 static ByteSize lock_stack_top_offset() { return lock_stack_offset() + LockStack::top_offset(); }
1167 static ByteSize lock_stack_base_offset() { return lock_stack_offset() + LockStack::base_offset(); }
1168
1169 static OopStorage* thread_oop_storage();
1170
1171 static void verify_cross_modify_fence_failure(JavaThread *thread) PRODUCT_RETURN;
1172
1173 // Helper function to create the java.lang.Thread object for a
1174 // VM-internal thread. The thread will have the given name and be
1175 // part of the System ThreadGroup.
1176 static Handle create_system_thread_object(const char* name, TRAPS);
1177
1178 // Helper function to start a VM-internal daemon thread.
1179 // E.g. ServiceThread, NotificationThread, CompilerThread etc.
1180 static void start_internal_daemon(JavaThread* current, JavaThread* target,
1181 Handle thread_oop, ThreadPriority prio);
1182
1183 // Helper function to do vm_exit_on_initialization for osthread
1184 // resource allocation failure.
1185 static void vm_exit_on_osthread_failure(JavaThread* thread);
1186
1187 // Deferred OopHandle release support
1188 private:
|
43 #include "runtime/threadHeapSampler.hpp"
44 #include "runtime/threadStatisticalInfo.hpp"
45 #include "utilities/exceptions.hpp"
46 #include "utilities/globalDefinitions.hpp"
47 #include "utilities/macros.hpp"
48 #if INCLUDE_JFR
49 #include "jfr/support/jfrThreadExtension.hpp"
50 #endif
51
52 class AsyncExceptionHandshake;
53 class ContinuationEntry;
54 class DeoptResourceMark;
55 class JNIHandleBlock;
56 class JVMCIRuntime;
57
58 class JvmtiDeferredUpdates;
59 class JvmtiSampledObjectAllocEventCollector;
60 class JvmtiThreadState;
61
62 class Metadata;
63 class ObjectMonitor;
64 class OopHandleList;
65 class OopStorage;
66 class OSThread;
67
68 class ThreadsList;
69 class ThreadSafepointState;
70 class ThreadStatistics;
71
72 class vframeArray;
73 class vframe;
74 class javaVFrame;
75
76 class JavaThread;
77 typedef void (*ThreadFunction)(JavaThread*, TRAPS);
78
79 class JavaThread: public Thread {
80 friend class VMStructs;
81 friend class JVMCIVMStructs;
82 friend class WhiteBox;
83 friend class ThreadsSMRSupport; // to access _threadObj for exiting_threads_oops_do
1139
1140 private:
1141 InstanceKlass* _class_to_be_initialized;
1142
1143 // java.lang.Thread.sleep support
1144 ParkEvent * _SleepEvent;
1145 public:
1146 bool sleep(jlong millis);
1147 bool sleep_nanos(jlong nanos);
1148
1149 // java.lang.Thread interruption support
1150 void interrupt();
1151 bool is_interrupted(bool clear_interrupted);
1152
1153 // This is only for use by JVMTI RawMonitorWait. It emulates the actions of
1154 // the Java code in Object::wait which are not present in RawMonitorWait.
1155 bool get_and_clear_interrupted();
1156
1157 private:
1158 LockStack _lock_stack;
1159 OMCache _om_cache;
1160
1161 public:
1162 LockStack& lock_stack() { return _lock_stack; }
1163 size_t _unlocked_inflation = 0;
1164 size_t _recursive_inflation = 0;
1165 size_t _contended_recursive_inflation = 0;
1166 size_t _contended_inflation = 0;
1167 size_t _wait_inflation = 0;
1168 size_t _lock_stack_inflation = 0;
1169
1170 size_t _lock_lookup = 0;
1171 size_t _lock_hit = 0;
1172 size_t _unlock_lookup = 0;
1173 size_t _unlock_hit = 0;
1174
1175 static ByteSize lock_lookup_offset() { return byte_offset_of(JavaThread, _lock_lookup); }
1176 static ByteSize lock_hit_offset() { return byte_offset_of(JavaThread, _lock_hit); }
1177 static ByteSize unlock_lookup_offset() { return byte_offset_of(JavaThread, _unlock_lookup); }
1178 static ByteSize unlock_hit_offset() { return byte_offset_of(JavaThread, _unlock_hit); }
1179
1180 static ByteSize lock_stack_offset() { return byte_offset_of(JavaThread, _lock_stack); }
1181 // Those offsets are used in code generators to access the LockStack that is embedded in this
1182 // JavaThread structure. Those accesses are relative to the current thread, which
1183 // is typically in a dedicated register.
1184 static ByteSize lock_stack_top_offset() { return lock_stack_offset() + LockStack::top_offset(); }
1185 static ByteSize lock_stack_base_offset() { return lock_stack_offset() + LockStack::base_offset(); }
1186
1187
1188 static ByteSize om_cache_offset() { return byte_offset_of(JavaThread, _om_cache); }
1189 static ByteSize om_cache_oops_offset() { return om_cache_offset() + OMCache::entries(); }
1190
1191 void om_set_monitor_cache(ObjectMonitor* monitor);
1192 void om_clear_monitor_cache();
1193 ObjectMonitor* om_get_from_monitor_cache(oop obj);
1194
1195 static OopStorage* thread_oop_storage();
1196
1197 static void verify_cross_modify_fence_failure(JavaThread *thread) PRODUCT_RETURN;
1198
1199 // Helper function to create the java.lang.Thread object for a
1200 // VM-internal thread. The thread will have the given name and be
1201 // part of the System ThreadGroup.
1202 static Handle create_system_thread_object(const char* name, TRAPS);
1203
1204 // Helper function to start a VM-internal daemon thread.
1205 // E.g. ServiceThread, NotificationThread, CompilerThread etc.
1206 static void start_internal_daemon(JavaThread* current, JavaThread* target,
1207 Handle thread_oop, ThreadPriority prio);
1208
1209 // Helper function to do vm_exit_on_initialization for osthread
1210 // resource allocation failure.
1211 static void vm_exit_on_osthread_failure(JavaThread* thread);
1212
1213 // Deferred OopHandle release support
1214 private:
|