src/share/vm/gc_implementation/shared/gcTraceTime.cpp

Print this page
rev 4515 : 7176220: 'Full GC' events miss date stamp information occasionally
Summary: Move date stamp logic into GCTraceTime
Reviewed-by: johnc, brutisso, jmasa


  41 #endif
  42 #ifdef TARGET_OS_FAMILY_bsd
  43 # include "thread_bsd.inline.hpp"
  44 #endif
  45 
  46 
  47 GCTraceTime::GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer) :
  48     _title(title), _doit(doit), _print_cr(print_cr), _timer(timer) {
  49   if (_doit || _timer != NULL) {
  50     _start_counter = os::elapsed_counter();
  51   }
  52 
  53   if (_timer != NULL) {
  54     assert(SafepointSynchronize::is_at_safepoint(), "Tracing currently only supported at safepoints");
  55     assert(Thread::current()->is_VM_thread(), "Tracing currently only supported from the VM thread");
  56 
  57     _timer->register_gc_phase_start(title, _start_counter);
  58   }
  59 
  60   if (_doit) {
  61     if (PrintGCTimeStamps) {
  62       gclog_or_tty->stamp();
  63       gclog_or_tty->print(": ");
  64     }
  65     gclog_or_tty->print("[%s", title);
  66     gclog_or_tty->flush();
  67   }
  68 }
  69 
  70 GCTraceTime::~GCTraceTime() {
  71   jlong stop_counter = 0;
  72 
  73   if (_doit || _timer != NULL) {
  74     stop_counter = os::elapsed_counter();
  75   }
  76 
  77   if (_timer != NULL) {
  78     _timer->register_gc_phase_end(stop_counter);
  79   }
  80 
  81   if (_doit) {
  82     double seconds = TimeHelper::counter_to_seconds(stop_counter - _start_counter);
  83     if (_print_cr) {
  84       gclog_or_tty->print_cr(", %3.7f secs]", seconds);


  41 #endif
  42 #ifdef TARGET_OS_FAMILY_bsd
  43 # include "thread_bsd.inline.hpp"
  44 #endif
  45 
  46 
  47 GCTraceTime::GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer) :
  48     _title(title), _doit(doit), _print_cr(print_cr), _timer(timer) {
  49   if (_doit || _timer != NULL) {
  50     _start_counter = os::elapsed_counter();
  51   }
  52 
  53   if (_timer != NULL) {
  54     assert(SafepointSynchronize::is_at_safepoint(), "Tracing currently only supported at safepoints");
  55     assert(Thread::current()->is_VM_thread(), "Tracing currently only supported from the VM thread");
  56 
  57     _timer->register_gc_phase_start(title, _start_counter);
  58   }
  59 
  60   if (_doit) {
  61     gclog_or_tty->date_stamp(PrintGCDateStamps);
  62     gclog_or_tty->stamp(PrintGCTimeStamps);


  63     gclog_or_tty->print("[%s", title);
  64     gclog_or_tty->flush();
  65   }
  66 }
  67 
  68 GCTraceTime::~GCTraceTime() {
  69   jlong stop_counter = 0;
  70 
  71   if (_doit || _timer != NULL) {
  72     stop_counter = os::elapsed_counter();
  73   }
  74 
  75   if (_timer != NULL) {
  76     _timer->register_gc_phase_end(stop_counter);
  77   }
  78 
  79   if (_doit) {
  80     double seconds = TimeHelper::counter_to_seconds(stop_counter - _start_counter);
  81     if (_print_cr) {
  82       gclog_or_tty->print_cr(", %3.7f secs]", seconds);