1.1 --- a/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp Wed Feb 17 13:42:03 2016 +0000 1.2 +++ b/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp Thu Feb 18 20:30:45 2016 +0000 1.3 @@ -154,28 +154,28 @@ 1.4 _has_new_data = true; 1.5 } 1.6 1.7 - double average(){ 1.8 - calculate_totals(); 1.9 + double average(uint active_threads){ 1.10 + calculate_totals(active_threads); 1.11 return _average; 1.12 } 1.13 1.14 - T sum() { 1.15 - calculate_totals(); 1.16 + T sum(uint active_threads) { 1.17 + calculate_totals(active_threads); 1.18 return _sum; 1.19 } 1.20 1.21 - T minimum() { 1.22 - calculate_totals(); 1.23 + T minimum(uint active_threads) { 1.24 + calculate_totals(active_threads); 1.25 return _min; 1.26 } 1.27 1.28 - T maximum() { 1.29 - calculate_totals(); 1.30 + T maximum(uint active_threads) { 1.31 + calculate_totals(active_threads); 1.32 return _max; 1.33 } 1.34 1.35 void reset() PRODUCT_RETURN; 1.36 - void verify() PRODUCT_RETURN; 1.37 + void verify(uint active_threads) PRODUCT_RETURN; 1.38 1.39 void set_enabled(bool enabled) { _enabled = enabled; } 1.40 1.41 @@ -183,7 +183,7 @@ 1.42 1.43 private: 1.44 1.45 - void calculate_totals(){ 1.46 + void calculate_totals(uint active_threads){ 1.47 if (!_has_new_data) { 1.48 return; 1.49 } 1.50 @@ -191,13 +191,14 @@ 1.51 _sum = (T)0; 1.52 _min = _data[0]; 1.53 _max = _min; 1.54 - for (uint i = 0; i < _length; ++i) { 1.55 + assert(active_threads <= _length, "Wrong number of active threads"); 1.56 + for (uint i = 0; i < active_threads; ++i) { 1.57 T val = _data[i]; 1.58 _sum += val; 1.59 _min = MIN2(_min, val); 1.60 _max = MAX2(_max, val); 1.61 } 1.62 - _average = (double)_sum / (double)_length; 1.63 + _average = (double)_sum / (double)active_threads; 1.64 _has_new_data = false; 1.65 } 1.66 }; 1.67 @@ -226,17 +227,18 @@ 1.68 } 1.69 1.70 template <class T> 1.71 -void WorkerDataArray<T>::verify() { 1.72 +void WorkerDataArray<T>::verify(uint active_threads) { 1.73 if (!_enabled) { 1.74 return; 1.75 } 1.76 1.77 - for (uint i = 0; i < _length; i++) { 1.78 + assert(active_threads <= _length, "Wrong number of active threads"); 1.79 + for (uint i = 0; i < active_threads; i++) { 1.80 assert(_data[i] != WorkerDataArray<T>::uninitialized(), 1.81 err_msg("Invalid data for worker %u in '%s'", i, _title)); 1.82 } 1.83 if (_thread_work_items != NULL) { 1.84 - _thread_work_items->verify(); 1.85 + _thread_work_items->verify(active_threads); 1.86 } 1.87 } 1.88 1.89 @@ -321,7 +323,7 @@ 1.90 } 1.91 1.92 for (int i = 0; i < GCParPhasesSentinel; i++) { 1.93 - _gc_par_phases[i]->verify(); 1.94 + _gc_par_phases[i]->verify(_active_gc_threads); 1.95 } 1.96 } 1.97 1.98 @@ -378,7 +380,7 @@ 1.99 1.100 // return the average time for a phase in milliseconds 1.101 double G1GCPhaseTimes::average_time_ms(GCParPhases phase) { 1.102 - return _gc_par_phases[phase]->average() * 1000.0; 1.103 + return _gc_par_phases[phase]->average(_active_gc_threads) * 1000.0; 1.104 } 1.105 1.106 double G1GCPhaseTimes::get_time_ms(GCParPhases phase, uint worker_i) { 1.107 @@ -386,15 +388,15 @@ 1.108 } 1.109 1.110 double G1GCPhaseTimes::sum_time_ms(GCParPhases phase) { 1.111 - return _gc_par_phases[phase]->sum() * 1000.0; 1.112 + return _gc_par_phases[phase]->sum(_active_gc_threads) * 1000.0; 1.113 } 1.114 1.115 double G1GCPhaseTimes::min_time_ms(GCParPhases phase) { 1.116 - return _gc_par_phases[phase]->minimum() * 1000.0; 1.117 + return _gc_par_phases[phase]->minimum(_active_gc_threads) * 1000.0; 1.118 } 1.119 1.120 double G1GCPhaseTimes::max_time_ms(GCParPhases phase) { 1.121 - return _gc_par_phases[phase]->maximum() * 1000.0; 1.122 + return _gc_par_phases[phase]->maximum(_active_gc_threads) * 1000.0; 1.123 } 1.124 1.125 size_t G1GCPhaseTimes::get_thread_work_item(GCParPhases phase, uint worker_i) { 1.126 @@ -404,22 +406,22 @@ 1.127 1.128 size_t G1GCPhaseTimes::sum_thread_work_items(GCParPhases phase) { 1.129 assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count"); 1.130 - return _gc_par_phases[phase]->thread_work_items()->sum(); 1.131 + return _gc_par_phases[phase]->thread_work_items()->sum(_active_gc_threads); 1.132 } 1.133 1.134 double G1GCPhaseTimes::average_thread_work_items(GCParPhases phase) { 1.135 assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count"); 1.136 - return _gc_par_phases[phase]->thread_work_items()->average(); 1.137 + return _gc_par_phases[phase]->thread_work_items()->average(_active_gc_threads); 1.138 } 1.139 1.140 size_t G1GCPhaseTimes::min_thread_work_items(GCParPhases phase) { 1.141 assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count"); 1.142 - return _gc_par_phases[phase]->thread_work_items()->minimum(); 1.143 + return _gc_par_phases[phase]->thread_work_items()->minimum(_active_gc_threads); 1.144 } 1.145 1.146 size_t G1GCPhaseTimes::max_thread_work_items(GCParPhases phase) { 1.147 assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count"); 1.148 - return _gc_par_phases[phase]->thread_work_items()->maximum(); 1.149 + return _gc_par_phases[phase]->thread_work_items()->maximum(_active_gc_threads); 1.150 } 1.151 1.152 class G1GCParPhasePrinter : public StackObj { 1.153 @@ -455,14 +457,16 @@ 1.154 } 1.155 1.156 void print_time_values(LineBuffer& buf, G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<double>* phase) { 1.157 - for (uint i = 0; i < phase->_length; ++i) { 1.158 + uint active_length = _phase_times->_active_gc_threads; 1.159 + for (uint i = 0; i < active_length; ++i) { 1.160 buf.append(" %.1lf", _phase_times->get_time_ms(phase_id, i)); 1.161 } 1.162 buf.print_cr(); 1.163 } 1.164 1.165 void print_count_values(LineBuffer& buf, G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<size_t>* thread_work_items) { 1.166 - for (uint i = 0; i < thread_work_items->_length; ++i) { 1.167 + uint active_length = _phase_times->_active_gc_threads; 1.168 + for (uint i = 0; i < active_length; ++i) { 1.169 buf.append(" " SIZE_FORMAT, _phase_times->get_thread_work_item(phase_id, i)); 1.170 } 1.171 buf.print_cr();