src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp

Print this page




  74 
  75 PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() {
  76   assert(_manager_array != NULL, "Sanity");
  77   return &_manager_array[ParallelGCThreads];
  78 }
  79 
  80 void PSPromotionManager::pre_scavenge() {
  81   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
  82   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
  83 
  84   _young_space = heap->young_gen()->to_space();
  85 
  86   for(uint i=0; i<ParallelGCThreads+1; i++) {
  87     manager_array(i)->reset();
  88   }
  89 }
  90 
  91 bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) {
  92   bool promotion_failure_occurred = false;
  93 
  94   TASKQUEUE_STATS_ONLY(if (PrintGCDetails && ParallelGCVerbose) print_stats());
  95   for (uint i = 0; i < ParallelGCThreads + 1; i++) {
  96     PSPromotionManager* manager = manager_array(i);
  97     assert(manager->claimed_stack_depth()->is_empty(), "should be empty");
  98     if (manager->_promotion_failed_info.has_failed()) {
  99       gc_tracer.report_promotion_failed(manager->_promotion_failed_info);
 100       promotion_failure_occurred = true;
 101     }
 102     manager->flush_labs();
 103   }
 104   return promotion_failure_occurred;
 105 }
 106 
 107 #if TASKQUEUE_STATS
 108 void
 109 PSPromotionManager::print_taskqueue_stats(uint i) const {
 110   tty->print("%3u ", i);
 111   _claimed_stack_depth.stats.print();
 112   tty->cr();
 113 }
 114 
 115 void
 116 PSPromotionManager::print_local_stats(uint i) const {
 117   #define FMT " " SIZE_FORMAT_W(10)
 118   tty->print_cr("%3u" FMT FMT FMT FMT, i, _masked_pushes, _masked_steals,
 119                 _arrays_chunked, _array_chunks_processed);
 120   #undef FMT
 121 }
 122 
 123 static const char* const pm_stats_hdr[] = {
 124   "    --------masked-------     arrays      array",
 125   "thr       push      steal    chunked     chunks",
 126   "--- ---------- ---------- ---------- ----------"
 127 };
 128 
 129 void
 130 PSPromotionManager::print_stats() {
 131   tty->print_cr("== GC Tasks Stats, GC %3d",
 132                 Universe::heap()->total_collections());
 133 
 134   tty->print("thr "); TaskQueueStats::print_header(1); tty->cr();
 135   tty->print("--- "); TaskQueueStats::print_header(2); tty->cr();

 136   for (uint i = 0; i < ParallelGCThreads + 1; ++i) {
 137     manager_array(i)->print_taskqueue_stats(i);


 138   }

 139 
 140   const uint hlines = sizeof(pm_stats_hdr) / sizeof(pm_stats_hdr[0]);
 141   for (uint i = 0; i < hlines; ++i) tty->print_cr("%s", pm_stats_hdr[i]);
 142   for (uint i = 0; i < ParallelGCThreads + 1; ++i) {
 143     manager_array(i)->print_local_stats(i);
 144   }
 145 }
 146 
 147 void
 148 PSPromotionManager::reset_stats() {
 149   claimed_stack_depth()->stats.reset();
 150   _masked_pushes = _masked_steals = 0;
 151   _arrays_chunked = _array_chunks_processed = 0;
 152 }
 153 #endif // TASKQUEUE_STATS
 154 
 155 PSPromotionManager::PSPromotionManager() {
 156   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 157   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 158 
 159   // We set the old lab's start array.
 160   _old_lab.set_start_array(old_gen()->start_array());
 161 
 162   uint queue_size;
 163   claimed_stack_depth()->initialize();




  74 
  75 PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() {
  76   assert(_manager_array != NULL, "Sanity");
  77   return &_manager_array[ParallelGCThreads];
  78 }
  79 
  80 void PSPromotionManager::pre_scavenge() {
  81   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
  82   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
  83 
  84   _young_space = heap->young_gen()->to_space();
  85 
  86   for(uint i=0; i<ParallelGCThreads+1; i++) {
  87     manager_array(i)->reset();
  88   }
  89 }
  90 
  91 bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) {
  92   bool promotion_failure_occurred = false;
  93 
  94   TASKQUEUE_STATS_ONLY(if (PrintTaskqueue) print_taskqueue_stats());
  95   for (uint i = 0; i < ParallelGCThreads + 1; i++) {
  96     PSPromotionManager* manager = manager_array(i);
  97     assert(manager->claimed_stack_depth()->is_empty(), "should be empty");
  98     if (manager->_promotion_failed_info.has_failed()) {
  99       gc_tracer.report_promotion_failed(manager->_promotion_failed_info);
 100       promotion_failure_occurred = true;
 101     }
 102     manager->flush_labs();
 103   }
 104   return promotion_failure_occurred;
 105 }
 106 
 107 #if TASKQUEUE_STATS
 108 void
 109 PSPromotionManager::print_local_stats(outputStream* const out, uint i) const {







 110   #define FMT " " SIZE_FORMAT_W(10)
 111   out->print_cr("%3u" FMT FMT FMT FMT, i, _masked_pushes, _masked_steals,
 112                 _arrays_chunked, _array_chunks_processed);
 113   #undef FMT
 114 }
 115 
 116 static const char* const pm_stats_hdr[] = {
 117   "    --------masked-------     arrays      array",
 118   "thr       push      steal    chunked     chunks",
 119   "--- ---------- ---------- ---------- ----------"
 120 };
 121 
 122 void
 123 PSPromotionManager::print_taskqueue_stats(outputStream* const out) {
 124   out->print_cr("== GC Tasks Stats, GC %3d",
 125                 Universe::heap()->total_collections());
 126 
 127   TaskQueueStats totals;
 128   out->print("thr "); TaskQueueStats::print_header(1, out); out->cr();
 129   out->print("--- "); TaskQueueStats::print_header(2, out); out->cr();
 130   for (uint i = 0; i < ParallelGCThreads + 1; ++i) {
 131     TaskQueueStats& next = manager_array(i)->_claimed_stack_depth.stats;
 132     out->print("%3d ", i); next.print(out); out->cr();
 133     totals += next;
 134   }
 135   out->print("tot "); totals.print(out); out->cr();
 136 
 137   const uint hlines = sizeof(pm_stats_hdr) / sizeof(pm_stats_hdr[0]);
 138   for (uint i = 0; i < hlines; ++i) out->print_cr("%s", pm_stats_hdr[i]);
 139   for (uint i = 0; i < ParallelGCThreads + 1; ++i) {
 140     manager_array(i)->print_local_stats(out, i);
 141   }
 142 }
 143 
 144 void
 145 PSPromotionManager::reset_stats() {
 146   claimed_stack_depth()->stats.reset();
 147   _masked_pushes = _masked_steals = 0;
 148   _arrays_chunked = _array_chunks_processed = 0;
 149 }
 150 #endif // TASKQUEUE_STATS
 151 
 152 PSPromotionManager::PSPromotionManager() {
 153   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 154   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 155 
 156   // We set the old lab's start array.
 157   _old_lab.set_start_array(old_gen()->start_array());
 158 
 159   uint queue_size;
 160   claimed_stack_depth()->initialize();