< prev index next >

src/hotspot/share/runtime/safepoint.cpp

Print this page
rev 47287 : Port 09.17.Thread_SMR_logging_update from JDK9 to JDK10
rev 47289 : eosterlund, stefank CR - refactor code into threadSMR.cpp and threadSMR.hpp
rev 47292 : stefank, coleenp CR - refactor most JavaThreadIterator usage to use JavaThreadIteratorWithHandle.

*** 201,214 **** // Consider using active_processor_count() ... but that call is expensive. int ncpus = os::processor_count() ; unsigned int iterations = 0; { ! ThreadsListHandle tlh; ! JavaThreadIterator jti(tlh.list()); #ifdef ASSERT ! for (JavaThread *cur = jti.first(); cur != NULL; cur = jti.next()) { assert(cur->safepoint_state()->is_running(), "Illegal initial state"); // Clear the visited flag to ensure that the critical counts are collected properly. cur->set_visited_for_critical_count(false); } #endif // ASSERT --- 201,213 ---- // Consider using active_processor_count() ... but that call is expensive. int ncpus = os::processor_count() ; unsigned int iterations = 0; { ! JavaThreadIteratorWithHandle jtiwh; #ifdef ASSERT ! for (; JavaThread *cur = jtiwh.next(); ) { assert(cur->safepoint_state()->is_running(), "Illegal initial state"); // Clear the visited flag to ensure that the critical counts are collected properly. cur->set_visited_for_critical_count(false); } #endif // ASSERT
*** 217,227 **** safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS; // Iterate through all threads until it have been determined how to stop them all at a safepoint int steps = 0 ; while(still_running > 0) { ! for (JavaThread *cur = jti.first(); cur != NULL; cur = jti.next()) { assert(!cur->is_ConcurrentGC_thread(), "A concurrent GC thread is unexpectly being suspended"); ThreadSafepointState *cur_state = cur->safepoint_state(); if (cur_state->is_running()) { cur_state->examine_state_of_thread(); if (!cur_state->is_running()) { --- 216,227 ---- safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS; // Iterate through all threads until it have been determined how to stop them all at a safepoint int steps = 0 ; while(still_running > 0) { ! jtiwh.rewind(); ! for (; JavaThread *cur = jtiwh.next(); ) { assert(!cur->is_ConcurrentGC_thread(), "A concurrent GC thread is unexpectly being suspended"); ThreadSafepointState *cur_state = cur->safepoint_state(); if (cur_state->is_running()) { cur_state->examine_state_of_thread(); if (!cur_state->is_running()) {
*** 394,411 **** wait_blocked_event.commit(); } } // EventSafepointWaitBlocked #ifdef ASSERT - { // Make sure all the threads were visited. ! ThreadsListHandle tlh; ! JavaThreadIterator jti(tlh.list()); ! for (JavaThread *cur = jti.first(); cur != NULL; cur = jti.next()) { assert(cur->was_visited_for_critical_count(), "missed a thread"); } - } #endif // ASSERT // Update the count of active JNI critical regions GCLocker::set_jni_lock_count(_current_jni_active_count); --- 394,407 ---- wait_blocked_event.commit(); } } // EventSafepointWaitBlocked #ifdef ASSERT // Make sure all the threads were visited. ! for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur = jtiwh.next(); ) { assert(cur->was_visited_for_critical_count(), "missed a thread"); } #endif // ASSERT // Update the count of active JNI critical regions GCLocker::set_jni_lock_count(_current_jni_active_count);
*** 458,474 **** if (PrintSafepointStatistics) { end_statistics(os::javaTimeNanos()); } { ! ThreadsListHandle tlh; ! JavaThreadIterator jti(tlh.list()); #ifdef ASSERT // A pending_exception cannot be installed during a safepoint. The threads // may install an async exception after they come back from a safepoint into // pending_exception after they unblock. But that should happen later. ! for (JavaThread *cur = jti.first(); cur != NULL; cur = jti.next()) { assert (!(cur->has_pending_exception() && cur->safepoint_state()->is_at_poll_safepoint()), "safepoint installed a pending exception"); } #endif // ASSERT --- 454,469 ---- if (PrintSafepointStatistics) { end_statistics(os::javaTimeNanos()); } { ! JavaThreadIteratorWithHandle jtiwh; #ifdef ASSERT // A pending_exception cannot be installed during a safepoint. The threads // may install an async exception after they come back from a safepoint into // pending_exception after they unblock. But that should happen later. ! for (; JavaThread *cur = jtiwh.next(); ) { assert (!(cur->has_pending_exception() && cur->safepoint_state()->is_at_poll_safepoint()), "safepoint installed a pending exception"); } #endif // ASSERT
*** 493,503 **** OrderAccess::fence(); log_debug(safepoint)("Leaving safepoint region"); // Start suspended threads ! for (JavaThread *current = jti.first(); current != NULL; current = jti.next()) { // A problem occurring on Solaris is when attempting to restart threads // the first #cpus - 1 go well, but then the VMThread is preempted when we get // to the next one (since it has been running the longest). We then have // to wait for a cpu to become available before we can continue restarting // threads. --- 488,499 ---- OrderAccess::fence(); log_debug(safepoint)("Leaving safepoint region"); // Start suspended threads ! jtiwh.rewind(); ! for (; JavaThread *current = jtiwh.next(); ) { // A problem occurring on Solaris is when attempting to restart threads // the first #cpus - 1 go well, but then the VMThread is preempted when we get // to the next one (since it has been running the longest). We then have // to wait for a cpu to become available before we can continue restarting // threads.
*** 907,920 **** } tty->print_cr("# SafepointSynchronize::begin: Threads which did not reach the safepoint:"); ThreadSafepointState *cur_state; ResourceMark rm; ! { ! ThreadsListHandle tlh; ! JavaThreadIterator jti(tlh.list()); ! for (JavaThread *cur_thread = jti.first(); cur_thread != NULL; cur_thread = jti.next()) { cur_state = cur_thread->safepoint_state(); if (cur_thread->thread_state() != _thread_blocked && ((reason == _spinning_timeout && cur_state->is_running()) || (reason == _blocking_timeout && !cur_state->has_called_back()))) { --- 903,913 ---- } tty->print_cr("# SafepointSynchronize::begin: Threads which did not reach the safepoint:"); ThreadSafepointState *cur_state; ResourceMark rm; ! for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) { cur_state = cur_thread->safepoint_state(); if (cur_thread->thread_state() != _thread_blocked && ((reason == _spinning_timeout && cur_state->is_running()) || (reason == _blocking_timeout && !cur_state->has_called_back()))) {
*** 921,931 **** tty->print("# "); cur_thread->print(); tty->cr(); } } - } tty->print_cr("# SafepointSynchronize::begin: (End of list)"); } // To debug the long safepoint, specify both DieOnSafepointTimeout & // ShowMessageBoxOnError. --- 914,923 ----
*** 1421,1433 **** tty->print_cr("not synchronized"); } else if (_state == _synchronizing || _state == _synchronized) { tty->print_cr("State: %s", (_state == _synchronizing) ? "synchronizing" : "synchronized"); ! ThreadsListHandle tlh; ! JavaThreadIterator jti(tlh.list()); ! for (JavaThread *cur = jti.first(); cur != NULL; cur = jti.next()) { cur->safepoint_state()->print(); } } } --- 1413,1423 ---- tty->print_cr("not synchronized"); } else if (_state == _synchronizing || _state == _synchronized) { tty->print_cr("State: %s", (_state == _synchronizing) ? "synchronizing" : "synchronized"); ! for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur = jtiwh.next(); ) { cur->safepoint_state()->print(); } } }
< prev index next >