< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page
rev 50392 : JEP 331


  25 #ifndef SHARE_VM_RUNTIME_THREAD_HPP
  26 #define SHARE_VM_RUNTIME_THREAD_HPP
  27 
  28 #include "jni.h"
  29 #include "gc/shared/gcThreadLocalData.hpp"
  30 #include "gc/shared/threadLocalAllocBuffer.hpp"
  31 #include "memory/allocation.hpp"
  32 #include "oops/oop.hpp"
  33 #include "prims/jvmtiExport.hpp"
  34 #include "runtime/frame.hpp"
  35 #include "runtime/globals.hpp"
  36 #include "runtime/handshake.hpp"
  37 #include "runtime/javaFrameAnchor.hpp"
  38 #include "runtime/jniHandles.hpp"
  39 #include "runtime/mutexLocker.hpp"
  40 #include "runtime/os.hpp"
  41 #include "runtime/osThread.hpp"
  42 #include "runtime/park.hpp"
  43 #include "runtime/safepoint.hpp"
  44 #include "runtime/stubRoutines.hpp"

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


 321   // (Hence, !allow_safepoint() => !allow_allocation()).
 322   //
 323   // The two classes NoSafepointVerifier and No_Allocation_Verifier are used to set these counters.
 324   //
 325   NOT_PRODUCT(int _allow_safepoint_count;)      // If 0, thread allow a safepoint to happen
 326   debug_only(int _allow_allocation_count;)     // If 0, the thread is allowed to allocate oops.
 327 
 328   // Used by SkipGCALot class.
 329   NOT_PRODUCT(bool _skip_gcalot;)               // Should we elide gc-a-lot?
 330 
 331   friend class NoAllocVerifier;
 332   friend class NoSafepointVerifier;
 333   friend class PauseNoSafepointVerifier;
 334   friend class GCLocker;
 335 
 336   volatile void* _polling_page;                 // Thread local polling page
 337 
 338   ThreadLocalAllocBuffer _tlab;                 // Thread-local eden
 339   jlong _allocated_bytes;                       // Cumulative number of bytes allocated on
 340                                                 // the Java heap

 341 
 342   JFR_ONLY(DEFINE_THREAD_LOCAL_FIELD_JFR;)      // Thread-local data for jfr
 343 
 344   int   _vm_operation_started_count;            // VM_Operation support
 345   int   _vm_operation_completed_count;          // VM_Operation support
 346 
 347   ObjectMonitor* _current_pending_monitor;      // ObjectMonitor this thread
 348                                                 // is waiting to lock
 349   bool _current_pending_monitor_is_from_java;   // locking is from Java code
 350 
 351   // ObjectMonitor on which this thread called Object.wait()
 352   ObjectMonitor* _current_waiting_monitor;
 353 
 354   // Private thread-local objectmonitor list - a simple cache organized as a SLL.
 355  public:
 356   ObjectMonitor* omFreeList;
 357   int omFreeCount;                              // length of omFreeList
 358   int omFreeProvision;                          // reload chunk size
 359   ObjectMonitor* omInUseList;                   // SLL to track monitors in circulation
 360   int omInUseCount;                             // length of omInUseList


 499 
 500   // Internal handle support
 501   HandleArea* handle_area() const                { return _handle_area; }
 502   void set_handle_area(HandleArea* area)         { _handle_area = area; }
 503 
 504   GrowableArray<Metadata*>* metadata_handles() const          { return _metadata_handles; }
 505   void set_metadata_handles(GrowableArray<Metadata*>* handles){ _metadata_handles = handles; }
 506 
 507   // Thread-Local Allocation Buffer (TLAB) support
 508   ThreadLocalAllocBuffer& tlab()                 { return _tlab; }
 509   void initialize_tlab() {
 510     if (UseTLAB) {
 511       tlab().initialize();
 512     }
 513   }
 514 
 515   jlong allocated_bytes()               { return _allocated_bytes; }
 516   void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
 517   void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
 518   inline jlong cooked_allocated_bytes();


 519 
 520   JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
 521 
 522   bool is_trace_suspend()               { return (_suspend_flags & _trace_flag) != 0; }
 523 
 524   // VM operation support
 525   int vm_operation_ticket()                      { return ++_vm_operation_started_count; }
 526   int vm_operation_completed_count()             { return _vm_operation_completed_count; }
 527   void increment_vm_operation_completed_count()  { _vm_operation_completed_count++; }
 528 
 529   // For tracking the heavyweight monitor the thread is pending on.
 530   ObjectMonitor* current_pending_monitor() {
 531     return _current_pending_monitor;
 532   }
 533   void set_current_pending_monitor(ObjectMonitor* monitor) {
 534     _current_pending_monitor = monitor;
 535   }
 536   void set_current_pending_monitor_is_from_java(bool from_java) {
 537     _current_pending_monitor_is_from_java = from_java;
 538   }




  25 #ifndef SHARE_VM_RUNTIME_THREAD_HPP
  26 #define SHARE_VM_RUNTIME_THREAD_HPP
  27 
  28 #include "jni.h"
  29 #include "gc/shared/gcThreadLocalData.hpp"
  30 #include "gc/shared/threadLocalAllocBuffer.hpp"
  31 #include "memory/allocation.hpp"
  32 #include "oops/oop.hpp"
  33 #include "prims/jvmtiExport.hpp"
  34 #include "runtime/frame.hpp"
  35 #include "runtime/globals.hpp"
  36 #include "runtime/handshake.hpp"
  37 #include "runtime/javaFrameAnchor.hpp"
  38 #include "runtime/jniHandles.hpp"
  39 #include "runtime/mutexLocker.hpp"
  40 #include "runtime/os.hpp"
  41 #include "runtime/osThread.hpp"
  42 #include "runtime/park.hpp"
  43 #include "runtime/safepoint.hpp"
  44 #include "runtime/stubRoutines.hpp"
  45 #include "runtime/threadHeapSampler.hpp"
  46 #include "runtime/threadLocalStorage.hpp"
  47 #include "runtime/unhandledOops.hpp"
  48 #include "utilities/align.hpp"
  49 #include "utilities/exceptions.hpp"
  50 #include "utilities/macros.hpp"
  51 #ifdef ZERO
  52 # include "stack_zero.hpp"
  53 #endif
  54 #if INCLUDE_JFR
  55 #include "jfr/support/jfrThreadExtension.hpp"
  56 #endif
  57 
  58 
  59 class SafeThreadsListPtr;
  60 class ThreadSafepointState;
  61 class ThreadsList;
  62 class ThreadsSMRSupport;
  63 
  64 class JvmtiThreadState;
  65 class JvmtiGetLoadedClassesClosure;


 322   // (Hence, !allow_safepoint() => !allow_allocation()).
 323   //
 324   // The two classes NoSafepointVerifier and No_Allocation_Verifier are used to set these counters.
 325   //
 326   NOT_PRODUCT(int _allow_safepoint_count;)      // If 0, thread allow a safepoint to happen
 327   debug_only(int _allow_allocation_count;)     // If 0, the thread is allowed to allocate oops.
 328 
 329   // Used by SkipGCALot class.
 330   NOT_PRODUCT(bool _skip_gcalot;)               // Should we elide gc-a-lot?
 331 
 332   friend class NoAllocVerifier;
 333   friend class NoSafepointVerifier;
 334   friend class PauseNoSafepointVerifier;
 335   friend class GCLocker;
 336 
 337   volatile void* _polling_page;                 // Thread local polling page
 338 
 339   ThreadLocalAllocBuffer _tlab;                 // Thread-local eden
 340   jlong _allocated_bytes;                       // Cumulative number of bytes allocated on
 341                                                 // the Java heap
 342   ThreadHeapSampler _heap_sampler;              // For use when sampling the memory.
 343 
 344   JFR_ONLY(DEFINE_THREAD_LOCAL_FIELD_JFR;)      // Thread-local data for jfr
 345 
 346   int   _vm_operation_started_count;            // VM_Operation support
 347   int   _vm_operation_completed_count;          // VM_Operation support
 348 
 349   ObjectMonitor* _current_pending_monitor;      // ObjectMonitor this thread
 350                                                 // is waiting to lock
 351   bool _current_pending_monitor_is_from_java;   // locking is from Java code
 352 
 353   // ObjectMonitor on which this thread called Object.wait()
 354   ObjectMonitor* _current_waiting_monitor;
 355 
 356   // Private thread-local objectmonitor list - a simple cache organized as a SLL.
 357  public:
 358   ObjectMonitor* omFreeList;
 359   int omFreeCount;                              // length of omFreeList
 360   int omFreeProvision;                          // reload chunk size
 361   ObjectMonitor* omInUseList;                   // SLL to track monitors in circulation
 362   int omInUseCount;                             // length of omInUseList


 501 
 502   // Internal handle support
 503   HandleArea* handle_area() const                { return _handle_area; }
 504   void set_handle_area(HandleArea* area)         { _handle_area = area; }
 505 
 506   GrowableArray<Metadata*>* metadata_handles() const          { return _metadata_handles; }
 507   void set_metadata_handles(GrowableArray<Metadata*>* handles){ _metadata_handles = handles; }
 508 
 509   // Thread-Local Allocation Buffer (TLAB) support
 510   ThreadLocalAllocBuffer& tlab()                 { return _tlab; }
 511   void initialize_tlab() {
 512     if (UseTLAB) {
 513       tlab().initialize();
 514     }
 515   }
 516 
 517   jlong allocated_bytes()               { return _allocated_bytes; }
 518   void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
 519   void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
 520   inline jlong cooked_allocated_bytes();
 521 
 522   ThreadHeapSampler& heap_sampler()     { return _heap_sampler; }
 523 
 524   JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
 525 
 526   bool is_trace_suspend()               { return (_suspend_flags & _trace_flag) != 0; }
 527 
 528   // VM operation support
 529   int vm_operation_ticket()                      { return ++_vm_operation_started_count; }
 530   int vm_operation_completed_count()             { return _vm_operation_completed_count; }
 531   void increment_vm_operation_completed_count()  { _vm_operation_completed_count++; }
 532 
 533   // For tracking the heavyweight monitor the thread is pending on.
 534   ObjectMonitor* current_pending_monitor() {
 535     return _current_pending_monitor;
 536   }
 537   void set_current_pending_monitor(ObjectMonitor* monitor) {
 538     _current_pending_monitor = monitor;
 539   }
 540   void set_current_pending_monitor_is_from_java(bool from_java) {
 541     _current_pending_monitor_is_from_java = from_java;
 542   }


< prev index next >