2006 // We must flush the G1-related buffers before removing a thread
2007 // from the list of active threads. We must do this after any deferred
2008 // card marks have been flushed (above) so that any entries that are
2009 // added to the thread's dirty card queue as a result are not lost.
2010 if (UseG1GC) {
2011 flush_barrier_queues();
2012 }
2013 #endif // INCLUDE_ALL_GCS
2014
2015 log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").",
2016 exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
2017 os::current_thread_id());
2018
2019 if (log_is_enabled(Debug, os, thread, timer)) {
2020 _timer_exit_phase3.stop();
2021 _timer_exit_phase4.start();
2022 }
2023 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
2024 Threads::remove(this);
2025
2026 // If someone set a handshake on us just as we entered exit path, we simple cancel it.
2027 if (ThreadLocalHandshakes) {
2028 cancel_handshake();
2029 }
2030
2031 if (log_is_enabled(Debug, os, thread, timer)) {
2032 _timer_exit_phase4.stop();
2033 ResourceMark rm(this);
2034 log_debug(os, thread, timer)("name='%s'"
2035 ", exit-phase1=" JLONG_FORMAT
2036 ", exit-phase2=" JLONG_FORMAT
2037 ", exit-phase3=" JLONG_FORMAT
2038 ", exit-phase4=" JLONG_FORMAT,
2039 get_thread_name(),
2040 _timer_exit_phase1.milliseconds(),
2041 _timer_exit_phase2.milliseconds(),
2042 _timer_exit_phase3.milliseconds(),
2043 _timer_exit_phase4.milliseconds());
2044 }
2045 }
2046
2047 #if INCLUDE_ALL_GCS
2048 // Flush G1-related queues.
2049 void JavaThread::flush_barrier_queues() {
2050 satb_mark_queue().flush();
4813 if (EnableThreadSMRStatistics) {
4814 _smr_delete_lock_wait_cnt++;
4815 if (_smr_delete_lock_wait_cnt > _smr_delete_lock_wait_max) {
4816 _smr_delete_lock_wait_max = _smr_delete_lock_wait_cnt;
4817 }
4818 }
4819 // Wait for a release_stable_list() call before we check again. No
4820 // safepoint check, no timeout, and not as suspend equivalent flag
4821 // because this JavaThread is not on the Threads list.
4822 Threads::smr_delete_lock()->wait(Mutex::_no_safepoint_check_flag, 0,
4823 !Mutex::_as_suspend_equivalent_flag);
4824 if (EnableThreadSMRStatistics) {
4825 _smr_delete_lock_wait_cnt--;
4826 }
4827
4828 Threads::clear_smr_delete_notify();
4829 Threads::smr_delete_lock()->unlock();
4830 // Retry the whole scenario.
4831 }
4832
4833 delete thread;
4834 if (EnableThreadSMRStatistics) {
4835 timer.stop();
4836 jint millis = (jint)timer.milliseconds();
4837 Threads::inc_smr_deleted_thread_cnt();
4838 Threads::add_smr_deleted_thread_times(millis);
4839 Threads::update_smr_deleted_thread_time_max(millis);
4840 }
4841
4842 log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::smr_delete: thread=" INTPTR_FORMAT " is deleted.", os::current_thread_id(), p2i(thread));
4843 }
4844
4845 bool Threads::smr_delete_notify() {
4846 // Use load_acquire() in order to see any updates to _smr_delete_notify
4847 // earlier than when smr_delete_lock is grabbed.
4848 return (OrderAccess::load_acquire(&_smr_delete_notify) != 0);
4849 }
4850
4851 // set_smr_delete_notify() and clear_smr_delete_notify() are called
4852 // under the protection of the smr_delete_lock, but we also use an
|
2006 // We must flush the G1-related buffers before removing a thread
2007 // from the list of active threads. We must do this after any deferred
2008 // card marks have been flushed (above) so that any entries that are
2009 // added to the thread's dirty card queue as a result are not lost.
2010 if (UseG1GC) {
2011 flush_barrier_queues();
2012 }
2013 #endif // INCLUDE_ALL_GCS
2014
2015 log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").",
2016 exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
2017 os::current_thread_id());
2018
2019 if (log_is_enabled(Debug, os, thread, timer)) {
2020 _timer_exit_phase3.stop();
2021 _timer_exit_phase4.start();
2022 }
2023 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
2024 Threads::remove(this);
2025
2026 if (log_is_enabled(Debug, os, thread, timer)) {
2027 _timer_exit_phase4.stop();
2028 ResourceMark rm(this);
2029 log_debug(os, thread, timer)("name='%s'"
2030 ", exit-phase1=" JLONG_FORMAT
2031 ", exit-phase2=" JLONG_FORMAT
2032 ", exit-phase3=" JLONG_FORMAT
2033 ", exit-phase4=" JLONG_FORMAT,
2034 get_thread_name(),
2035 _timer_exit_phase1.milliseconds(),
2036 _timer_exit_phase2.milliseconds(),
2037 _timer_exit_phase3.milliseconds(),
2038 _timer_exit_phase4.milliseconds());
2039 }
2040 }
2041
2042 #if INCLUDE_ALL_GCS
2043 // Flush G1-related queues.
2044 void JavaThread::flush_barrier_queues() {
2045 satb_mark_queue().flush();
4808 if (EnableThreadSMRStatistics) {
4809 _smr_delete_lock_wait_cnt++;
4810 if (_smr_delete_lock_wait_cnt > _smr_delete_lock_wait_max) {
4811 _smr_delete_lock_wait_max = _smr_delete_lock_wait_cnt;
4812 }
4813 }
4814 // Wait for a release_stable_list() call before we check again. No
4815 // safepoint check, no timeout, and not as suspend equivalent flag
4816 // because this JavaThread is not on the Threads list.
4817 Threads::smr_delete_lock()->wait(Mutex::_no_safepoint_check_flag, 0,
4818 !Mutex::_as_suspend_equivalent_flag);
4819 if (EnableThreadSMRStatistics) {
4820 _smr_delete_lock_wait_cnt--;
4821 }
4822
4823 Threads::clear_smr_delete_notify();
4824 Threads::smr_delete_lock()->unlock();
4825 // Retry the whole scenario.
4826 }
4827
4828 // If someone set a handshake on us just as we entered exit path, we simple cancel it.
4829 if (ThreadLocalHandshakes) {
4830 thread->cancel_handshake();
4831 }
4832
4833 delete thread;
4834 if (EnableThreadSMRStatistics) {
4835 timer.stop();
4836 jint millis = (jint)timer.milliseconds();
4837 Threads::inc_smr_deleted_thread_cnt();
4838 Threads::add_smr_deleted_thread_times(millis);
4839 Threads::update_smr_deleted_thread_time_max(millis);
4840 }
4841
4842 log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::smr_delete: thread=" INTPTR_FORMAT " is deleted.", os::current_thread_id(), p2i(thread));
4843 }
4844
4845 bool Threads::smr_delete_notify() {
4846 // Use load_acquire() in order to see any updates to _smr_delete_notify
4847 // earlier than when smr_delete_lock is grabbed.
4848 return (OrderAccess::load_acquire(&_smr_delete_notify) != 0);
4849 }
4850
4851 // set_smr_delete_notify() and clear_smr_delete_notify() are called
4852 // under the protection of the smr_delete_lock, but we also use an
|