51 #include "runtime/deoptimization.hpp"
52 #include "runtime/frame.inline.hpp"
53 #include "runtime/handles.inline.hpp"
54 #include "runtime/interfaceSupport.inline.hpp"
55 #include "runtime/mutexLocker.hpp"
56 #include "runtime/orderAccess.hpp"
57 #include "runtime/osThread.hpp"
58 #include "runtime/safepoint.hpp"
59 #include "runtime/safepointMechanism.inline.hpp"
60 #include "runtime/signature.hpp"
61 #include "runtime/stubCodeGenerator.hpp"
62 #include "runtime/stubRoutines.hpp"
63 #include "runtime/sweeper.hpp"
64 #include "runtime/synchronizer.hpp"
65 #include "runtime/thread.inline.hpp"
66 #include "runtime/threadSMR.hpp"
67 #include "runtime/timerTrace.hpp"
68 #include "services/runtimeService.hpp"
69 #include "utilities/events.hpp"
70 #include "utilities/macros.hpp"
71
72 static void post_safepoint_begin_event(EventSafepointBegin& event,
73 uint64_t safepoint_id,
74 int thread_count,
75 int critical_thread_count) {
76 if (event.should_commit()) {
77 event.set_safepointId(safepoint_id);
78 event.set_totalThreadCount(thread_count);
79 event.set_jniCriticalThreadCount(critical_thread_count);
80 event.commit();
81 }
82 }
83
84 static void post_safepoint_cleanup_event(EventSafepointCleanup& event, uint64_t safepoint_id) {
85 if (event.should_commit()) {
86 event.set_safepointId(safepoint_id);
87 event.commit();
88 }
89 }
90
867 !thread->is_at_poll_safepoint() && (state != _thread_in_native_trans));
868 }
869
870 // cross_modify_fence is done by SafepointMechanism::block_if_requested_slow
871 // which is the only caller here.
872 }
873
874 // ------------------------------------------------------------------------------------------------------
875 // Exception handlers
876
877
878 void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) {
879 assert(thread->is_Java_thread(), "polling reference encountered by VM thread");
880 assert(thread->thread_state() == _thread_in_Java, "should come from Java code");
881 if (!SafepointMechanism::uses_thread_local_poll()) {
882 assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization");
883 }
884
885 if (log_is_enabled(Info, safepoint, stats)) {
886 Atomic::inc(&_nof_threads_hit_polling_page);
887 }
888
889 ThreadSafepointState* state = thread->safepoint_state();
890
891 state->handle_polling_page_exception();
892 }
893
894
895 void SafepointSynchronize::print_safepoint_timeout() {
896 if (!timeout_error_printed) {
897 timeout_error_printed = true;
898 // Print out the thread info which didn't reach the safepoint for debugging
899 // purposes (useful when there are lots of threads in the debugger).
900 LogTarget(Warning, safepoint) lt;
901 if (lt.is_enabled()) {
902 ResourceMark rm;
903 LogStream ls(lt);
904
905 ls.cr();
906 ls.print_cr("# SafepointSynchronize::begin: Timeout detected:");
|
51 #include "runtime/deoptimization.hpp"
52 #include "runtime/frame.inline.hpp"
53 #include "runtime/handles.inline.hpp"
54 #include "runtime/interfaceSupport.inline.hpp"
55 #include "runtime/mutexLocker.hpp"
56 #include "runtime/orderAccess.hpp"
57 #include "runtime/osThread.hpp"
58 #include "runtime/safepoint.hpp"
59 #include "runtime/safepointMechanism.inline.hpp"
60 #include "runtime/signature.hpp"
61 #include "runtime/stubCodeGenerator.hpp"
62 #include "runtime/stubRoutines.hpp"
63 #include "runtime/sweeper.hpp"
64 #include "runtime/synchronizer.hpp"
65 #include "runtime/thread.inline.hpp"
66 #include "runtime/threadSMR.hpp"
67 #include "runtime/timerTrace.hpp"
68 #include "services/runtimeService.hpp"
69 #include "utilities/events.hpp"
70 #include "utilities/macros.hpp"
71 #if INCLUDE_G1GC
72 #include "gc/g1/g1EpochUpdater.inline.hpp"
73 #endif // INCLUDE_G1GC
74
75
76 static void post_safepoint_begin_event(EventSafepointBegin& event,
77 uint64_t safepoint_id,
78 int thread_count,
79 int critical_thread_count) {
80 if (event.should_commit()) {
81 event.set_safepointId(safepoint_id);
82 event.set_totalThreadCount(thread_count);
83 event.set_jniCriticalThreadCount(critical_thread_count);
84 event.commit();
85 }
86 }
87
88 static void post_safepoint_cleanup_event(EventSafepointCleanup& event, uint64_t safepoint_id) {
89 if (event.should_commit()) {
90 event.set_safepointId(safepoint_id);
91 event.commit();
92 }
93 }
94
871 !thread->is_at_poll_safepoint() && (state != _thread_in_native_trans));
872 }
873
874 // cross_modify_fence is done by SafepointMechanism::block_if_requested_slow
875 // which is the only caller here.
876 }
877
878 // ------------------------------------------------------------------------------------------------------
879 // Exception handlers
880
881
882 void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) {
883 assert(thread->is_Java_thread(), "polling reference encountered by VM thread");
884 assert(thread->thread_state() == _thread_in_Java, "should come from Java code");
885 if (!SafepointMechanism::uses_thread_local_poll()) {
886 assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization");
887 }
888
889 if (log_is_enabled(Info, safepoint, stats)) {
890 Atomic::inc(&_nof_threads_hit_polling_page);
891 }
892
893 if (UseG1GC) {
894 G1EpochUpdater::update_epoch_self(thread);
895 }
896
897 ThreadSafepointState* state = thread->safepoint_state();
898
899 state->handle_polling_page_exception();
900 }
901
902
903 void SafepointSynchronize::print_safepoint_timeout() {
904 if (!timeout_error_printed) {
905 timeout_error_printed = true;
906 // Print out the thread info which didn't reach the safepoint for debugging
907 // purposes (useful when there are lots of threads in the debugger).
908 LogTarget(Warning, safepoint) lt;
909 if (lt.is_enabled()) {
910 ResourceMark rm;
911 LogStream ls(lt);
912
913 ls.cr();
914 ls.print_cr("# SafepointSynchronize::begin: Timeout detected:");
|