< prev index next >

src/share/vm/runtime/safepoint.cpp

Print this page




 877       break;
 878 
 879     case _call_back:
 880       set_has_called_back(false);
 881       break;
 882 
 883     case _running:
 884     default:
 885       ShouldNotReachHere();
 886   }
 887 }
 888 
 889 void ThreadSafepointState::restart() {
 890   switch(type()) {
 891     case _at_safepoint:
 892     case _call_back:
 893       break;
 894 
 895     case _running:
 896     default:
 897        tty->print_cr("restart thread "INTPTR_FORMAT" with state %d",
 898                       _thread, _type);
 899        _thread->print();
 900       ShouldNotReachHere();
 901   }
 902   _type = _running;
 903   set_has_called_back(false);
 904 }
 905 
 906 
 907 void ThreadSafepointState::print_on(outputStream *st) const {
 908   const char *s;
 909 
 910   switch(_type) {
 911     case _running                : s = "_running";              break;
 912     case _at_safepoint           : s = "_at_safepoint";         break;
 913     case _call_back              : s = "_call_back";            break;
 914     default:
 915       ShouldNotReachHere();
 916   }
 917 


1176     // array fills up.
1177     if (_cur_stat_index == PrintSafepointStatisticsCount - 1) {
1178       print_statistics();
1179       _cur_stat_index = 0;
1180     } else {
1181       _cur_stat_index++;
1182     }
1183   }
1184 }
1185 
1186 void SafepointSynchronize::print_statistics() {
1187   SafepointStats* sstats = _safepoint_stats;
1188 
1189   for (int index = 0; index <= _cur_stat_index; index++) {
1190     if (index % 30 == 0) {
1191       print_header();
1192     }
1193     sstats = &_safepoint_stats[index];
1194     tty->print("%.3f: ", sstats->_time_stamp);
1195     tty->print("%-26s       ["
1196                INT32_FORMAT_W(8)INT32_FORMAT_W(11)INT32_FORMAT_W(15)
1197                "    ]    ",
1198                sstats->_vmop_type == -1 ? "no vm operation" :
1199                VM_Operation::name(sstats->_vmop_type),
1200                sstats->_nof_total_threads,
1201                sstats->_nof_initial_running_threads,
1202                sstats->_nof_threads_wait_to_block);
1203     // "/ MICROUNITS " is to convert the unit from nanos to millis.
1204     tty->print("  ["
1205                INT64_FORMAT_W(6)INT64_FORMAT_W(6)
1206                INT64_FORMAT_W(6)INT64_FORMAT_W(6)
1207                INT64_FORMAT_W(6)"    ]  ",
1208                sstats->_time_to_spin / MICROUNITS,
1209                sstats->_time_to_wait_to_block / MICROUNITS,
1210                sstats->_time_to_sync / MICROUNITS,
1211                sstats->_time_to_do_cleanups / MICROUNITS,
1212                sstats->_time_to_exec_vmop / MICROUNITS);
1213 
1214     if (need_to_track_page_armed_status) {
1215       tty->print(INT32_FORMAT"         ", sstats->_page_armed);
1216     }
1217     tty->print_cr(INT32_FORMAT"   ", sstats->_nof_threads_hit_page_trap);
1218   }
1219 }
1220 
1221 // This method will be called when VM exits. It will first call
1222 // print_statistics to print out the rest of the sampling.  Then
1223 // it tries to summarize the sampling.
1224 void SafepointSynchronize::print_stat_on_exit() {
1225   if (_safepoint_stats == NULL) return;
1226 
1227   SafepointStats *spstat = &_safepoint_stats[_cur_stat_index];
1228 
1229   // During VM exit, end_statistics may not get called and in that
1230   // case, if the sync time is less than PrintSafepointStatisticsTimeout,
1231   // don't print it out.
1232   // Approximate the vm op time.
1233   _safepoint_stats[_cur_stat_index]._time_to_exec_vmop =
1234     os::javaTimeNanos() - cleanup_end_time;
1235 
1236   if ( PrintSafepointStatisticsTimeout < 0 ||
1237        spstat->_time_to_sync > PrintSafepointStatisticsTimeout * MICROUNITS) {
1238     print_statistics();
1239   }
1240   tty->cr();
1241 
1242   // Print out polling page sampling status.
1243   if (!need_to_track_page_armed_status) {
1244     tty->print_cr("Polling page always armed");
1245   } else {
1246     tty->print_cr("Defer polling page loop count = %d\n",
1247                  DeferPollingPageLoopCount);
1248   }
1249 
1250   for (int index = 0; index < VM_Operation::VMOp_Terminating; index++) {
1251     if (_safepoint_reasons[index] != 0) {
1252       tty->print_cr("%-26s"UINT64_FORMAT_W(10), VM_Operation::name(index),
1253                     _safepoint_reasons[index]);
1254     }
1255   }
1256 
1257   tty->print_cr(UINT64_FORMAT_W(5)" VM operations coalesced during safepoint",
1258                 _coalesced_vmop_count);
1259   tty->print_cr("Maximum sync time  "INT64_FORMAT_W(5)" ms",
1260                 _max_sync_time / MICROUNITS);
1261   tty->print_cr("Maximum vm operation time (except for Exit VM operation)  "
1262                 INT64_FORMAT_W(5)" ms",
1263                 _max_vmop_time / MICROUNITS);
1264 }
1265 
1266 // ------------------------------------------------------------------------------------------------
1267 // Non-product code
1268 
1269 #ifndef PRODUCT
1270 
1271 void SafepointSynchronize::print_state() {
1272   if (_state == _not_synchronized) {
1273     tty->print_cr("not synchronized");
1274   } else if (_state == _synchronizing || _state == _synchronized) {
1275     tty->print_cr("State: %s", (_state == _synchronizing) ? "synchronizing" :
1276                   "synchronized");
1277 
1278     for(JavaThread *cur = Threads::first(); cur; cur = cur->next()) {
1279        cur->safepoint_state()->print();
1280     }
1281   }
1282 }


 877       break;
 878 
 879     case _call_back:
 880       set_has_called_back(false);
 881       break;
 882 
 883     case _running:
 884     default:
 885       ShouldNotReachHere();
 886   }
 887 }
 888 
 889 void ThreadSafepointState::restart() {
 890   switch(type()) {
 891     case _at_safepoint:
 892     case _call_back:
 893       break;
 894 
 895     case _running:
 896     default:
 897        tty->print_cr("restart thread " INTPTR_FORMAT " with state %d",
 898                       _thread, _type);
 899        _thread->print();
 900       ShouldNotReachHere();
 901   }
 902   _type = _running;
 903   set_has_called_back(false);
 904 }
 905 
 906 
 907 void ThreadSafepointState::print_on(outputStream *st) const {
 908   const char *s;
 909 
 910   switch(_type) {
 911     case _running                : s = "_running";              break;
 912     case _at_safepoint           : s = "_at_safepoint";         break;
 913     case _call_back              : s = "_call_back";            break;
 914     default:
 915       ShouldNotReachHere();
 916   }
 917 


1176     // array fills up.
1177     if (_cur_stat_index == PrintSafepointStatisticsCount - 1) {
1178       print_statistics();
1179       _cur_stat_index = 0;
1180     } else {
1181       _cur_stat_index++;
1182     }
1183   }
1184 }
1185 
1186 void SafepointSynchronize::print_statistics() {
1187   SafepointStats* sstats = _safepoint_stats;
1188 
1189   for (int index = 0; index <= _cur_stat_index; index++) {
1190     if (index % 30 == 0) {
1191       print_header();
1192     }
1193     sstats = &_safepoint_stats[index];
1194     tty->print("%.3f: ", sstats->_time_stamp);
1195     tty->print("%-26s       ["
1196                INT32_FORMAT_W(8) INT32_FORMAT_W(11) INT32_FORMAT_W(15)
1197                "    ]    ",
1198                sstats->_vmop_type == -1 ? "no vm operation" :
1199                VM_Operation::name(sstats->_vmop_type),
1200                sstats->_nof_total_threads,
1201                sstats->_nof_initial_running_threads,
1202                sstats->_nof_threads_wait_to_block);
1203     // "/ MICROUNITS " is to convert the unit from nanos to millis.
1204     tty->print("  ["
1205                INT64_FORMAT_W(6) INT64_FORMAT_W(6)
1206                INT64_FORMAT_W(6) INT64_FORMAT_W(6)
1207                INT64_FORMAT_W(6) "    ]  ",
1208                sstats->_time_to_spin / MICROUNITS,
1209                sstats->_time_to_wait_to_block / MICROUNITS,
1210                sstats->_time_to_sync / MICROUNITS,
1211                sstats->_time_to_do_cleanups / MICROUNITS,
1212                sstats->_time_to_exec_vmop / MICROUNITS);
1213 
1214     if (need_to_track_page_armed_status) {
1215       tty->print(INT32_FORMAT "         ", sstats->_page_armed);
1216     }
1217     tty->print_cr(INT32_FORMAT "   ", sstats->_nof_threads_hit_page_trap);
1218   }
1219 }
1220 
1221 // This method will be called when VM exits. It will first call
1222 // print_statistics to print out the rest of the sampling.  Then
1223 // it tries to summarize the sampling.
1224 void SafepointSynchronize::print_stat_on_exit() {
1225   if (_safepoint_stats == NULL) return;
1226 
1227   SafepointStats *spstat = &_safepoint_stats[_cur_stat_index];
1228 
1229   // During VM exit, end_statistics may not get called and in that
1230   // case, if the sync time is less than PrintSafepointStatisticsTimeout,
1231   // don't print it out.
1232   // Approximate the vm op time.
1233   _safepoint_stats[_cur_stat_index]._time_to_exec_vmop =
1234     os::javaTimeNanos() - cleanup_end_time;
1235 
1236   if ( PrintSafepointStatisticsTimeout < 0 ||
1237        spstat->_time_to_sync > PrintSafepointStatisticsTimeout * MICROUNITS) {
1238     print_statistics();
1239   }
1240   tty->cr();
1241 
1242   // Print out polling page sampling status.
1243   if (!need_to_track_page_armed_status) {
1244     tty->print_cr("Polling page always armed");
1245   } else {
1246     tty->print_cr("Defer polling page loop count = %d\n",
1247                  DeferPollingPageLoopCount);
1248   }
1249 
1250   for (int index = 0; index < VM_Operation::VMOp_Terminating; index++) {
1251     if (_safepoint_reasons[index] != 0) {
1252       tty->print_cr("%-26s" UINT64_FORMAT_W(10), VM_Operation::name(index),
1253                     _safepoint_reasons[index]);
1254     }
1255   }
1256 
1257   tty->print_cr(UINT64_FORMAT_W(5) " VM operations coalesced during safepoint",
1258                 _coalesced_vmop_count);
1259   tty->print_cr("Maximum sync time  " INT64_FORMAT_W(5) " ms",
1260                 _max_sync_time / MICROUNITS);
1261   tty->print_cr("Maximum vm operation time (except for Exit VM operation)  "
1262                 INT64_FORMAT_W(5) " ms",
1263                 _max_vmop_time / MICROUNITS);
1264 }
1265 
1266 // ------------------------------------------------------------------------------------------------
1267 // Non-product code
1268 
1269 #ifndef PRODUCT
1270 
1271 void SafepointSynchronize::print_state() {
1272   if (_state == _not_synchronized) {
1273     tty->print_cr("not synchronized");
1274   } else if (_state == _synchronizing || _state == _synchronized) {
1275     tty->print_cr("State: %s", (_state == _synchronizing) ? "synchronizing" :
1276                   "synchronized");
1277 
1278     for(JavaThread *cur = Threads::first(); cur; cur = cur->next()) {
1279        cur->safepoint_state()->print();
1280     }
1281   }
1282 }
< prev index next >