25 #ifndef SHARE_VM_RUNTIME_THREAD_HPP
26 #define SHARE_VM_RUNTIME_THREAD_HPP
27
28 #include "memory/allocation.hpp"
29 #include "memory/threadLocalAllocBuffer.hpp"
30 #include "oops/oop.hpp"
31 #include "prims/jni.h"
32 #include "prims/jvmtiExport.hpp"
33 #include "runtime/frame.hpp"
34 #include "runtime/javaFrameAnchor.hpp"
35 #include "runtime/jniHandles.hpp"
36 #include "runtime/mutexLocker.hpp"
37 #include "runtime/os.hpp"
38 #include "runtime/osThread.hpp"
39 #include "runtime/park.hpp"
40 #include "runtime/safepoint.hpp"
41 #include "runtime/stubRoutines.hpp"
42 #include "runtime/threadLocalStorage.hpp"
43 #include "runtime/thread_ext.hpp"
44 #include "runtime/unhandledOops.hpp"
45 #include "trace/traceBackend.hpp"
46 #include "trace/traceMacros.hpp"
47 #include "utilities/exceptions.hpp"
48 #include "utilities/macros.hpp"
49 #include "utilities/top.hpp"
50 #if INCLUDE_ALL_GCS
51 #include "gc_implementation/g1/dirtyCardQueue.hpp"
52 #include "gc_implementation/g1/satbQueue.hpp"
53 #endif // INCLUDE_ALL_GCS
54 #ifdef TARGET_ARCH_zero
55 # include "stack_zero.hpp"
56 #endif
57
58 class ThreadSafepointState;
59 class ThreadProfiler;
60
61 class JvmtiThreadState;
62 class JvmtiGetLoadedClassesClosure;
63 class ThreadStatistics;
64 class ConcurrentLocksDump;
65 class ParkEvent;
66 class Parker;
67
68 class ciEnv;
69 class CompileThread;
70 class CompileLog;
71 class CompileTask;
72 class CompileQueue;
73 class CompilerCounters;
74 class vframeArray;
75
76 class DeoptResourceMark;
243 //
244 NOT_PRODUCT(int _allow_safepoint_count;) // If 0, thread allow a safepoint to happen
245 debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops.
246
247 // Used by SkipGCALot class.
248 NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot?
249
250 friend class No_Alloc_Verifier;
251 friend class No_Safepoint_Verifier;
252 friend class Pause_No_Safepoint_Verifier;
253 friend class ThreadLocalStorage;
254 friend class GC_locker;
255
256 ThreadLocalAllocBuffer _tlab; // Thread-local eden
257 jlong _allocated_bytes; // Cumulative number of bytes allocated on
258 // the Java heap
259
260 // Thread-local buffer used by MetadataOnStackMark.
261 MetadataOnStackBuffer* _metadata_on_stack_buffer;
262
263 TRACE_DATA _trace_data; // Thread-local data for tracing
264
265 ThreadExt _ext;
266
267 int _vm_operation_started_count; // VM_Operation support
268 int _vm_operation_completed_count; // VM_Operation support
269
270 ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread
271 // is waiting to lock
272 bool _current_pending_monitor_is_from_java; // locking is from Java code
273
274 // ObjectMonitor on which this thread called Object.wait()
275 ObjectMonitor* _current_waiting_monitor;
276
277 // Private thread-local objectmonitor list - a simple cache organized as a SLL.
278 public:
279 ObjectMonitor* omFreeList;
280 int omFreeCount; // length of omFreeList
281 int omFreeProvision; // reload chunk size
282 ObjectMonitor* omInUseList; // SLL to track monitors in circulation
283 int omInUseCount; // length of omInUseList
424 // Internal handle support
425 HandleArea* handle_area() const { return _handle_area; }
426 void set_handle_area(HandleArea* area) { _handle_area = area; }
427
428 GrowableArray<Metadata*>* metadata_handles() const { return _metadata_handles; }
429 void set_metadata_handles(GrowableArray<Metadata*>* handles){ _metadata_handles = handles; }
430
431 // Thread-Local Allocation Buffer (TLAB) support
432 ThreadLocalAllocBuffer& tlab() { return _tlab; }
433 void initialize_tlab() {
434 if (UseTLAB) {
435 tlab().initialize();
436 }
437 }
438
439 jlong allocated_bytes() { return _allocated_bytes; }
440 void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
441 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
442 inline jlong cooked_allocated_bytes();
443
444 TRACE_DATA* trace_data() { return &_trace_data; }
445
446 const ThreadExt& ext() const { return _ext; }
447 ThreadExt& ext() { return _ext; }
448
449 // VM operation support
450 int vm_operation_ticket() { return ++_vm_operation_started_count; }
451 int vm_operation_completed_count() { return _vm_operation_completed_count; }
452 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; }
453
454 // For tracking the heavyweight monitor the thread is pending on.
455 ObjectMonitor* current_pending_monitor() {
456 return _current_pending_monitor;
457 }
458 void set_current_pending_monitor(ObjectMonitor* monitor) {
459 _current_pending_monitor = monitor;
460 }
461 void set_current_pending_monitor_is_from_java(bool from_java) {
462 _current_pending_monitor_is_from_java = from_java;
463 }
464 bool current_pending_monitor_is_from_java() {
608
609 static ByteSize stack_base_offset() { return byte_offset_of(Thread, _stack_base ); }
610 static ByteSize stack_size_offset() { return byte_offset_of(Thread, _stack_size ); }
611
612 #define TLAB_FIELD_OFFSET(name) \
613 static ByteSize tlab_##name##_offset() { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::name##_offset(); }
614
615 TLAB_FIELD_OFFSET(start)
616 TLAB_FIELD_OFFSET(end)
617 TLAB_FIELD_OFFSET(top)
618 TLAB_FIELD_OFFSET(pf_top)
619 TLAB_FIELD_OFFSET(size) // desired_size
620 TLAB_FIELD_OFFSET(refill_waste_limit)
621 TLAB_FIELD_OFFSET(number_of_refills)
622 TLAB_FIELD_OFFSET(fast_refill_waste)
623 TLAB_FIELD_OFFSET(slow_allocations)
624
625 #undef TLAB_FIELD_OFFSET
626
627 static ByteSize allocated_bytes_offset() { return byte_offset_of(Thread, _allocated_bytes ); }
628
629 public:
630 volatile intptr_t _Stalled ;
631 volatile int _TypeTag ;
632 ParkEvent * _ParkEvent ; // for synchronized()
633 ParkEvent * _SleepEvent ; // for Thread.sleep
634 ParkEvent * _MutexEvent ; // for native internal Mutex/Monitor
635 ParkEvent * _MuxEvent ; // for low-level muxAcquire-muxRelease
636 int NativeSyncRecursion ; // diagnostic
637
638 volatile int _OnTrap ; // Resume-at IP delta
639 jint _hashStateW ; // Marsaglia Shift-XOR thread-local RNG
640 jint _hashStateX ; // thread-specific hashCode generator state
641 jint _hashStateY ;
642 jint _hashStateZ ;
643 void * _schedctl ;
644
645
646 volatile jint rng [4] ; // RNG for spin loop
647
|
25 #ifndef SHARE_VM_RUNTIME_THREAD_HPP
26 #define SHARE_VM_RUNTIME_THREAD_HPP
27
28 #include "memory/allocation.hpp"
29 #include "memory/threadLocalAllocBuffer.hpp"
30 #include "oops/oop.hpp"
31 #include "prims/jni.h"
32 #include "prims/jvmtiExport.hpp"
33 #include "runtime/frame.hpp"
34 #include "runtime/javaFrameAnchor.hpp"
35 #include "runtime/jniHandles.hpp"
36 #include "runtime/mutexLocker.hpp"
37 #include "runtime/os.hpp"
38 #include "runtime/osThread.hpp"
39 #include "runtime/park.hpp"
40 #include "runtime/safepoint.hpp"
41 #include "runtime/stubRoutines.hpp"
42 #include "runtime/threadLocalStorage.hpp"
43 #include "runtime/thread_ext.hpp"
44 #include "runtime/unhandledOops.hpp"
45 #include "utilities/exceptions.hpp"
46 #include "utilities/macros.hpp"
47 #include "utilities/top.hpp"
48 #if INCLUDE_ALL_GCS
49 #include "gc_implementation/g1/dirtyCardQueue.hpp"
50 #include "gc_implementation/g1/satbQueue.hpp"
51 #endif // INCLUDE_ALL_GCS
52 #ifdef TARGET_ARCH_zero
53 # include "stack_zero.hpp"
54 #endif
55 #if INCLUDE_JFR
56 #include "jfr/support/jfrThreadExtension.hpp"
57 #endif
58
59 class ThreadSafepointState;
60 class ThreadProfiler;
61
62 class JvmtiThreadState;
63 class JvmtiGetLoadedClassesClosure;
64 class ThreadStatistics;
65 class ConcurrentLocksDump;
66 class ParkEvent;
67 class Parker;
68
69 class ciEnv;
70 class CompileThread;
71 class CompileLog;
72 class CompileTask;
73 class CompileQueue;
74 class CompilerCounters;
75 class vframeArray;
76
77 class DeoptResourceMark;
244 //
245 NOT_PRODUCT(int _allow_safepoint_count;) // If 0, thread allow a safepoint to happen
246 debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops.
247
248 // Used by SkipGCALot class.
249 NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot?
250
251 friend class No_Alloc_Verifier;
252 friend class No_Safepoint_Verifier;
253 friend class Pause_No_Safepoint_Verifier;
254 friend class ThreadLocalStorage;
255 friend class GC_locker;
256
257 ThreadLocalAllocBuffer _tlab; // Thread-local eden
258 jlong _allocated_bytes; // Cumulative number of bytes allocated on
259 // the Java heap
260
261 // Thread-local buffer used by MetadataOnStackMark.
262 MetadataOnStackBuffer* _metadata_on_stack_buffer;
263
264 JFR_ONLY(DEFINE_THREAD_LOCAL_FIELD_JFR;) // Thread-local data for jfr
265
266 ThreadExt _ext;
267
268 int _vm_operation_started_count; // VM_Operation support
269 int _vm_operation_completed_count; // VM_Operation support
270
271 ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread
272 // is waiting to lock
273 bool _current_pending_monitor_is_from_java; // locking is from Java code
274
275 // ObjectMonitor on which this thread called Object.wait()
276 ObjectMonitor* _current_waiting_monitor;
277
278 // Private thread-local objectmonitor list - a simple cache organized as a SLL.
279 public:
280 ObjectMonitor* omFreeList;
281 int omFreeCount; // length of omFreeList
282 int omFreeProvision; // reload chunk size
283 ObjectMonitor* omInUseList; // SLL to track monitors in circulation
284 int omInUseCount; // length of omInUseList
425 // Internal handle support
426 HandleArea* handle_area() const { return _handle_area; }
427 void set_handle_area(HandleArea* area) { _handle_area = area; }
428
429 GrowableArray<Metadata*>* metadata_handles() const { return _metadata_handles; }
430 void set_metadata_handles(GrowableArray<Metadata*>* handles){ _metadata_handles = handles; }
431
432 // Thread-Local Allocation Buffer (TLAB) support
433 ThreadLocalAllocBuffer& tlab() { return _tlab; }
434 void initialize_tlab() {
435 if (UseTLAB) {
436 tlab().initialize();
437 }
438 }
439
440 jlong allocated_bytes() { return _allocated_bytes; }
441 void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
442 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
443 inline jlong cooked_allocated_bytes();
444
445 JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
446
447 const ThreadExt& ext() const { return _ext; }
448 ThreadExt& ext() { return _ext; }
449
450 // VM operation support
451 int vm_operation_ticket() { return ++_vm_operation_started_count; }
452 int vm_operation_completed_count() { return _vm_operation_completed_count; }
453 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; }
454
455 // For tracking the heavyweight monitor the thread is pending on.
456 ObjectMonitor* current_pending_monitor() {
457 return _current_pending_monitor;
458 }
459 void set_current_pending_monitor(ObjectMonitor* monitor) {
460 _current_pending_monitor = monitor;
461 }
462 void set_current_pending_monitor_is_from_java(bool from_java) {
463 _current_pending_monitor_is_from_java = from_java;
464 }
465 bool current_pending_monitor_is_from_java() {
609
610 static ByteSize stack_base_offset() { return byte_offset_of(Thread, _stack_base ); }
611 static ByteSize stack_size_offset() { return byte_offset_of(Thread, _stack_size ); }
612
613 #define TLAB_FIELD_OFFSET(name) \
614 static ByteSize tlab_##name##_offset() { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::name##_offset(); }
615
616 TLAB_FIELD_OFFSET(start)
617 TLAB_FIELD_OFFSET(end)
618 TLAB_FIELD_OFFSET(top)
619 TLAB_FIELD_OFFSET(pf_top)
620 TLAB_FIELD_OFFSET(size) // desired_size
621 TLAB_FIELD_OFFSET(refill_waste_limit)
622 TLAB_FIELD_OFFSET(number_of_refills)
623 TLAB_FIELD_OFFSET(fast_refill_waste)
624 TLAB_FIELD_OFFSET(slow_allocations)
625
626 #undef TLAB_FIELD_OFFSET
627
628 static ByteSize allocated_bytes_offset() { return byte_offset_of(Thread, _allocated_bytes ); }
629
630 JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
631
632 public:
633 volatile intptr_t _Stalled ;
634 volatile int _TypeTag ;
635 ParkEvent * _ParkEvent ; // for synchronized()
636 ParkEvent * _SleepEvent ; // for Thread.sleep
637 ParkEvent * _MutexEvent ; // for native internal Mutex/Monitor
638 ParkEvent * _MuxEvent ; // for low-level muxAcquire-muxRelease
639 int NativeSyncRecursion ; // diagnostic
640
641 volatile int _OnTrap ; // Resume-at IP delta
642 jint _hashStateW ; // Marsaglia Shift-XOR thread-local RNG
643 jint _hashStateX ; // thread-specific hashCode generator state
644 jint _hashStateY ;
645 jint _hashStateZ ;
646 void * _schedctl ;
647
648
649 volatile jint rng [4] ; // RNG for spin loop
650
|