< prev index next >

src/hotspot/share/runtime/safepoint.cpp

Print this page
rev 47819 : imported patch 10.07.open.rebase_20171110.dcubed
rev 47820 : imported patch 10.08.open.rebase_20171114.rehn


 158   //  3. Running compiled Code
 159   //     Compiled code reads a global (Safepoint Polling) page that
 160   //     is set to fault if we are trying to get to a safepoint.
 161   //  4. Blocked
 162   //     A thread which is blocked will not be allowed to return from the
 163   //     block condition until the safepoint operation is complete.
 164   //  5. In VM or Transitioning between states
 165   //     If a Java thread is currently running in the VM or transitioning
 166   //     between states, the safepointing code will wait for the thread to
 167   //     block itself when it attempts transitions to a new state.
 168   //
 169   {
 170     EventSafepointStateSynchronization sync_event;
 171     int initial_running = 0;
 172 
 173     _state            = _synchronizing;
 174 
 175     if (SafepointMechanism::uses_thread_local_poll()) {
 176       // Arming the per thread poll while having _state != _not_synchronized means safepointing
 177       log_trace(safepoint)("Setting thread local yield flag for threads");
 178       for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) {
 179         // Make sure the threads start polling, it is time to yield.
 180         SafepointMechanism::arm_local_poll(cur); // release store, global state -> local state
 181       }
 182     }
 183     OrderAccess::fence(); // storestore|storeload, global state -> local state
 184 
 185     // Flush all thread states to memory
 186     if (!UseMembar) {
 187       os::serialize_thread_states();
 188     }
 189 
 190     if (SafepointMechanism::uses_global_page_poll()) {
 191       // Make interpreter safepoint aware
 192       Interpreter::notice_safepoints();
 193 
 194       if (DeferPollingPageLoopCount < 0) {
 195         // Make polling safepoint aware
 196         guarantee (PageArmed == 0, "invariant") ;
 197         PageArmed = 1 ;
 198         os::make_polling_page_unreadable();
 199       }
 200     }
 201 
 202     // Consider using active_processor_count() ... but that call is expensive.
 203     int ncpus = os::processor_count() ;

 204 


 205 #ifdef ASSERT
 206     for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) {
 207       assert(cur->safepoint_state()->is_running(), "Illegal initial state");
 208       // Clear the visited flag to ensure that the critical counts are collected properly.
 209       cur->set_visited_for_critical_count(false);
 210     }
 211 #endif // ASSERT
 212 
 213     if (SafepointTimeout)
 214       safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS;
 215 
 216     // Iterate through all threads until it have been determined how to stop them all at a safepoint
 217     unsigned int iterations = 0;
 218     int steps = 0 ;
 219     while(still_running > 0) {
 220       for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) {

 221         assert(!cur->is_ConcurrentGC_thread(), "A concurrent GC thread is unexpectly being suspended");
 222         ThreadSafepointState *cur_state = cur->safepoint_state();
 223         if (cur_state->is_running()) {
 224           cur_state->examine_state_of_thread();
 225           if (!cur_state->is_running()) {
 226             still_running--;
 227             // consider adjusting steps downward:
 228             //   steps = 0
 229             //   steps -= NNN
 230             //   steps >>= 1
 231             //   steps = MIN(steps, 2000-100)
 232             //   if (iterations != 0) steps -= NNN
 233           }
 234           LogTarget(Trace, safepoint) lt;
 235           if (lt.is_enabled()) {
 236             ResourceMark rm;
 237             LogStream ls(lt);
 238             cur_state->print_on(&ls);
 239           }
 240         }


 311           PageArmed = 1 ;
 312           os::make_polling_page_unreadable();
 313         }
 314 
 315         // Instead of (ncpus > 1) consider either (still_running < (ncpus + EPSILON)) or
 316         // ((still_running + _waiting_to_block - TryingToBlock)) < ncpus)
 317         ++steps ;
 318         if (ncpus > 1 && steps < SafepointSpinBeforeYield) {
 319           SpinPause() ;     // MP-Polite spin
 320         } else
 321           if (steps < DeferThrSuspendLoopCount) {
 322             os::naked_yield() ;
 323           } else {
 324             os::naked_short_sleep(1);
 325           }
 326 
 327         iterations ++ ;
 328       }
 329       assert(iterations < (uint)max_jint, "We have been iterating in the safepoint loop too long");
 330     }

 331     assert(still_running == 0, "sanity check");
 332 
 333     if (PrintSafepointStatistics) {
 334       update_statistics_on_spin_end();
 335     }
 336 
 337     if (sync_event.should_commit()) {
 338       // Group this event together with the ones committed after the counter is increased
 339       sync_event.set_safepointId(safepoint_counter() + 1);
 340       sync_event.set_initialThreadCount(initial_running);
 341       sync_event.set_runningThreadCount(_waiting_to_block);
 342       sync_event.set_iterations(iterations);
 343       sync_event.commit();
 344     }
 345   } // EventSafepointStateSynchronization destroyed here.
 346 
 347   // wait until all threads are stopped
 348   {
 349     EventSafepointWaitBlocked wait_blocked_event;
 350     int initial_waiting_to_block = _waiting_to_block;


 436 
 437 // Wake up all threads, so they are ready to resume execution after the safepoint
 438 // operation has been carried out
 439 void SafepointSynchronize::end() {
 440   EventSafepointEnd event;
 441   int safepoint_id = safepoint_counter(); // Keep the odd counter as "id"
 442 
 443   assert(Threads_lock->owned_by_self(), "must hold Threads_lock");
 444   assert((_safepoint_counter & 0x1) == 1, "must be odd");
 445   _safepoint_counter ++;
 446   // memory fence isn't required here since an odd _safepoint_counter
 447   // value can do no harm and a fence is issued below anyway.
 448 
 449   DEBUG_ONLY(Thread* myThread = Thread::current();)
 450   assert(myThread->is_VM_thread(), "Only VM thread can execute a safepoint");
 451 
 452   if (PrintSafepointStatistics) {
 453     end_statistics(os::javaTimeNanos());
 454   }
 455 


 456 #ifdef ASSERT
 457   // A pending_exception cannot be installed during a safepoint.  The threads
 458   // may install an async exception after they come back from a safepoint into
 459   // pending_exception after they unblock.  But that should happen later.
 460   for (JavaThread *cur = Threads::first(); cur; cur = cur->next()) {
 461     assert (!(cur->has_pending_exception() &&
 462               cur->safepoint_state()->is_at_poll_safepoint()),
 463             "safepoint installed a pending exception");
 464   }
 465 #endif // ASSERT
 466 
 467   if (PageArmed) {
 468     assert(SafepointMechanism::uses_global_page_poll(), "sanity");
 469     // Make polling safepoint aware
 470     os::make_polling_page_readable();
 471     PageArmed = 0 ;
 472   }
 473 
 474   if (SafepointMechanism::uses_global_page_poll()) {
 475     // Remove safepoint check from interpreter
 476     Interpreter::ignore_safepoints();
 477   }
 478 
 479   {
 480     MutexLocker mu(Safepoint_lock);
 481 
 482     assert(_state == _synchronized, "must be synchronized before ending safepoint synchronization");
 483 
 484     if (SafepointMechanism::uses_thread_local_poll()) {
 485       _state = _not_synchronized;
 486       OrderAccess::storestore(); // global state -> local state
 487       for (JavaThread *current = Threads::first(); current; current = current->next()) {

 488         ThreadSafepointState* cur_state = current->safepoint_state();
 489         cur_state->restart(); // TSS _running
 490         SafepointMechanism::disarm_local_poll(current); // release store, local state -> polling page
 491       }
 492       log_debug(safepoint)("Leaving safepoint region");
 493     } else {
 494       // Set to not synchronized, so the threads will not go into the signal_thread_blocked method
 495       // when they get restarted.
 496       _state = _not_synchronized;
 497       OrderAccess::fence();
 498 
 499       log_debug(safepoint)("Leaving safepoint region");
 500 
 501       // Start suspended threads
 502       for (JavaThread *current = Threads::first(); current; current = current->next()) {

 503         // A problem occurring on Solaris is when attempting to restart threads
 504         // the first #cpus - 1 go well, but then the VMThread is preempted when we get
 505         // to the next one (since it has been running the longest).  We then have
 506         // to wait for a cpu to become available before we can continue restarting
 507         // threads.
 508         // FIXME: This causes the performance of the VM to degrade when active and with
 509         // large numbers of threads.  Apparently this is due to the synchronous nature
 510         // of suspending threads.
 511         //
 512         // TODO-FIXME: the comments above are vestigial and no longer apply.
 513         // Furthermore, using solaris' schedctl in this particular context confers no benefit
 514         if (VMThreadHintNoPreempt) {
 515           os::hint_no_preempt();
 516         }
 517         ThreadSafepointState* cur_state = current->safepoint_state();
 518         assert(cur_state->type() != ThreadSafepointState::_running, "Thread not suspended at safepoint");
 519         cur_state->restart();
 520         assert(cur_state->is_running(), "safepoint state has not been reset");
 521       }
 522     }
 523 
 524     RuntimeService::record_safepoint_end();
 525 
 526     // Release threads lock, so threads can be created/destroyed again. It will also starts all threads
 527     // blocked in signal_thread_blocked
 528     Threads_lock->unlock();
 529 
 530   }


 531   Universe::heap()->safepoint_synchronize_end();
 532   // record this time so VMThread can keep track how much time has elapsed
 533   // since last safepoint.
 534   _end_of_last_safepoint = os::javaTimeMillis();
 535 
 536   if (event.should_commit()) {
 537     event.set_safepointId(safepoint_id);
 538     event.commit();
 539   }
 540 }
 541 
 542 bool SafepointSynchronize::is_cleanup_needed() {
 543   // Need a safepoint if there are many monitors to deflate.
 544   if (ObjectSynchronizer::is_cleanup_needed()) return true;
 545   // Need a safepoint if some inline cache buffers is non-empty
 546   if (!InlineCacheBuffer::is_empty()) return true;
 547   return false;
 548 }
 549 
 550 static void event_safepoint_cleanup_task_commit(EventSafepointCleanupTask& event, const char* name) {


 899   state->handle_polling_page_exception();
 900 }
 901 
 902 
 903 void SafepointSynchronize::print_safepoint_timeout(SafepointTimeoutReason reason) {
 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     tty->cr();
 909     tty->print_cr("# SafepointSynchronize::begin: Timeout detected:");
 910     if (reason ==  _spinning_timeout) {
 911       tty->print_cr("# SafepointSynchronize::begin: Timed out while spinning to reach a safepoint.");
 912     } else if (reason == _blocking_timeout) {
 913       tty->print_cr("# SafepointSynchronize::begin: Timed out while waiting for threads to stop.");
 914     }
 915 
 916     tty->print_cr("# SafepointSynchronize::begin: Threads which did not reach the safepoint:");
 917     ThreadSafepointState *cur_state;
 918     ResourceMark rm;
 919     for (JavaThread *cur_thread = Threads::first(); cur_thread;
 920         cur_thread = cur_thread->next()) {
 921       cur_state = cur_thread->safepoint_state();
 922 
 923       if (cur_thread->thread_state() != _thread_blocked &&
 924           ((reason == _spinning_timeout && cur_state->is_running()) ||
 925            (reason == _blocking_timeout && !cur_state->has_called_back()))) {
 926         tty->print("# ");
 927         cur_thread->print();
 928         tty->cr();
 929       }
 930     }
 931     tty->print_cr("# SafepointSynchronize::begin: (End of list)");
 932   }
 933 
 934   // To debug the long safepoint, specify both DieOnSafepointTimeout &
 935   // ShowMessageBoxOnError.
 936   if (DieOnSafepointTimeout) {
 937     fatal("Safepoint sync time longer than " INTX_FORMAT "ms detected when executing %s.",
 938           SafepointTimeoutDelay, VMThread::vm_safepoint_description());
 939   }
 940 }


