src/share/vm/runtime/thread.hpp

changeset 9931
fd44df5e3bc3
parent 9448
73d689add964
parent 9903
f37c2dd33031
equal deleted inserted replaced
9855:274a1ea904c8 9931:fd44df5e3bc3
46 #include "runtime/safepoint.hpp" 46 #include "runtime/safepoint.hpp"
47 #include "runtime/stubRoutines.hpp" 47 #include "runtime/stubRoutines.hpp"
48 #include "runtime/threadLocalStorage.hpp" 48 #include "runtime/threadLocalStorage.hpp"
49 #include "runtime/thread_ext.hpp" 49 #include "runtime/thread_ext.hpp"
50 #include "runtime/unhandledOops.hpp" 50 #include "runtime/unhandledOops.hpp"
51 #include "trace/traceBackend.hpp"
52 #include "trace/traceMacros.hpp"
53 #include "utilities/exceptions.hpp" 51 #include "utilities/exceptions.hpp"
54 #include "utilities/macros.hpp" 52 #include "utilities/macros.hpp"
55 #include "utilities/top.hpp" 53 #include "utilities/top.hpp"
56 #if INCLUDE_ALL_GCS 54 #if INCLUDE_ALL_GCS
57 #include "gc_implementation/g1/dirtyCardQueue.hpp" 55 #include "gc_implementation/g1/dirtyCardQueue.hpp"
58 #include "gc_implementation/g1/satbQueue.hpp" 56 #include "gc_implementation/g1/satbQueue.hpp"
59 #endif // INCLUDE_ALL_GCS 57 #endif // INCLUDE_ALL_GCS
60 #ifdef TARGET_ARCH_zero 58 #ifdef TARGET_ARCH_zero
61 # include "stack_zero.hpp" 59 # include "stack_zero.hpp"
60 #endif
61 #if INCLUDE_JFR
62 #include "jfr/support/jfrThreadExtension.hpp"
62 #endif 63 #endif
63 64
64 class ThreadSafepointState; 65 class ThreadSafepointState;
65 class ThreadProfiler; 66 class ThreadProfiler;
66 67
199 _external_suspend = 0x20000000U, // thread is asked to self suspend 200 _external_suspend = 0x20000000U, // thread is asked to self suspend
200 _ext_suspended = 0x40000000U, // thread has self-suspended 201 _ext_suspended = 0x40000000U, // thread has self-suspended
201 _deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt 202 _deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt
202 203
203 _has_async_exception = 0x00000001U, // there is a pending async exception 204 _has_async_exception = 0x00000001U, // there is a pending async exception
204 _critical_native_unlock = 0x00000002U // Must call back to unlock JNI critical lock 205 _critical_native_unlock = 0x00000002U, // Must call back to unlock JNI critical lock
206
207 JFR_ONLY(_trace_flag = 0x00000004U) // call jfr tracing
205 }; 208 };
206 209
207 // various suspension related flags - atomically updated 210 // various suspension related flags - atomically updated
208 // overloaded for async exception checking in check_special_condition_for_native_trans. 211 // overloaded for async exception checking in check_special_condition_for_native_trans.
209 volatile uint32_t _suspend_flags; 212 volatile uint32_t _suspend_flags;
264 // the Java heap 267 // the Java heap
265 268
266 // Thread-local buffer used by MetadataOnStackMark. 269 // Thread-local buffer used by MetadataOnStackMark.
267 MetadataOnStackBuffer* _metadata_on_stack_buffer; 270 MetadataOnStackBuffer* _metadata_on_stack_buffer;
268 271
269 TRACE_DATA _trace_data; // Thread-local data for tracing 272 JFR_ONLY(DEFINE_THREAD_LOCAL_FIELD_JFR;) // Thread-local data for jfr
270 273
271 ThreadExt _ext; 274 ThreadExt _ext;
272 275
273 int _vm_operation_started_count; // VM_Operation support 276 int _vm_operation_started_count; // VM_Operation support
274 int _vm_operation_completed_count; // VM_Operation support 277 int _vm_operation_completed_count; // VM_Operation support
445 jlong allocated_bytes() { return _allocated_bytes; } 448 jlong allocated_bytes() { return _allocated_bytes; }
446 void set_allocated_bytes(jlong value) { _allocated_bytes = value; } 449 void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
447 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; } 450 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
448 inline jlong cooked_allocated_bytes(); 451 inline jlong cooked_allocated_bytes();
449 452
450 TRACE_DATA* trace_data() { return &_trace_data; } 453 JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
454 JFR_ONLY(DEFINE_TRACE_SUSPEND_FLAG_METHODS)
451 455
452 const ThreadExt& ext() const { return _ext; } 456 const ThreadExt& ext() const { return _ext; }
453 ThreadExt& ext() { return _ext; } 457 ThreadExt& ext() { return _ext; }
454 458
455 // VM operation support 459 // VM operation support
558 void set_stack_size(size_t size) { _stack_size = size; } 562 void set_stack_size(size_t size) { _stack_size = size; }
559 void record_stack_base_and_size(); 563 void record_stack_base_and_size();
560 564
561 bool on_local_stack(address adr) const { 565 bool on_local_stack(address adr) const {
562 /* QQQ this has knowledge of direction, ought to be a stack method */ 566 /* QQQ this has knowledge of direction, ought to be a stack method */
563 return (_stack_base >= adr && adr >= (_stack_base - _stack_size)); 567 return (_stack_base > adr && adr >= (_stack_base - _stack_size));
564 } 568 }
565 569
566 uintptr_t self_raw_id() { return _self_raw_id; } 570 uintptr_t self_raw_id() { return _self_raw_id; }
567 void set_self_raw_id(uintptr_t value) { _self_raw_id = value; } 571 void set_self_raw_id(uintptr_t value) { _self_raw_id = value; }
568 572
630 634
631 #undef TLAB_FIELD_OFFSET 635 #undef TLAB_FIELD_OFFSET
632 636
633 static ByteSize allocated_bytes_offset() { return byte_offset_of(Thread, _allocated_bytes ); } 637 static ByteSize allocated_bytes_offset() { return byte_offset_of(Thread, _allocated_bytes ); }
634 638
639 JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
640
635 public: 641 public:
636 volatile intptr_t _Stalled ; 642 volatile intptr_t _Stalled ;
637 volatile int _TypeTag ; 643 volatile int _TypeTag ;
638 ParkEvent * _ParkEvent ; // for synchronized() 644 ParkEvent * _ParkEvent ; // for synchronized()
639 ParkEvent * _SleepEvent ; // for Thread.sleep 645 ParkEvent * _SleepEvent ; // for Thread.sleep
732 private: 738 private:
733 static WatcherThread* _watcher_thread; 739 static WatcherThread* _watcher_thread;
734 740
735 static bool _startable; 741 static bool _startable;
736 volatile static bool _should_terminate; // updated without holding lock 742 volatile static bool _should_terminate; // updated without holding lock
737
738 os::WatcherThreadCrashProtection* _crash_protection;
739 public: 743 public:
740 enum SomeConstants { 744 enum SomeConstants {
741 delay_interval = 10 // interrupt delay in milliseconds 745 delay_interval = 10 // interrupt delay in milliseconds
742 }; 746 };
743 747
760 static void start(); 764 static void start();
761 static void stop(); 765 static void stop();
762 // Only allow start once the VM is sufficiently initialized 766 // Only allow start once the VM is sufficiently initialized
763 // Otherwise the first task to enroll will trigger the start 767 // Otherwise the first task to enroll will trigger the start
764 static void make_startable(); 768 static void make_startable();
765
766 void set_crash_protection(os::WatcherThreadCrashProtection* crash_protection) {
767 assert(Thread::current()->is_Watcher_thread(), "Can only be set by WatcherThread");
768 _crash_protection = crash_protection;
769 }
770
771 bool has_crash_protection() const { return _crash_protection != NULL; }
772 os::WatcherThreadCrashProtection* crash_protection() const { return _crash_protection; }
773
774 private: 769 private:
775 int sleep() const; 770 int sleep() const;
776 }; 771 };
777 772
778 773

mercurial