< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page
rev 56776 : v2.00 -> v2.07 (CR7/v2.07/10-for-jdk14) patches combined into one; merge with 8230876.patch (2019.10.17) and jdk-14+21.
rev 56777 : See CR7-to-CR8-changes.


 397 
 398   ThreadStatisticalInfo _statistical_info;      // Statistics about the thread
 399 
 400   JFR_ONLY(DEFINE_THREAD_LOCAL_FIELD_JFR;)      // Thread-local data for jfr
 401 
 402   int   _vm_operation_started_count;            // VM_Operation support
 403   int   _vm_operation_completed_count;          // VM_Operation support
 404 
 405   ObjectMonitor* _current_pending_monitor;      // ObjectMonitor this thread
 406                                                 // is waiting to lock
 407   bool _current_pending_monitor_is_from_java;   // locking is from Java code
 408   JvmtiRawMonitor* _current_pending_raw_monitor; // JvmtiRawMonitor this thread
 409                                                  // is waiting to lock
 410 
 411 
 412   // ObjectMonitor on which this thread called Object.wait()
 413   ObjectMonitor* _current_waiting_monitor;
 414 
 415   // Per-thread ObjectMonitor lists:
 416  public:
 417   ObjectMonitor* om_free_list;                  // SLL of free ObjectMonitors
 418   int om_free_count;                            // # on om_free_list
 419   int om_free_provision;                        // # to try to allocate next
 420   ObjectMonitor* om_in_use_list;                // SLL of in-use ObjectMonitors
 421   int om_in_use_count;                          // # on om_in_use_list
 422 
 423 #ifdef ASSERT
 424  private:
 425   volatile uint64_t _visited_for_critical_count;
 426 
 427  public:
 428   void set_visited_for_critical_count(uint64_t safepoint_id) {
 429     assert(_visited_for_critical_count == 0, "Must be reset before set");
 430     assert((safepoint_id & 0x1) == 1, "Must be odd");
 431     _visited_for_critical_count = safepoint_id;
 432   }
 433   void reset_visited_for_critical_count(uint64_t safepoint_id) {
 434     assert(_visited_for_critical_count == safepoint_id, "Was not visited");
 435     _visited_for_critical_count = 0;
 436   }
 437   bool was_visited_for_critical_count(uint64_t safepoint_id) const {
 438     return _visited_for_critical_count == safepoint_id;
 439   }
 440 #endif
 441 


 507   static inline Thread* current();
 508   // Returns the current thread, or NULL if not attached
 509   static inline Thread* current_or_null();
 510   // Returns the current thread, or NULL if not attached, and is
 511   // safe for use from signal-handlers
 512   static inline Thread* current_or_null_safe();
 513 
 514   // Common thread operations
 515 #ifdef ASSERT
 516   static void check_for_dangling_thread_pointer(Thread *thread);
 517 #endif
 518   static void set_priority(Thread* thread, ThreadPriority priority);
 519   static ThreadPriority get_priority(const Thread* const thread);
 520   static void start(Thread* thread);
 521 
 522   void set_native_thread_name(const char *name) {
 523     assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
 524     os::set_native_thread_name(name);
 525   }
 526 
 527   ObjectMonitor** om_in_use_list_addr()          { return (ObjectMonitor **)&om_in_use_list; }
 528   Monitor* SR_lock() const                       { return _SR_lock; }
 529 
 530   bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
 531 
 532   inline void set_suspend_flag(SuspendFlags f);
 533   inline void clear_suspend_flag(SuspendFlags f);
 534 
 535   inline void set_has_async_exception();
 536   inline void clear_has_async_exception();
 537 
 538   bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
 539 
 540   inline void set_critical_native_unlock();
 541   inline void clear_critical_native_unlock();
 542 
 543   inline void set_trace_flag();
 544   inline void clear_trace_flag();
 545 
 546   // Support for Unhandled Oop detection
 547   // Add the field for both, fastdebug and debug, builds to keep


 606 
 607   jlong allocated_bytes()               { return _allocated_bytes; }
 608   void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
 609   void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
 610   inline jlong cooked_allocated_bytes();
 611 
 612   ThreadHeapSampler& heap_sampler()     { return _heap_sampler; }
 613 
 614   ThreadStatisticalInfo& statistical_info() { return _statistical_info; }
 615 
 616   JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
 617 
 618   bool is_trace_suspend()               { return (_suspend_flags & _trace_flag) != 0; }
 619 
 620   // VM operation support
 621   int vm_operation_ticket()                      { return ++_vm_operation_started_count; }
 622   int vm_operation_completed_count()             { return _vm_operation_completed_count; }
 623   void increment_vm_operation_completed_count()  { _vm_operation_completed_count++; }
 624 
 625   // For tracking the heavyweight monitor the thread is pending on.
 626   ObjectMonitor* current_pending_monitor() {
 627     return _current_pending_monitor;



 628   }
 629   void set_current_pending_monitor(ObjectMonitor* monitor) {






 630     _current_pending_monitor = monitor;



 631   }
 632   void set_current_pending_monitor_is_from_java(bool from_java) {
 633     _current_pending_monitor_is_from_java = from_java;
 634   }
 635   bool current_pending_monitor_is_from_java() {
 636     return _current_pending_monitor_is_from_java;
 637   }
 638 
 639   // For tracking the ObjectMonitor on which this thread called Object.wait()
 640   ObjectMonitor* current_waiting_monitor() {
 641     return _current_waiting_monitor;



 642   }
 643   void set_current_waiting_monitor(ObjectMonitor* monitor) {






 644     _current_waiting_monitor = monitor;



 645   }
 646 
 647   // For tracking the Jvmti raw monitor the thread is pending on.
 648   JvmtiRawMonitor* current_pending_raw_monitor() {
 649     return _current_pending_raw_monitor;
 650   }
 651   void set_current_pending_raw_monitor(JvmtiRawMonitor* monitor) {
 652     _current_pending_raw_monitor = monitor;
 653   }
 654 
 655   // GC support
 656   // Apply "f->do_oop" to all root oops in "this".
 657   //   Used by JavaThread::oops_do.
 658   // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
 659   virtual void oops_do(OopClosure* f, CodeBlobClosure* cf);
 660 
 661   // Handles the parallel case for claim_threads_do.
 662  private:
 663   bool claim_par_threads_do(uintx claim_token);
 664  public:




 397 
 398   ThreadStatisticalInfo _statistical_info;      // Statistics about the thread
 399 
 400   JFR_ONLY(DEFINE_THREAD_LOCAL_FIELD_JFR;)      // Thread-local data for jfr
 401 
 402   int   _vm_operation_started_count;            // VM_Operation support
 403   int   _vm_operation_completed_count;          // VM_Operation support
 404 
 405   ObjectMonitor* _current_pending_monitor;      // ObjectMonitor this thread
 406                                                 // is waiting to lock
 407   bool _current_pending_monitor_is_from_java;   // locking is from Java code
 408   JvmtiRawMonitor* _current_pending_raw_monitor; // JvmtiRawMonitor this thread
 409                                                  // is waiting to lock
 410 
 411 
 412   // ObjectMonitor on which this thread called Object.wait()
 413   ObjectMonitor* _current_waiting_monitor;
 414 
 415   // Per-thread ObjectMonitor lists:
 416  public:
 417   ObjectMonitor* volatile om_free_list;         // SLL of free ObjectMonitors
 418   volatile int om_free_count;                   // # on om_free_list
 419   int om_free_provision;                        // # to try to allocate next
 420   ObjectMonitor* volatile om_in_use_list;       // SLL of in-use ObjectMonitors
 421   volatile int om_in_use_count;                 // # on om_in_use_list
 422 
 423 #ifdef ASSERT
 424  private:
 425   volatile uint64_t _visited_for_critical_count;
 426 
 427  public:
 428   void set_visited_for_critical_count(uint64_t safepoint_id) {
 429     assert(_visited_for_critical_count == 0, "Must be reset before set");
 430     assert((safepoint_id & 0x1) == 1, "Must be odd");
 431     _visited_for_critical_count = safepoint_id;
 432   }
 433   void reset_visited_for_critical_count(uint64_t safepoint_id) {
 434     assert(_visited_for_critical_count == safepoint_id, "Was not visited");
 435     _visited_for_critical_count = 0;
 436   }
 437   bool was_visited_for_critical_count(uint64_t safepoint_id) const {
 438     return _visited_for_critical_count == safepoint_id;
 439   }
 440 #endif
 441 


 507   static inline Thread* current();
 508   // Returns the current thread, or NULL if not attached
 509   static inline Thread* current_or_null();
 510   // Returns the current thread, or NULL if not attached, and is
 511   // safe for use from signal-handlers
 512   static inline Thread* current_or_null_safe();
 513 
 514   // Common thread operations
 515 #ifdef ASSERT
 516   static void check_for_dangling_thread_pointer(Thread *thread);
 517 #endif
 518   static void set_priority(Thread* thread, ThreadPriority priority);
 519   static ThreadPriority get_priority(const Thread* const thread);
 520   static void start(Thread* thread);
 521 
 522   void set_native_thread_name(const char *name) {
 523     assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
 524     os::set_native_thread_name(name);
 525   }
 526 

 527   Monitor* SR_lock() const                       { return _SR_lock; }
 528 
 529   bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
 530 
 531   inline void set_suspend_flag(SuspendFlags f);
 532   inline void clear_suspend_flag(SuspendFlags f);
 533 
 534   inline void set_has_async_exception();
 535   inline void clear_has_async_exception();
 536 
 537   bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
 538 
 539   inline void set_critical_native_unlock();
 540   inline void clear_critical_native_unlock();
 541 
 542   inline void set_trace_flag();
 543   inline void clear_trace_flag();
 544 
 545   // Support for Unhandled Oop detection
 546   // Add the field for both, fastdebug and debug, builds to keep


 605 
 606   jlong allocated_bytes()               { return _allocated_bytes; }
 607   void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
 608   void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
 609   inline jlong cooked_allocated_bytes();
 610 
 611   ThreadHeapSampler& heap_sampler()     { return _heap_sampler; }
 612 
 613   ThreadStatisticalInfo& statistical_info() { return _statistical_info; }
 614 
 615   JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
 616 
 617   bool is_trace_suspend()               { return (_suspend_flags & _trace_flag) != 0; }
 618 
 619   // VM operation support
 620   int vm_operation_ticket()                      { return ++_vm_operation_started_count; }
 621   int vm_operation_completed_count()             { return _vm_operation_completed_count; }
 622   void increment_vm_operation_completed_count()  { _vm_operation_completed_count++; }
 623 
 624   // For tracking the heavyweight monitor the thread is pending on.
 625   ObjectMonitor* current_pending_monitor(ObjectMonitorHandle* omh_p) {
 626     if (omh_p->set_om_ptr_if_safe(_current_pending_monitor)) {
 627       return omh_p->om_ptr();  // Return the safe ObjectMonitor*.
 628     }
 629     return NULL;
 630   }
 631   void set_current_pending_monitor(ObjectMonitor* monitor) {
 632     ObjectMonitor* saved_cur = NULL;
 633     if (monitor != NULL) {
 634       monitor->inc_ref_count();  // Protect the ObjectMonitor* we're about to cache.
 635     } else {
 636       saved_cur = _current_pending_monitor;
 637     }
 638     _current_pending_monitor = monitor;
 639     if (saved_cur != NULL) {
 640       saved_cur->dec_ref_count();  // Cleared the cached ObjectMonitor*.
 641     }
 642   }
 643   void set_current_pending_monitor_is_from_java(bool from_java) {
 644     _current_pending_monitor_is_from_java = from_java;
 645   }
 646   bool current_pending_monitor_is_from_java() {
 647     return _current_pending_monitor_is_from_java;
 648   }
 649 
 650   // For tracking the ObjectMonitor on which this thread called Object.wait()
 651   ObjectMonitor* current_waiting_monitor(ObjectMonitorHandle* omh_p) {
 652     if (omh_p->set_om_ptr_if_safe(_current_waiting_monitor)) {
 653       return omh_p->om_ptr();  // Return the safe ObjectMonitor*.
 654     }
 655     return NULL;
 656   }
 657   void set_current_waiting_monitor(ObjectMonitor* monitor) {
 658     ObjectMonitor* saved_cur = NULL;
 659     if (monitor != NULL) {
 660       monitor->inc_ref_count();  // Protect the ObjectMonitor* we're about to cache.
 661     } else {
 662       saved_cur = _current_waiting_monitor;
 663     }
 664     _current_waiting_monitor = monitor;
 665     if (saved_cur != NULL) {
 666       saved_cur->dec_ref_count();  // Cleared the cached ObjectMonitor*.
 667     }
 668   }
 669 
 670   // For tracking the Jvmti raw monitor the thread is pending on.
 671   JvmtiRawMonitor* current_pending_raw_monitor() {
 672     return _current_pending_raw_monitor;
 673   }
 674   void set_current_pending_raw_monitor(JvmtiRawMonitor* monitor) {
 675     _current_pending_raw_monitor = monitor;
 676   }
 677 
 678   // GC support
 679   // Apply "f->do_oop" to all root oops in "this".
 680   //   Used by JavaThread::oops_do.
 681   // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
 682   virtual void oops_do(OopClosure* f, CodeBlobClosure* cf);
 683 
 684   // Handles the parallel case for claim_threads_do.
 685  private:
 686   bool claim_par_threads_do(uintx claim_token);
 687  public:


< prev index next >