1411                 _coalesced_vmop_count);
1412   tty->print_cr("Maximum sync time  " INT64_FORMAT_W(5) " ms",
1413                 (int64_t)(_max_sync_time / MICROUNITS));
1414   tty->print_cr("Maximum vm operation time (except for Exit VM operation)  "
1415                 INT64_FORMAT_W(5) " ms",
1416                 (int64_t)(_max_vmop_time / MICROUNITS));
1417 }
1418 
1419 // ------------------------------------------------------------------------------------------------
1420 // Non-product code
1421 
1422 #ifndef PRODUCT
1423 
1424 void SafepointSynchronize::print_state() {
1425   if (_state == _not_synchronized) {
1426     tty->print_cr("not synchronized");
1427   } else if (_state == _synchronizing || _state == _synchronized) {
1428     tty->print_cr("State: %s", (_state == _synchronizing) ? "synchronizing" :
1429                   "synchronized");
1430 
1431     for (JavaThread *cur = Threads::first(); cur; cur = cur->next()) {
1432        cur->safepoint_state()->print();
1433     }
1434   }
1435 }
1436 
1437 void SafepointSynchronize::safepoint_msg(const char* format, ...) {
1438   if (ShowSafepointMsgs) {
1439     va_list ap;
1440     va_start(ap, format);
1441     tty->vprint_cr(format, ap);
1442     va_end(ap);
1443   }
1444 }
1445 
1446 #endif // !PRODUCT


 158   //  3. Running compiled Code
 159   //     Compiled code reads a global (Safepoint Polling) page that
 160   //     is set to fault if we are trying to get to a safepoint.
 161   //  4. Blocked
 162   //     A thread which is blocked will not be allowed to return from the
 163   //     block condition until the safepoint operation is complete.
 164   //  5. In VM or Transitioning between states
 165   //     If a Java thread is currently running in the VM or transitioning
 166   //     between states, the safepointing code will wait for the thread to
 167   //     block itself when it attempts transitions to a new state.
 168   //
 169   {
 170     EventSafepointStateSynchronization sync_event;
 171     int initial_running = 0;
 172 
 173     _state            = _synchronizing;
 174 
 175     if (SafepointMechanism::uses_thread_local_poll()) {
 176       // Arming the per thread poll while having _state != _not_synchronized means safepointing
 177       log_trace(safepoint)("Setting thread local yield flag for threads");
 178       for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur = jtiwh.next(); ) {
 179         // Make sure the threads start polling, it is time to yield.
 180         SafepointMechanism::arm_local_poll(cur); // release store, global state -> local state
 181       }
 182     }
 183     OrderAccess::fence(); // storestore|storeload, global state -> local state
 184 
 185     // Flush all thread states to memory
 186     if (!UseMembar) {
 187       os::serialize_thread_states();
 188     }
 189 
 190     if (SafepointMechanism::uses_global_page_poll()) {
 191       // Make interpreter safepoint aware
 192       Interpreter::notice_safepoints();
 193 
 194       if (DeferPollingPageLoopCount < 0) {
 195         // Make polling safepoint aware
 196         guarantee (PageArmed == 0, "invariant") ;
 197         PageArmed = 1 ;
 198         os::make_polling_page_unreadable();
 199       }
 200     }
 201 
 202     // Consider using active_processor_count() ... but that call is expensive.
 203     int ncpus = os::processor_count() ;
 204     unsigned int iterations = 0;
 205 
 206     {
 207       JavaThreadIteratorWithHandle jtiwh;
 208 #ifdef ASSERT
 209       for (; JavaThread *cur = jtiwh.next(); ) {
 210         assert(cur->safepoint_state()->is_running(), "Illegal initial state");
 211         // Clear the visited flag to ensure that the critical counts are collected properly.
 212         cur->set_visited_for_critical_count(false);
 213       }
 214 #endif // ASSERT
 215 
 216       if (SafepointTimeout)
 217         safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS;
 218 
 219       // Iterate through all threads until it have been determined how to stop them all at a safepoint

 220       int steps = 0 ;
 221       while(still_running > 0) {
 222         jtiwh.rewind();
 223         for (; JavaThread *cur = jtiwh.next(); ) {
 224           assert(!cur->is_ConcurrentGC_thread(), "A concurrent GC thread is unexpectly being suspended");
 225           ThreadSafepointState *cur_state = cur->safepoint_state();
 226           if (cur_state->is_running()) {
 227             cur_state->examine_state_of_thread();
 228             if (!cur_state->is_running()) {
 229               still_running--;
 230               // consider adjusting steps downward:
 231               //   steps = 0
 232               //   steps -= NNN
 233               //   steps >>= 1
 234               //   steps = MIN(steps, 2000-100)
 235               //   if (iterations != 0) steps -= NNN
 236             }
 237             LogTarget(Trace, safepoint) lt;
 238             if (lt.is_enabled()) {
 239               ResourceMark rm;
 240               LogStream ls(lt);
 241               cur_state->print_on(&ls);
 242             }
 243           }


 314             PageArmed = 1 ;
 315             os::make_polling_page_unreadable();
 316           }
 317 
 318           // Instead of (ncpus > 1) consider either (still_running < (ncpus + EPSILON)) or
 319           // ((still_running + _waiting_to_block - TryingToBlock)) < ncpus)
 320           ++steps ;
 321           if (ncpus > 1 && steps < SafepointSpinBeforeYield) {
 322             SpinPause() ;     // MP-Polite spin
 323           } else
 324             if (steps < DeferThrSuspendLoopCount) {
 325               os::naked_yield() ;
 326             } else {
 327               os::naked_short_sleep(1);
 328             }
 329 
 330           iterations ++ ;
 331         }
 332         assert(iterations < (uint)max_jint, "We have been iterating in the safepoint loop too long");
 333       }
 334     } // ThreadsListHandle destroyed here.
 335     assert(still_running == 0, "sanity check");
 336 
 337     if (PrintSafepointStatistics) {
 338       update_statistics_on_spin_end();
 339     }
 340 
 341     if (sync_event.should_commit()) {
 342       // Group this event together with the ones committed after the counter is increased
 343       sync_event.set_safepointId(safepoint_counter() + 1);
 344       sync_event.set_initialThreadCount(initial_running);
 345       sync_event.set_runningThreadCount(_waiting_to_block);
 346       sync_event.set_iterations(iterations);
 347       sync_event.commit();
 348     }
 349   } // EventSafepointStateSynchronization destroyed here.
 350 
 351   // wait until all threads are stopped
 352   {
 353     EventSafepointWaitBlocked wait_blocked_event;
 354     int initial_waiting_to_block = _waiting_to_block;


 440 
 441 // Wake up all threads, so they are ready to resume execution after the safepoint
 442 // operation has been carried out
 443 void SafepointSynchronize::end() {
 444   EventSafepointEnd event;
 445   int safepoint_id = safepoint_counter(); // Keep the odd counter as "id"
 446 
 447   assert(Threads_lock->owned_by_self(), "must hold Threads_lock");
 448   assert((_safepoint_counter & 0x1) == 1, "must be odd");
 449   _safepoint_counter ++;
 450   // memory fence isn't required here since an odd _safepoint_counter
 451   // value can do no harm and a fence is issued below anyway.
 452 
 453   DEBUG_ONLY(Thread* myThread = Thread::current();)
 454   assert(myThread->is_VM_thread(), "Only VM thread can execute a safepoint");
 455 
 456   if (PrintSafepointStatistics) {
 457     end_statistics(os::javaTimeNanos());
 458   }
 459 
 460   {
 461     JavaThreadIteratorWithHandle jtiwh;
 462 #ifdef ASSERT
 463     // A pending_exception cannot be installed during a safepoint.  The threads
 464     // may install an async exception after they come back from a safepoint into
 465     // pending_exception after they unblock.  But that should happen later.
 466     for (; JavaThread *cur = jtiwh.next(); ) {
 467       assert (!(cur->has_pending_exception() &&
 468                 cur->safepoint_state()->is_at_poll_safepoint()),
 469               "safepoint installed a pending exception");
 470     }
 471 #endif // ASSERT
 472 
 473     if (PageArmed) {
 474       assert(SafepointMechanism::uses_global_page_poll(), "sanity");
 475       // Make polling safepoint aware
 476       os::make_polling_page_readable();
 477       PageArmed = 0 ;
 478     }
 479 
 480     if (SafepointMechanism::uses_global_page_poll()) {
 481       // Remove safepoint check from interpreter
 482       Interpreter::ignore_safepoints();
 483     }
 484 
 485     {
 486       MutexLocker mu(Safepoint_lock);
 487 
 488       assert(_state == _synchronized, "must be synchronized before ending safepoint synchronization");
 489 
 490       if (SafepointMechanism::uses_thread_local_poll()) {
 491         _state = _not_synchronized;
 492         OrderAccess::storestore(); // global state -> local state
 493         jtiwh.rewind();
 494         for (; JavaThread *current = jtiwh.next(); ) {
 495           ThreadSafepointState* cur_state = current->safepoint_state();
 496           cur_state->restart(); // TSS _running
 497           SafepointMechanism::disarm_local_poll(current); // release store, local state -> polling page
 498         }
 499         log_debug(safepoint)("Leaving safepoint region");
 500       } else {
 501         // Set to not synchronized, so the threads will not go into the signal_thread_blocked method
 502         // when they get restarted.
 503         _state = _not_synchronized;
 504         OrderAccess::fence();
 505 
 506         log_debug(safepoint)("Leaving safepoint region");
 507 
 508         // Start suspended threads
 509         jtiwh.rewind();
 510         for (; JavaThread *current = jtiwh.next(); ) {
 511           // A problem occurring on Solaris is when attempting to restart threads
 512           // the first #cpus - 1 go well, but then the VMThread is preempted when we get
 513           // to the next one (since it has been running the longest).  We then have
 514           // to wait for a cpu to become available before we can continue restarting
 515           // threads.
 516           // FIXME: This causes the performance of the VM to degrade when active and with
 517           // large numbers of threads.  Apparently this is due to the synchronous nature
 518           // of suspending threads.
 519           //
 520           // TODO-FIXME: the comments above are vestigial and no longer apply.
 521           // Furthermore, using solaris' schedctl in this particular context confers no benefit
 522           if (VMThreadHintNoPreempt) {
 523             os::hint_no_preempt();
 524           }
 525           ThreadSafepointState* cur_state = current->safepoint_state();
 526           assert(cur_state->type() != ThreadSafepointState::_running, "Thread not suspended at safepoint");
 527           cur_state->restart();
 528           assert(cur_state->is_running(), "safepoint state has not been reset");
 529         }
 530       }
 531 
 532       RuntimeService::record_safepoint_end();
 533 
 534       // Release threads lock, so threads can be created/destroyed again.
 535       // It will also release all threads blocked in signal_thread_blocked.
 536       Threads_lock->unlock();

 537     }
 538   } // ThreadsListHandle destroyed here.
 539 
 540   Universe::heap()->safepoint_synchronize_end();
 541   // record this time so VMThread can keep track how much time has elapsed
 542   // since last safepoint.
 543   _end_of_last_safepoint = os::javaTimeMillis();
 544 
 545   if (event.should_commit()) {
 546     event.set_safepointId(safepoint_id);
 547     event.commit();
 548   }
 549 }
 550 
 551 bool SafepointSynchronize::is_cleanup_needed() {
 552   // Need a safepoint if there are many monitors to deflate.
 553   if (ObjectSynchronizer::is_cleanup_needed()) return true;
 554   // Need a safepoint if some inline cache buffers is non-empty
 555   if (!InlineCacheBuffer::is_empty()) return true;
 556   return false;
 557 }
 558 
 559 static void event_safepoint_cleanup_task_commit(EventSafepointCleanupTask& event, const char* name) {


 908   state->handle_polling_page_exception();
 909 }
 910 
 911 
 912 void SafepointSynchronize::print_safepoint_timeout(SafepointTimeoutReason reason) {
 913   if (!timeout_error_printed) {
 914     timeout_error_printed = true;
 915     // Print out the thread info which didn't reach the safepoint for debugging
 916     // purposes (useful when there are lots of threads in the debugger).
 917     tty->cr();
 918     tty->print_cr("# SafepointSynchronize::begin: Timeout detected:");
 919     if (reason ==  _spinning_timeout) {
 920       tty->print_cr("# SafepointSynchronize::begin: Timed out while spinning to reach a safepoint.");
 921     } else if (reason == _blocking_timeout) {
 922       tty->print_cr("# SafepointSynchronize::begin: Timed out while waiting for threads to stop.");
 923     }
 924 
 925     tty->print_cr("# SafepointSynchronize::begin: Threads which did not reach the safepoint:");
 926     ThreadSafepointState *cur_state;
 927     ResourceMark rm;
 928     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) {

 929       cur_state = cur_thread->safepoint_state();
 930 
 931       if (cur_thread->thread_state() != _thread_blocked &&
 932         ((reason == _spinning_timeout && cur_state->is_running()) ||
 933            (reason == _blocking_timeout && !cur_state->has_called_back()))) {
 934         tty->print("# ");
 935         cur_thread->print();
 936         tty->cr();
 937       }
 938     }
 939     tty->print_cr("# SafepointSynchronize::begin: (End of list)");
 940   }
 941 
 942   // To debug the long safepoint, specify both DieOnSafepointTimeout &
 943   // ShowMessageBoxOnError.
 944   if (DieOnSafepointTimeout) {
 945     fatal("Safepoint sync time longer than " INTX_FORMAT "ms detected when executing %s.",
 946           SafepointTimeoutDelay, VMThread::vm_safepoint_description());
 947   }
 948 }


