< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page

 44 #endif
 45 
 46 class CompilerThread;
 47 class HandleArea;
 48 class HandleMark;
 49 class ICRefillVerifier;
 50 class JvmtiRawMonitor;
 51 class Metadata;
 52 class OSThread;
 53 class ParkEvent;
 54 class ResourceArea;
 55 class SafeThreadsListPtr;
 56 class ThreadClosure;
 57 class ThreadsList;
 58 class ThreadsSMRSupport;
 59 class VMErrorCallback;
 60 
 61 class OopClosure;
 62 class CodeBlobClosure;
 63 


 64 DEBUG_ONLY(class ResourceMark;)
 65 
 66 class WorkerThread;
 67 
 68 class JavaThread;
 69 
 70 // Class hierarchy
 71 // - Thread
 72 //   - JavaThread
 73 //     - various subclasses eg CompilerThread, ServiceThread
 74 //   - NonJavaThread
 75 //     - NamedThread
 76 //       - VMThread
 77 //       - ConcurrentGCThread
 78 //       - WorkerThread
 79 //     - WatcherThread
 80 //     - JfrThreadSampler
 81 //     - LogAsyncWriter
 82 //
 83 // All Thread subclasses must be either JavaThread or NonJavaThread.

635   void init_wx();
636   WXMode enable_wx(WXMode new_state);
637 
638   void assert_wx_state(WXMode expected) {
639     assert(_wx_state == expected, "wrong state");
640   }
641 #endif // __APPLE__ && AARCH64
642 
643  private:
644   bool _in_asgct = false;
645  public:
646   bool in_asgct() const { return _in_asgct; }
647   void set_in_asgct(bool value) { _in_asgct = value; }
648   static bool current_in_asgct() {
649     Thread *cur = Thread::current_or_null_safe();
650     return cur != nullptr && cur->in_asgct();
651   }
652 
653  private:
654   VMErrorCallback* _vm_error_callbacks;


































































































