hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp
changeset 24424 2658d7834c6e
parent 24104 febf9363fb68
child 25351 7c198a690050
equal deleted inserted replaced
24358:8528b67f6562 24424:2658d7834c6e
    37   static const int INDENT_CHARS = 3;
    37   static const int INDENT_CHARS = 3;
    38   char _buffer[BUFFER_LEN];
    38   char _buffer[BUFFER_LEN];
    39   int _indent_level;
    39   int _indent_level;
    40   int _cur;
    40   int _cur;
    41 
    41 
    42   void vappend(const char* format, va_list ap) {
    42   void vappend(const char* format, va_list ap)  ATTRIBUTE_PRINTF(2, 0) {
    43     int res = vsnprintf(&_buffer[_cur], BUFFER_LEN - _cur, format, ap);
    43     int res = vsnprintf(&_buffer[_cur], BUFFER_LEN - _cur, format, ap);
    44     if (res != -1) {
    44     if (res != -1) {
    45       _cur += res;
    45       _cur += res;
    46     } else {
    46     } else {
    47       DEBUG_ONLY(warning("buffer too small in LineBuffer");)
    47       DEBUG_ONLY(warning("buffer too small in LineBuffer");)
    61   ~LineBuffer() {
    61   ~LineBuffer() {
    62     assert(_cur == _indent_level * INDENT_CHARS, "pending data in buffer - append_and_print_cr() not called?");
    62     assert(_cur == _indent_level * INDENT_CHARS, "pending data in buffer - append_and_print_cr() not called?");
    63   }
    63   }
    64 #endif
    64 #endif
    65 
    65 
    66   void append(const char* format, ...) {
    66   void append(const char* format, ...)  ATTRIBUTE_PRINTF(2, 3) {
    67     va_list ap;
    67     va_list ap;
    68     va_start(ap, format);
    68     va_start(ap, format);
    69     vappend(format, ap);
    69     vappend(format, ap);
    70     va_end(ap);
    70     va_end(ap);
    71   }
    71   }
    72 
    72 
    73   void append_and_print_cr(const char* format, ...) {
    73   void append_and_print_cr(const char* format, ...)  ATTRIBUTE_PRINTF(2, 3) {
    74     va_list ap;
    74     va_list ap;
    75     va_start(ap, format);
    75     va_start(ap, format);
    76     vappend(format, ap);
    76     vappend(format, ap);
    77     va_end(ap);
    77     va_end(ap);
    78     gclog_or_tty->print_cr("%s", _buffer);
    78     gclog_or_tty->print_cr("%s", _buffer);
    79     _cur = _indent_level * INDENT_CHARS;
    79     _cur = _indent_level * INDENT_CHARS;
    80   }
    80   }
    81 };
    81 };
    82 
    82 
       
    83 PRAGMA_DIAG_PUSH
       
    84 PRAGMA_FORMAT_NONLITERAL_IGNORED
    83 template <class T>
    85 template <class T>
    84 void WorkerDataArray<T>::print(int level, const char* title) {
    86 void WorkerDataArray<T>::print(int level, const char* title) {
    85   if (_length == 1) {
    87   if (_length == 1) {
    86     // No need for min, max, average and sum for only one worker
    88     // No need for min, max, average and sum for only one worker
    87     LineBuffer buf(level);
    89     LineBuffer buf(level);
   107       buf.append(_print_format, val);
   109       buf.append(_print_format, val);
   108     }
   110     }
   109   }
   111   }
   110 
   112 
   111   if (G1Log::finest()) {
   113   if (G1Log::finest()) {
   112     buf.append_and_print_cr("");
   114     buf.append_and_print_cr("%s", "");
   113   }
   115   }
   114 
   116 
   115   double avg = (double)sum / (double)_length;
   117   double avg = (double)sum / (double)_length;
   116   buf.append(" Min: ");
   118   buf.append(" Min: ");
   117   buf.append(_print_format, min);
   119   buf.append(_print_format, min);
   127     buf.append(", Sum: ");
   129     buf.append(", Sum: ");
   128     buf.append(_print_format, sum);
   130     buf.append(_print_format, sum);
   129   }
   131   }
   130   buf.append_and_print_cr("]");
   132   buf.append_and_print_cr("]");
   131 }
   133 }
       
   134 PRAGMA_DIAG_POP
   132 
   135 
   133 #ifndef PRODUCT
   136 #ifndef PRODUCT
   134 
   137 
   135 template <> const int WorkerDataArray<int>::_uninitialized = -1;
   138 template <> const int WorkerDataArray<int>::_uninitialized = -1;
   136 template <> const double WorkerDataArray<double>::_uninitialized = -1.0;
   139 template <> const double WorkerDataArray<double>::_uninitialized = -1.0;