< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page




  45 #include "runtime/threadHeapSampler.hpp"
  46 #include "runtime/threadLocalStorage.hpp"
  47 #include "runtime/threadStatisticalInfo.hpp"
  48 #include "runtime/unhandledOops.hpp"
  49 #include "utilities/align.hpp"
  50 #include "utilities/exceptions.hpp"
  51 #include "utilities/macros.hpp"
  52 #ifdef ZERO
  53 # include "stack_zero.hpp"
  54 #endif
  55 #if INCLUDE_JFR
  56 #include "jfr/support/jfrThreadExtension.hpp"
  57 #endif
  58 
  59 
  60 class SafeThreadsListPtr;
  61 class ThreadSafepointState;
  62 class ThreadsList;
  63 class ThreadsSMRSupport;
  64 

  65 class JvmtiThreadState;
  66 class ThreadStatistics;
  67 class ConcurrentLocksDump;
  68 class ParkEvent;
  69 class Parker;
  70 class MonitorInfo;
  71 
  72 class ciEnv;
  73 class CompileThread;
  74 class CompileLog;
  75 class CompileTask;
  76 class CompileQueue;
  77 class CompilerCounters;
  78 
  79 class vframeArray;
  80 class vframe;
  81 class javaVFrame;
  82 
  83 class DeoptResourceMark;
  84 class jvmtiDeferredLocalVariableSet;


 387   friend class NoSafepointVerifier;
 388   friend class PauseNoSafepointVerifier;
 389 
 390   volatile void* _polling_page;                 // Thread local polling page
 391 
 392   ThreadLocalAllocBuffer _tlab;                 // Thread-local eden
 393   jlong _allocated_bytes;                       // Cumulative number of bytes allocated on
 394                                                 // the Java heap
 395   ThreadHeapSampler _heap_sampler;              // For use when sampling the memory.
 396 
 397   ThreadStatisticalInfo _statistical_info;      // Statistics about the thread
 398 
 399   JFR_ONLY(DEFINE_THREAD_LOCAL_FIELD_JFR;)      // Thread-local data for jfr
 400 
 401   int   _vm_operation_started_count;            // VM_Operation support
 402   int   _vm_operation_completed_count;          // VM_Operation support
 403 
 404   ObjectMonitor* _current_pending_monitor;      // ObjectMonitor this thread
 405                                                 // is waiting to lock
 406   bool _current_pending_monitor_is_from_java;   // locking is from Java code



 407 
 408   // ObjectMonitor on which this thread called Object.wait()
 409   ObjectMonitor* _current_waiting_monitor;
 410 
 411   // Per-thread ObjectMonitor lists:
 412  public:
 413   ObjectMonitor* om_free_list;                  // SLL of free ObjectMonitors
 414   int om_free_count;                            // # on om_free_list
 415   int om_free_provision;                        // # to try to allocate next
 416   ObjectMonitor* om_in_use_list;                // SLL of in-use ObjectMonitors
 417   int om_in_use_count;                          // # on om_in_use_list
 418 
 419 #ifdef ASSERT
 420  private:
 421   volatile uint64_t _visited_for_critical_count;
 422 
 423  public:
 424   void set_visited_for_critical_count(uint64_t safepoint_id) {
 425     assert(_visited_for_critical_count == 0, "Must be reset before set");
 426     assert((safepoint_id & 0x1) == 1, "Must be odd");


 623     return _current_pending_monitor;
 624   }
 625   void set_current_pending_monitor(ObjectMonitor* monitor) {
 626     _current_pending_monitor = monitor;
 627   }
 628   void set_current_pending_monitor_is_from_java(bool from_java) {
 629     _current_pending_monitor_is_from_java = from_java;
 630   }
 631   bool current_pending_monitor_is_from_java() {
 632     return _current_pending_monitor_is_from_java;
 633   }
 634 
 635   // For tracking the ObjectMonitor on which this thread called Object.wait()
 636   ObjectMonitor* current_waiting_monitor() {
 637     return _current_waiting_monitor;
 638   }
 639   void set_current_waiting_monitor(ObjectMonitor* monitor) {
 640     _current_waiting_monitor = monitor;
 641   }
 642 








 643   // GC support
 644   // Apply "f->do_oop" to all root oops in "this".
 645   //   Used by JavaThread::oops_do.
 646   // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
 647   virtual void oops_do(OopClosure* f, CodeBlobClosure* cf);
 648 
 649   // Handles the parallel case for claim_threads_do.
 650  private:
 651   bool claim_par_threads_do(uintx claim_token);
 652  public:
 653   // Requires that "claim_token" is that of the current iteration.
 654   // If "is_par" is false, sets the token of "this" to
 655   // "claim_token", and returns "true".  If "is_par" is true,
 656   // uses an atomic instruction to set the current thread's token to
 657   // "claim_token", if it is not already.  Returns "true" iff the
 658   // calling thread does the update, this indicates that the calling thread
 659   // has claimed the thread in the current iteration.
 660   bool claim_threads_do(bool is_par, uintx claim_token) {
 661     if (!is_par) {
 662       _threads_do_token = claim_token;


 769   static ByteSize exception_line_offset()        { return byte_offset_of(Thread, _exception_line); }
 770   static ByteSize active_handles_offset()        { return byte_offset_of(Thread, _active_handles); }
 771 
 772   static ByteSize stack_base_offset()            { return byte_offset_of(Thread, _stack_base); }
 773   static ByteSize stack_size_offset()            { return byte_offset_of(Thread, _stack_size); }
 774 
 775   static ByteSize polling_page_offset()          { return byte_offset_of(Thread, _polling_page); }
 776 
 777   static ByteSize tlab_start_offset()            { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::start_offset(); }
 778   static ByteSize tlab_end_offset()              { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::end_offset(); }
 779   static ByteSize tlab_top_offset()              { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::top_offset(); }
 780   static ByteSize tlab_pf_top_offset()           { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::pf_top_offset(); }
 781 
 782   static ByteSize allocated_bytes_offset()       { return byte_offset_of(Thread, _allocated_bytes); }
 783 
 784   JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
 785 
 786  public:
 787   volatile intptr_t _Stalled;
 788   volatile int _TypeTag;
 789   ParkEvent * _ParkEvent;                     // for synchronized()
 790   ParkEvent * _MuxEvent;                      // for low-level muxAcquire-muxRelease
 791   int NativeSyncRecursion;                    // diagnostic
 792 
 793   volatile int _OnTrap;                       // Resume-at IP delta
 794   jint _hashStateW;                           // Marsaglia Shift-XOR thread-local RNG
 795   jint _hashStateX;                           // thread-specific hashCode generator state
 796   jint _hashStateY;
 797   jint _hashStateZ;
 798 
 799   // Low-level leaf-lock primitives used to implement synchronization
 800   // and native monitor-mutex infrastructure.
 801   // Not for general synchronization use.
 802   static void SpinAcquire(volatile int * Lock, const char * Name);
 803   static void SpinRelease(volatile int * Lock);
 804   static void muxAcquire(volatile intptr_t * Lock, const char * Name);
 805   static void muxRelease(volatile intptr_t * Lock);
 806 };
 807 
 808 // Inline implementation of Thread::current()
 809 inline Thread* Thread::current() {




  45 #include "runtime/threadHeapSampler.hpp"
  46 #include "runtime/threadLocalStorage.hpp"
  47 #include "runtime/threadStatisticalInfo.hpp"
  48 #include "runtime/unhandledOops.hpp"
  49 #include "utilities/align.hpp"
  50 #include "utilities/exceptions.hpp"
  51 #include "utilities/macros.hpp"
  52 #ifdef ZERO
  53 # include "stack_zero.hpp"
  54 #endif
  55 #if INCLUDE_JFR
  56 #include "jfr/support/jfrThreadExtension.hpp"
  57 #endif
  58 
  59 
  60 class SafeThreadsListPtr;
  61 class ThreadSafepointState;
  62 class ThreadsList;
  63 class ThreadsSMRSupport;
  64 
  65 class JvmtiRawMonitor;
  66 class JvmtiThreadState;
  67 class ThreadStatistics;
  68 class ConcurrentLocksDump;
  69 class ParkEvent;
  70 class Parker;
  71 class MonitorInfo;
  72 
  73 class ciEnv;
  74 class CompileThread;
  75 class CompileLog;
  76 class CompileTask;
  77 class CompileQueue;
  78 class CompilerCounters;
  79 
  80 class vframeArray;
  81 class vframe;
  82 class javaVFrame;
  83 
  84 class DeoptResourceMark;
  85 class jvmtiDeferredLocalVariableSet;


 388   friend class NoSafepointVerifier;
 389   friend class PauseNoSafepointVerifier;
 390 
 391   volatile void* _polling_page;                 // Thread local polling page
 392 
 393   ThreadLocalAllocBuffer _tlab;                 // Thread-local eden
 394   jlong _allocated_bytes;                       // Cumulative number of bytes allocated on
 395                                                 // the Java heap
 396   ThreadHeapSampler _heap_sampler;              // For use when sampling the memory.
 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");


 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:
 665   // Requires that "claim_token" is that of the current iteration.
 666   // If "is_par" is false, sets the token of "this" to
 667   // "claim_token", and returns "true".  If "is_par" is true,
 668   // uses an atomic instruction to set the current thread's token to
 669   // "claim_token", if it is not already.  Returns "true" iff the
 670   // calling thread does the update, this indicates that the calling thread
 671   // has claimed the thread in the current iteration.
 672   bool claim_threads_do(bool is_par, uintx claim_token) {
 673     if (!is_par) {
 674       _threads_do_token = claim_token;


 781   static ByteSize exception_line_offset()        { return byte_offset_of(Thread, _exception_line); }
 782   static ByteSize active_handles_offset()        { return byte_offset_of(Thread, _active_handles); }
 783 
 784   static ByteSize stack_base_offset()            { return byte_offset_of(Thread, _stack_base); }
 785   static ByteSize stack_size_offset()            { return byte_offset_of(Thread, _stack_size); }
 786 
 787   static ByteSize polling_page_offset()          { return byte_offset_of(Thread, _polling_page); }
 788 
 789   static ByteSize tlab_start_offset()            { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::start_offset(); }
 790   static ByteSize tlab_end_offset()              { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::end_offset(); }
 791   static ByteSize tlab_top_offset()              { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::top_offset(); }
 792   static ByteSize tlab_pf_top_offset()           { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::pf_top_offset(); }
 793 
 794   static ByteSize allocated_bytes_offset()       { return byte_offset_of(Thread, _allocated_bytes); }
 795 
 796   JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
 797 
 798  public:
 799   volatile intptr_t _Stalled;
 800   volatile int _TypeTag;
 801   ParkEvent * _ParkEvent;                     // for Object monitors and JVMTI raw monitors
 802   ParkEvent * _MuxEvent;                      // for low-level muxAcquire-muxRelease
 803   int NativeSyncRecursion;                    // diagnostic
 804 
 805   volatile int _OnTrap;                       // Resume-at IP delta
 806   jint _hashStateW;                           // Marsaglia Shift-XOR thread-local RNG
 807   jint _hashStateX;                           // thread-specific hashCode generator state
 808   jint _hashStateY;
 809   jint _hashStateZ;
 810 
 811   // Low-level leaf-lock primitives used to implement synchronization
 812   // and native monitor-mutex infrastructure.
 813   // Not for general synchronization use.
 814   static void SpinAcquire(volatile int * Lock, const char * Name);
 815   static void SpinRelease(volatile int * Lock);
 816   static void muxAcquire(volatile intptr_t * Lock, const char * Name);
 817   static void muxRelease(volatile intptr_t * Lock);
 818 };
 819 
 820 // Inline implementation of Thread::current()
 821 inline Thread* Thread::current() {


< prev index next >