655 };
656 
657 class ThreadInAsgct {
658  private:
659   Thread* _thread;
660  public:
661   ThreadInAsgct(Thread* thread) : _thread(thread) {
662     assert(thread != nullptr, "invariant");
663     assert(!thread->in_asgct(), "invariant");
664     thread->set_in_asgct(true);
665   }
666   ~ThreadInAsgct() {
667     assert(_thread->in_asgct(), "invariant");
668     _thread->set_in_asgct(false);
669   }
670 };
671 
672 // Inline implementation of Thread::current()
673 inline Thread* Thread::current() {
674   Thread* current = current_or_null();

 44 #endif
 45 
 46 class CompilerThread;
 47 class HandleArea;
 48 class HandleMark;
 49 class ICRefillVerifier;
 50 class JvmtiRawMonitor;
 51 class Metadata;
 52 class OSThread;
 53 class ParkEvent;
 54 class ResourceArea;
 55 class SafeThreadsListPtr;
 56 class ThreadClosure;
 57 class ThreadsList;
 58 class ThreadsSMRSupport;
 59 class VMErrorCallback;
 60 
 61 class OopClosure;
 62 class CodeBlobClosure;
 63 
 64 class PerfTraceTime;
 65 
 66 DEBUG_ONLY(class ResourceMark;)
 67 
 68 class WorkerThread;
 69 
 70 class JavaThread;
 71 
 72 // Class hierarchy
 73 // - Thread
 74 //   - JavaThread
 75 //     - various subclasses eg CompilerThread, ServiceThread
 76 //   - NonJavaThread
 77 //     - NamedThread
 78 //       - VMThread
 79 //       - ConcurrentGCThread
 80 //       - WorkerThread
 81 //     - WatcherThread
 82 //     - JfrThreadSampler
 83 //     - LogAsyncWriter
 84 //
 85 // All Thread subclasses must be either JavaThread or NonJavaThread.

637   void init_wx();
638   WXMode enable_wx(WXMode new_state);
639 
640   void assert_wx_state(WXMode expected) {
641     assert(_wx_state == expected, "wrong state");
642   }
643 #endif // __APPLE__ && AARCH64
644 
645  private:
646   bool _in_asgct = false;
647  public:
648   bool in_asgct() const { return _in_asgct; }
649   void set_in_asgct(bool value) { _in_asgct = value; }
650   static bool current_in_asgct() {
651     Thread *cur = Thread::current_or_null_safe();
652     return cur != nullptr && cur->in_asgct();
653   }
654 
655  private:
656   VMErrorCallback* _vm_error_callbacks;
657 
658   bool  _profile_vm_locks;
659   bool  _profile_vm_calls;
660   bool  _profile_vm_ops;
661   bool  _profile_rt_calls;
662   bool  _profile_upcalls;
663 
664   jlong    _all_bc_counter_value;
665   jlong _clinit_bc_counter_value;
666 
667   PerfTraceTime* _current_rt_call_timer;
668  public:
669   bool     profile_vm_locks() const { return _profile_vm_locks; }
670   void set_profile_vm_locks(bool v) { _profile_vm_locks = v; }
671 
672   bool     profile_vm_calls() const { return _profile_vm_calls; }
673   void set_profile_vm_calls(bool v) { _profile_vm_calls = v; }
674 
675   bool     profile_vm_ops() const { return _profile_vm_ops; }
676   void set_profile_vm_ops(bool v) { _profile_vm_ops = v; }
677 
678   bool     profile_rt_calls() const { return _profile_rt_calls; }
679   void set_profile_rt_calls(bool v) { _profile_rt_calls = v; }
680 
681   bool     profile_upcalls() const { return _profile_upcalls; }
682   void set_profile_upcalls(bool v) { _profile_upcalls = v; }
683 
684   PerfTraceTime*     current_rt_call_timer() const           { return _current_rt_call_timer;            }
685   void           set_current_rt_call_timer(PerfTraceTime* c) {        _current_rt_call_timer = c;        }
686   bool           has_current_rt_call_timer() const           { return _current_rt_call_timer != nullptr; }
687 
688   bool do_profile_rt_call() const {
689     return ProfileRuntimeCalls && profile_rt_calls() && !has_current_rt_call_timer();
690   }
691 
692   jlong        bc_counter_value() const { return    _all_bc_counter_value; }
693 
694   jlong clinit_bc_counter_value() const { return _clinit_bc_counter_value; }
695 
696   void inc_clinit_bc_counter_value(jlong l) { _clinit_bc_counter_value += l; }
697 
698   static ByteSize bc_counter_offset() { return byte_offset_of(Thread, _all_bc_counter_value); }
699 };
700 
701 class ProfileVMCallContext : StackObj {
702  private:
703   Thread* _thread;
704   bool _enabled;
705   PerfTraceTime* _timer;
706 
707   static int _perf_nested_runtime_calls_count;
708 
709   static const char* name(PerfTraceTime* t);
710   static void notify_nested_rt_call(PerfTraceTime* current, PerfTraceTime* inner_timer);
711  public:
712   inline ProfileVMCallContext(Thread* current, PerfTraceTime* timer, bool is_on)
713   : _thread(current), _enabled(is_on), _timer(timer) {
714     if (_enabled) {
715       assert(timer != nullptr, "");
716       assert(_thread->current_rt_call_timer() == nullptr, "%s", name(_thread->current_rt_call_timer()));
717       _thread->set_current_rt_call_timer(timer);
718     } else if (current->profile_rt_calls()) {
719       notify_nested_rt_call(current->current_rt_call_timer(), timer);
720     }
721   }
722 
723   inline ~ProfileVMCallContext() {
724     if (_enabled) {
725       assert(_timer == _thread->current_rt_call_timer(),
726              "%s vs %s", name(_timer), name(_thread->current_rt_call_timer()));
727       _thread->set_current_rt_call_timer(nullptr);
728     }
729   }
730 
731   static int nested_runtime_calls_count() { return _perf_nested_runtime_calls_count; };
732 };
733 
734 class PauseRuntimeCallProfiling : public StackObj {
735  protected:
736   Thread* _thread;
737   bool _enabled;
738   PerfTraceTime* _timer;
739 
740  public:
741   inline PauseRuntimeCallProfiling(Thread* current, bool is_on)
742   : _thread(current), _enabled(is_on), _timer(nullptr) {
743     if (_enabled) {
744       _timer = _thread->current_rt_call_timer();
745       _thread->set_current_rt_call_timer(nullptr);
746     }
747   }
748 
749   inline ~PauseRuntimeCallProfiling () {
750     if (_enabled) {
751       guarantee(_thread->current_rt_call_timer() == nullptr, "");
752       _thread->set_current_rt_call_timer(_timer); // restore
753     }
754   }
755 };
756 
757 class ThreadInAsgct {
758  private:
759   Thread* _thread;
760  public:
761   ThreadInAsgct(Thread* thread) : _thread(thread) {
762     assert(thread != nullptr, "invariant");
763     assert(!thread->in_asgct(), "invariant");
764     thread->set_in_asgct(true);
765   }
766   ~ThreadInAsgct() {
767     assert(_thread->in_asgct(), "invariant");
768     _thread->set_in_asgct(false);
769   }
770 };
771 
772 // Inline implementation of Thread::current()
773 inline Thread* Thread::current() {
774   Thread* current = current_or_null();
< prev index next >