< prev index next >

src/share/vm/gc/g1/workerDataArray.inline.hpp

Print this page
rev 12944 : imported patch 8178148-more-detailed-scan-rs-logging


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP
  26 #define SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP
  27 
  28 #include "gc/g1/workerDataArray.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "utilities/ostream.hpp"
  31 
  32 template <typename T>
  33 WorkerDataArray<T>::WorkerDataArray(uint length, const char* title) :
  34  _title(title),
  35  _length(0),
  36  _thread_work_items(NULL) {
  37   assert(length > 0, "Must have some workers to store data for");
  38   _length = length;
  39   _data = NEW_C_HEAP_ARRAY(T, _length, mtGC);



  40   reset();
  41 }
  42 
  43 template <typename T>
  44 void WorkerDataArray<T>::set(uint worker_i, T value) {
  45   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
  46   assert(_data[worker_i] == uninitialized(), "Overwriting data for worker %d in %s", worker_i, _title);
  47   _data[worker_i] = value;
  48 }
  49 
  50 template <typename T>
  51 T WorkerDataArray<T>::get(uint worker_i) const {
  52   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
  53   return _data[worker_i];
  54 }
  55 
  56 template <typename T>
  57 WorkerDataArray<T>::~WorkerDataArray() {
  58   FREE_C_HEAP_ARRAY(T, _data);
  59 }
  60 
  61 template <typename T>
  62 void WorkerDataArray<T>::link_thread_work_items(WorkerDataArray<size_t>* thread_work_items) {
  63   _thread_work_items = thread_work_items;

  64 }
  65 
  66 template <typename T>
  67 void WorkerDataArray<T>::set_thread_work_item(uint worker_i, size_t value) {
  68   assert(_thread_work_items != NULL, "No sub count");
  69   _thread_work_items->set(worker_i, value);

  70 }
  71 
  72 template <typename T>
  73 void WorkerDataArray<T>::add(uint worker_i, T value) {
  74   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
  75   assert(_data[worker_i] != uninitialized(), "No data to add to for worker %d", worker_i);
  76   _data[worker_i] += value;
  77 }
  78 
  79 template <typename T>
  80 double WorkerDataArray<T>::average() const {
  81   uint contributing_threads = 0;
  82   for (uint i = 0; i < _length; ++i) {
  83     if (get(i) != uninitialized()) {
  84       contributing_threads++;
  85     }
  86   }
  87   if (contributing_threads == 0) {
  88     return 0.0;
  89   }


 131     }
 132     T diff = max - min;
 133     assert(contributing_threads != 0, "Must be since we found a used value for the start index");
 134     double avg = sum / (double) contributing_threads;
 135     WDAPrinter::summary(out, min, avg, max, diff, sum, print_sum);
 136     out->print_cr(", Workers: %d", contributing_threads);
 137   } else {
 138     // No data for this phase.
 139     out->print_cr(" skipped");
 140   }
 141 }
 142 
 143 template <class T>
 144 void WorkerDataArray<T>::print_details_on(outputStream* out) const {
 145   WDAPrinter::details(this, out);
 146 }
 147 
 148 template <typename T>
 149 void WorkerDataArray<T>::reset() {
 150   set_all(uninitialized());
 151   if (_thread_work_items != NULL) {
 152     _thread_work_items->reset();


 153   }
 154 }
 155 
 156 #endif // SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP
  26 #define SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP
  27 
  28 #include "gc/g1/workerDataArray.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "utilities/ostream.hpp"
  31 
  32 template <typename T>
  33 WorkerDataArray<T>::WorkerDataArray(uint length, const char* title) :
  34  _title(title),
  35  _length(0) {

  36   assert(length > 0, "Must have some workers to store data for");
  37   _length = length;
  38   _data = NEW_C_HEAP_ARRAY(T, _length, mtGC);
  39   for (uint i = 0; i < MaxThreadWorkItems; i++) {
  40     _thread_work_items[i] = NULL;
  41   }
  42   reset();
  43 }
  44 
  45 template <typename T>
  46 void WorkerDataArray<T>::set(uint worker_i, T value) {
  47   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
  48   assert(_data[worker_i] == uninitialized(), "Overwriting data for worker %d in %s", worker_i, _title);
  49   _data[worker_i] = value;
  50 }
  51 
  52 template <typename T>
  53 T WorkerDataArray<T>::get(uint worker_i) const {
  54   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
  55   return _data[worker_i];
  56 }
  57 
  58 template <typename T>
  59 WorkerDataArray<T>::~WorkerDataArray() {
  60   FREE_C_HEAP_ARRAY(T, _data);
  61 }
  62 
  63 template <typename T>
  64 void WorkerDataArray<T>::link_thread_work_items(WorkerDataArray<size_t>* thread_work_items, uint index) {
  65   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u max %u", index, MaxThreadWorkItems);
  66   _thread_work_items[index] = thread_work_items;
  67 }
  68 
  69 template <typename T>
  70 void WorkerDataArray<T>::set_thread_work_item(uint worker_i, size_t value, uint index) {
  71   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u max %u", index, MaxThreadWorkItems);
  72   assert(_thread_work_items[index] != NULL, "No sub count");
  73   _thread_work_items[index]->set(worker_i, value);
  74 }
  75 
  76 template <typename T>
  77 void WorkerDataArray<T>::add(uint worker_i, T value) {
  78   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
  79   assert(_data[worker_i] != uninitialized(), "No data to add to for worker %d", worker_i);
  80   _data[worker_i] += value;
  81 }
  82 
  83 template <typename T>
  84 double WorkerDataArray<T>::average() const {
  85   uint contributing_threads = 0;
  86   for (uint i = 0; i < _length; ++i) {
  87     if (get(i) != uninitialized()) {
  88       contributing_threads++;
  89     }
  90   }
  91   if (contributing_threads == 0) {
  92     return 0.0;
  93   }


 135     }
 136     T diff = max - min;
 137     assert(contributing_threads != 0, "Must be since we found a used value for the start index");
 138     double avg = sum / (double) contributing_threads;
 139     WDAPrinter::summary(out, min, avg, max, diff, sum, print_sum);
 140     out->print_cr(", Workers: %d", contributing_threads);
 141   } else {
 142     // No data for this phase.
 143     out->print_cr(" skipped");
 144   }
 145 }
 146 
 147 template <class T>
 148 void WorkerDataArray<T>::print_details_on(outputStream* out) const {
 149   WDAPrinter::details(this, out);
 150 }
 151 
 152 template <typename T>
 153 void WorkerDataArray<T>::reset() {
 154   set_all(uninitialized());
 155   for (uint i = 0; i < MaxThreadWorkItems; i++) {
 156     if (_thread_work_items[i] != NULL) {
 157       _thread_work_items[i]->reset();
 158     }
 159   }
 160 }
 161 
 162 #endif // SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP
< prev index next >