1419                 _coalesced_vmop_count);
1420   tty->print_cr("Maximum sync time  " INT64_FORMAT_W(5) " ms",
1421                 (int64_t)(_max_sync_time / MICROUNITS));
1422   tty->print_cr("Maximum vm operation time (except for Exit VM operation)  "
1423                 INT64_FORMAT_W(5) " ms",
1424                 (int64_t)(_max_vmop_time / MICROUNITS));
1425 }
1426 
1427 // ------------------------------------------------------------------------------------------------
1428 // Non-product code
1429 
1430 #ifndef PRODUCT
1431 
1432 void SafepointSynchronize::print_state() {
1433   if (_state == _not_synchronized) {
1434     tty->print_cr("not synchronized");
1435   } else if (_state == _synchronizing || _state == _synchronized) {
1436     tty->print_cr("State: %s", (_state == _synchronizing) ? "synchronizing" :
1437                   "synchronized");
1438 
1439     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur = jtiwh.next(); ) {
1440        cur->safepoint_state()->print();
1441     }
1442   }
1443 }
1444 
1445 void SafepointSynchronize::safepoint_msg(const char* format, ...) {
1446   if (ShowSafepointMsgs) {
1447     va_list ap;
1448     va_start(ap, format);
1449     tty->vprint_cr(format, ap);
1450     va_end(ap);
1451   }
1452 }
1453 
1454 #endif // !PRODUCT
< prev index next >