< prev index next >

src/hotspot/share/gc/shared/workerDataArray.inline.hpp

Print this page
rev 52681 : [mq]: AMGC-kbar-rev1


  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_thread_work_item(uint worker_i, size_t value, uint index) {
  78   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
  79   assert(_thread_work_items[index] != NULL, "No sub count");
  80   _thread_work_items[index]->add(worker_i, value);
  81 }
  82 
  83 template <typename T>











  84 void WorkerDataArray<T>::add(uint worker_i, T value) {
  85   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
  86   assert(_data[worker_i] != uninitialized(), "No data to add to for worker %d", worker_i);
  87   _data[worker_i] += value;
  88 }
  89 
  90 template <typename T>
  91 double WorkerDataArray<T>::average() const {
  92   uint contributing_threads = 0;
  93   for (uint i = 0; i < _length; ++i) {
  94     if (get(i) != uninitialized()) {
  95       contributing_threads++;
  96     }
  97   }
  98   if (contributing_threads == 0) {
  99     return 0.0;
 100   }
 101   return sum() / (double) contributing_threads;
 102 }
 103 




  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_thread_work_item(uint worker_i, size_t value, uint index) {
  78   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
  79   assert(_thread_work_items[index] != NULL, "No sub count");
  80   _thread_work_items[index]->add(worker_i, value);
  81 }
  82 
  83 template <typename T>
  84 void WorkerDataArray<T>::set_or_add_thread_work_item(uint worker_i, size_t value, uint index) {
  85   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
  86   assert(_thread_work_items[index] != NULL, "No sub count");
  87   if (_thread_work_items[index]->get(worker_i) == _thread_work_items[index]->uninitialized()) {
  88     _thread_work_items[index]->set(worker_i, value);
  89   } else {
  90     _thread_work_items[index]->add(worker_i, value);
  91   }
  92 }
  93 
  94 template <typename T>
  95 void WorkerDataArray<T>::add(uint worker_i, T value) {
  96   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
  97   assert(_data[worker_i] != uninitialized(), "No data to add to for worker %d", worker_i);
  98   _data[worker_i] += value;
  99 }
 100 
 101 template <typename T>
 102 double WorkerDataArray<T>::average() const {
 103   uint contributing_threads = 0;
 104   for (uint i = 0; i < _length; ++i) {
 105     if (get(i) != uninitialized()) {
 106       contributing_threads++;
 107     }
 108   }
 109   if (contributing_threads == 0) {
 110     return 0.0;
 111   }
 112   return sum() / (double) contributing_threads;
 113 }
 114 


< prev index next >