< prev index next >

src/share/vm/runtime/safepoint.cpp

Print this page
rev 9081 : imported patch more.patch


 107   int nof_threads = Threads::number_of_threads();
 108 
 109   if (TraceSafepoint) {
 110     tty->print_cr("Safepoint synchronization initiated. (%d)", nof_threads);
 111   }
 112 
 113   RuntimeService::record_safepoint_begin();
 114 
 115   MutexLocker mu(Safepoint_lock);
 116 
 117   // Reset the count of active JNI critical threads
 118   _current_jni_active_count = 0;
 119 
 120   // Set number of threads to wait for, before we initiate the callbacks
 121   _waiting_to_block = nof_threads;
 122   TryingToBlock     = 0 ;
 123   int still_running = nof_threads;
 124 
 125   // Save the starting time, so that it can be compared to see if this has taken
 126   // too long to complete.
 127   jlong safepoint_limit_time;
 128   timeout_error_printed = false;
 129 
 130   // PrintSafepointStatisticsTimeout can be specified separately. When
 131   // specified, PrintSafepointStatistics will be set to true in
 132   // deferred_initialize_stat method. The initialization has to be done
 133   // early enough to avoid any races. See bug 6880029 for details.
 134   if (PrintSafepointStatistics || PrintSafepointStatisticsTimeout > 0) {
 135     deferred_initialize_stat();
 136   }
 137 
 138   // Begin the process of bringing the system to a safepoint.
 139   // Java threads can be in several different states and are
 140   // stopped by different mechanisms:
 141   //
 142   //  1. Running interpreted
 143   //     The interpreter dispatch table is changed to force it to
 144   //     check for a safepoint condition between bytecodes.
 145   //  2. Running in native code
 146   //     When returning from the native code, a Java thread must check
 147   //     the safepoint _state to see if we must block.  If the


 886 
 887 void ThreadSafepointState::restart() {
 888   switch(type()) {
 889     case _at_safepoint:
 890     case _call_back:
 891       break;
 892 
 893     case _running:
 894     default:
 895        tty->print_cr("restart thread " INTPTR_FORMAT " with state %d",
 896                       _thread, _type);
 897        _thread->print();
 898       ShouldNotReachHere();
 899   }
 900   _type = _running;
 901   set_has_called_back(false);
 902 }
 903 
 904 
 905 void ThreadSafepointState::print_on(outputStream *st) const {
 906   const char *s;
 907 
 908   switch(_type) {
 909     case _running                : s = "_running";              break;
 910     case _at_safepoint           : s = "_at_safepoint";         break;
 911     case _call_back              : s = "_call_back";            break;
 912     default:
 913       ShouldNotReachHere();
 914   }
 915 
 916   st->print_cr("Thread: " INTPTR_FORMAT
 917               "  [0x%2x] State: %s _has_called_back %d _at_poll_safepoint %d",
 918                _thread, _thread->osthread()->thread_id(), s, _has_called_back,
 919                _at_poll_safepoint);
 920 
 921   _thread->print_thread_state_on(st);
 922 }
 923 
 924 
 925 // ---------------------------------------------------------------------------------------------------------------------
 926 




 107   int nof_threads = Threads::number_of_threads();
 108 
 109   if (TraceSafepoint) {
 110     tty->print_cr("Safepoint synchronization initiated. (%d)", nof_threads);
 111   }
 112 
 113   RuntimeService::record_safepoint_begin();
 114 
 115   MutexLocker mu(Safepoint_lock);
 116 
 117   // Reset the count of active JNI critical threads
 118   _current_jni_active_count = 0;
 119 
 120   // Set number of threads to wait for, before we initiate the callbacks
 121   _waiting_to_block = nof_threads;
 122   TryingToBlock     = 0 ;
 123   int still_running = nof_threads;
 124 
 125   // Save the starting time, so that it can be compared to see if this has taken
 126   // too long to complete.
 127   jlong safepoint_limit_time = 0;
 128   timeout_error_printed = false;
 129 
 130   // PrintSafepointStatisticsTimeout can be specified separately. When
 131   // specified, PrintSafepointStatistics will be set to true in
 132   // deferred_initialize_stat method. The initialization has to be done
 133   // early enough to avoid any races. See bug 6880029 for details.
 134   if (PrintSafepointStatistics || PrintSafepointStatisticsTimeout > 0) {
 135     deferred_initialize_stat();
 136   }
 137 
 138   // Begin the process of bringing the system to a safepoint.
 139   // Java threads can be in several different states and are
 140   // stopped by different mechanisms:
 141   //
 142   //  1. Running interpreted
 143   //     The interpreter dispatch table is changed to force it to
 144   //     check for a safepoint condition between bytecodes.
 145   //  2. Running in native code
 146   //     When returning from the native code, a Java thread must check
 147   //     the safepoint _state to see if we must block.  If the


 886 
 887 void ThreadSafepointState::restart() {
 888   switch(type()) {
 889     case _at_safepoint:
 890     case _call_back:
 891       break;
 892 
 893     case _running:
 894     default:
 895        tty->print_cr("restart thread " INTPTR_FORMAT " with state %d",
 896                       _thread, _type);
 897        _thread->print();
 898       ShouldNotReachHere();
 899   }
 900   _type = _running;
 901   set_has_called_back(false);
 902 }
 903 
 904 
 905 void ThreadSafepointState::print_on(outputStream *st) const {
 906   const char *s = NULL;
 907 
 908   switch(_type) {
 909     case _running                : s = "_running";              break;
 910     case _at_safepoint           : s = "_at_safepoint";         break;
 911     case _call_back              : s = "_call_back";            break;
 912     default:
 913       ShouldNotReachHere();
 914   }
 915 
 916   st->print_cr("Thread: " INTPTR_FORMAT
 917               "  [0x%2x] State: %s _has_called_back %d _at_poll_safepoint %d",
 918                _thread, _thread->osthread()->thread_id(), s, _has_called_back,
 919                _at_poll_safepoint);
 920 
 921   _thread->print_thread_state_on(st);
 922 }
 923 
 924 
 925 // ---------------------------------------------------------------------------------------------------------------------
 926 


< prev index next >