509 static inline Thread* current();
510 // Returns the current thread, or NULL if not attached
511 static inline Thread* current_or_null();
512 // Returns the current thread, or NULL if not attached, and is
513 // safe for use from signal-handlers
514 static inline Thread* current_or_null_safe();
515
516 // Common thread operations
517 #ifdef ASSERT
518 static void check_for_dangling_thread_pointer(Thread *thread);
519 #endif
520 static void set_priority(Thread* thread, ThreadPriority priority);
521 static ThreadPriority get_priority(const Thread* const thread);
522 static void start(Thread* thread);
523
524 void set_native_thread_name(const char *name) {
525 assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
526 os::set_native_thread_name(name);
527 }
528
529 ObjectMonitor** om_in_use_list_addr() { return (ObjectMonitor **)&om_in_use_list; }
530 Monitor* SR_lock() const { return _SR_lock; }
531
532 bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
533
534 inline void set_suspend_flag(SuspendFlags f);
535 inline void clear_suspend_flag(SuspendFlags f);
536
537 inline void set_has_async_exception();
538 inline void clear_has_async_exception();
539
540 bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
541
542 inline void set_critical_native_unlock();
543 inline void clear_critical_native_unlock();
544
545 inline void set_trace_flag();
546 inline void clear_trace_flag();
547
548 // Support for Unhandled Oop detection
549 // Add the field for both, fastdebug and debug, builds to keep
608
609 jlong allocated_bytes() { return _allocated_bytes; }
610 void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
611 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
612 inline jlong cooked_allocated_bytes();
613
614 ThreadHeapSampler& heap_sampler() { return _heap_sampler; }
615
616 ThreadStatisticalInfo& statistical_info() { return _statistical_info; }
617
618 JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
619
620 bool is_trace_suspend() { return (_suspend_flags & _trace_flag) != 0; }
621
622 // VM operation support
623 int vm_operation_ticket() { return ++_vm_operation_started_count; }
624 int vm_operation_completed_count() { return _vm_operation_completed_count; }
625 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; }
626
627 // For tracking the heavyweight monitor the thread is pending on.
628 ObjectMonitor* current_pending_monitor() {
629 return _current_pending_monitor;
630 }
631 void set_current_pending_monitor(ObjectMonitor* monitor) {
632 _current_pending_monitor = monitor;
633 }
634 void set_current_pending_monitor_is_from_java(bool from_java) {
635 _current_pending_monitor_is_from_java = from_java;
636 }
637 bool current_pending_monitor_is_from_java() {
638 return _current_pending_monitor_is_from_java;
639 }
640
641 // For tracking the ObjectMonitor on which this thread called Object.wait()
642 ObjectMonitor* current_waiting_monitor() {
643 return _current_waiting_monitor;
644 }
645 void set_current_waiting_monitor(ObjectMonitor* monitor) {
646 _current_waiting_monitor = monitor;
647 }
648
649 // For tracking the Jvmti raw monitor the thread is pending on.
650 JvmtiRawMonitor* current_pending_raw_monitor() {
651 return _current_pending_raw_monitor;
652 }
653 void set_current_pending_raw_monitor(JvmtiRawMonitor* monitor) {
654 _current_pending_raw_monitor = monitor;
655 }
656
657 // GC support
658 // Apply "f->do_oop" to all root oops in "this".
659 // Used by JavaThread::oops_do.
660 // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
661 virtual void oops_do(OopClosure* f, CodeBlobClosure* cf);
662
663 // Handles the parallel case for claim_threads_do.
664 private:
665 bool claim_par_threads_do(uintx claim_token);
666 public:
|
509 static inline Thread* current();
510 // Returns the current thread, or NULL if not attached
511 static inline Thread* current_or_null();
512 // Returns the current thread, or NULL if not attached, and is
513 // safe for use from signal-handlers
514 static inline Thread* current_or_null_safe();
515
516 // Common thread operations
517 #ifdef ASSERT
518 static void check_for_dangling_thread_pointer(Thread *thread);
519 #endif
520 static void set_priority(Thread* thread, ThreadPriority priority);
521 static ThreadPriority get_priority(const Thread* const thread);
522 static void start(Thread* thread);
523
524 void set_native_thread_name(const char *name) {
525 assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
526 os::set_native_thread_name(name);
527 }
528
529 Monitor* SR_lock() const { return _SR_lock; }
530
531 bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
532
533 inline void set_suspend_flag(SuspendFlags f);
534 inline void clear_suspend_flag(SuspendFlags f);
535
536 inline void set_has_async_exception();
537 inline void clear_has_async_exception();
538
539 bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
540
541 inline void set_critical_native_unlock();
542 inline void clear_critical_native_unlock();
543
544 inline void set_trace_flag();
545 inline void clear_trace_flag();
546
547 // Support for Unhandled Oop detection
548 // Add the field for both, fastdebug and debug, builds to keep
607
608 jlong allocated_bytes() { return _allocated_bytes; }
609 void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
610 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
611 inline jlong cooked_allocated_bytes();
612
613 ThreadHeapSampler& heap_sampler() { return _heap_sampler; }
614
615 ThreadStatisticalInfo& statistical_info() { return _statistical_info; }
616
617 JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
618
619 bool is_trace_suspend() { return (_suspend_flags & _trace_flag) != 0; }
620
621 // VM operation support
622 int vm_operation_ticket() { return ++_vm_operation_started_count; }
623 int vm_operation_completed_count() { return _vm_operation_completed_count; }
624 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; }
625
626 // For tracking the heavyweight monitor the thread is pending on.
627 ObjectMonitor* current_pending_monitor(ObjectMonitorHandle* omh_p) {
628 if (omh_p->set_om_ptr_if_safe(_current_pending_monitor)) {
629 return omh_p->om_ptr(); // Return the safe ObjectMonitor*.
630 }
631 return NULL;
632 }
633 void set_current_pending_monitor(ObjectMonitor* monitor) {
634 ObjectMonitor* saved_cur = NULL;
635 if (monitor != NULL) {
636 monitor->inc_ref_count(); // Protect the ObjectMonitor* we're about to cache.
637 } else {
638 saved_cur = _current_pending_monitor;
639 }
640 _current_pending_monitor = monitor;
641 if (saved_cur != NULL) {
642 saved_cur->dec_ref_count(); // Cleared the cached ObjectMonitor*.
643 }
644 }
645 void set_current_pending_monitor_is_from_java(bool from_java) {
646 _current_pending_monitor_is_from_java = from_java;
647 }
648 bool current_pending_monitor_is_from_java() {
649 return _current_pending_monitor_is_from_java;
650 }
651
652 // For tracking the ObjectMonitor on which this thread called Object.wait()
653 ObjectMonitor* current_waiting_monitor(ObjectMonitorHandle* omh_p) {
654 if (omh_p->set_om_ptr_if_safe(_current_waiting_monitor)) {
655 return omh_p->om_ptr(); // Return the safe ObjectMonitor*.
656 }
657 return NULL;
658 }
659 void set_current_waiting_monitor(ObjectMonitor* monitor) {
660 ObjectMonitor* saved_cur = NULL;
661 if (monitor != NULL) {
662 monitor->inc_ref_count(); // Protect the ObjectMonitor* we're about to cache.
663 } else {
664 saved_cur = _current_waiting_monitor;
665 }
666 _current_waiting_monitor = monitor;
667 if (saved_cur != NULL) {
668 saved_cur->dec_ref_count(); // Cleared the cached ObjectMonitor*.
669 }
670 }
671
672 // For tracking the Jvmti raw monitor the thread is pending on.
673 JvmtiRawMonitor* current_pending_raw_monitor() {
674 return _current_pending_raw_monitor;
675 }
676 void set_current_pending_raw_monitor(JvmtiRawMonitor* monitor) {
677 _current_pending_raw_monitor = monitor;
678 }
679
680 // GC support
681 // Apply "f->do_oop" to all root oops in "this".
682 // Used by JavaThread::oops_do.
683 // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
684 virtual void oops_do(OopClosure* f, CodeBlobClosure* cf);
685
686 // Handles the parallel case for claim_threads_do.
687 private:
688 bool claim_par_threads_do(uintx claim_token);
689 public:
|