src/share/vm/runtime/safepoint.cpp
Print this page
@@ -126,10 +126,18 @@
}
// Make interpreter safepoint aware
Interpreter::notice_safepoints();
+ // PrintSafepointStatisticsTimeout can be specified separately. When
+ // specified, PrintSafepointStatistics will be set to true in
+ // deferred_initialize_stat method. The initialization has to be done
+ // early enough to avoid any races. See bug 6880029 for details.
+ if (PrintSafepointStatistics || PrintSafepointStatisticsTimeout > 0) {
+ deferred_initialize_stat();
+ }
+
if (UseCompilerSafepoints && DeferPollingPageLoopCount < 0) {
// Make polling safepoint aware
guarantee (PageArmed == 0, "invariant") ;
PageArmed = 1 ;
os::make_polling_page_unreadable();
@@ -167,12 +175,11 @@
}
if (TraceSafepoint && Verbose) cur_state->print();
}
}
- if ( (PrintSafepointStatistics || (PrintSafepointStatisticsTimeout > 0))
- && iterations == 0) {
+ if (PrintSafepointStatistics && iterations == 0) {
begin_statistics(nof_threads, still_running);
}
if (still_running > 0) {
// Check for if it takes to long
@@ -1024,12 +1031,11 @@
init_done = true;
}
void SafepointSynchronize::begin_statistics(int nof_threads, int nof_running) {
- deferred_initialize_stat();
-
+ assert(init_done, "safepoint statistics array hasn't been initialized");
SafepointStats *spstat = &_safepoint_stats[_cur_stat_index];
VM_Operation *op = VMThread::vm_operation();
spstat->_vmop_type = (op != NULL ? op->type() : -1);
if (op != NULL) {