101 |
101 |
102 assert( _state == _not_synchronized, "trying to safepoint synchronize with wrong state"); |
102 assert( _state == _not_synchronized, "trying to safepoint synchronize with wrong state"); |
103 |
103 |
104 int nof_threads = Threads::number_of_threads(); |
104 int nof_threads = Threads::number_of_threads(); |
105 |
105 |
106 log_debug(safepoint)("Safepoint synchronization initiated. (%d)", nof_threads); |
106 log_debug(safepoint)("Safepoint synchronization initiated. (%d threads)", nof_threads); |
107 |
107 |
108 RuntimeService::record_safepoint_begin(); |
108 RuntimeService::record_safepoint_begin(); |
109 |
109 |
110 MutexLocker mu(Safepoint_lock); |
110 MutexLocker mu(Safepoint_lock); |
111 |
111 |
405 #endif // ASSERT |
405 #endif // ASSERT |
406 |
406 |
407 // Update the count of active JNI critical regions |
407 // Update the count of active JNI critical regions |
408 GCLocker::set_jni_lock_count(_current_jni_active_count); |
408 GCLocker::set_jni_lock_count(_current_jni_active_count); |
409 |
409 |
410 if (log_is_enabled(Debug, safepoint)) { |
410 log_info(safepoint)("Entering safepoint region: %s", VMThread::vm_safepoint_description()); |
411 log_debug(safepoint)("Entering safepoint region: %s", VMThread::vm_safepoint_description()); |
|
412 } |
|
413 |
411 |
414 RuntimeService::record_safepoint_synchronized(); |
412 RuntimeService::record_safepoint_synchronized(); |
415 if (PrintSafepointStatistics) { |
413 if (PrintSafepointStatistics) { |
416 update_statistics_on_sync_end(os::javaTimeNanos()); |
414 update_statistics_on_sync_end(os::javaTimeNanos()); |
417 } |
415 } |
494 for (; JavaThread *current = jtiwh.next(); ) { |
492 for (; JavaThread *current = jtiwh.next(); ) { |
495 ThreadSafepointState* cur_state = current->safepoint_state(); |
493 ThreadSafepointState* cur_state = current->safepoint_state(); |
496 cur_state->restart(); // TSS _running |
494 cur_state->restart(); // TSS _running |
497 SafepointMechanism::disarm_local_poll(current); // release store, local state -> polling page |
495 SafepointMechanism::disarm_local_poll(current); // release store, local state -> polling page |
498 } |
496 } |
499 log_debug(safepoint)("Leaving safepoint region"); |
497 log_info(safepoint)("Leaving safepoint region"); |
500 } else { |
498 } else { |
501 // Set to not synchronized, so the threads will not go into the signal_thread_blocked method |
499 // Set to not synchronized, so the threads will not go into the signal_thread_blocked method |
502 // when they get restarted. |
500 // when they get restarted. |
503 _state = _not_synchronized; |
501 _state = _not_synchronized; |
504 OrderAccess::fence(); |
502 OrderAccess::fence(); |
505 |
503 |
506 log_debug(safepoint)("Leaving safepoint region"); |
504 log_info(safepoint)("Leaving safepoint region"); |
507 |
505 |
508 // Start suspended threads |
506 // Start suspended threads |
509 jtiwh.rewind(); |
507 jtiwh.rewind(); |
510 for (; JavaThread *current = jtiwh.next(); ) { |
508 for (; JavaThread *current = jtiwh.next(); ) { |
511 // A problem occurring on Solaris is when attempting to restart threads |
509 // A problem occurring on Solaris is when attempting to restart threads |