< prev index next >

src/share/vm/gc/g1/concurrentG1RefineThread.cpp

Print this page
rev 10389 : imported patch webrev.01
rev 10391 : [mq]: webrev.03


  61   initialize();
  62 
  63   // set name
  64   set_name("G1 Refine#%d", worker_id);
  65   create_and_start();
  66 }
  67 
  68 void ConcurrentG1RefineThread::initialize() {
  69   // Current thread activation threshold
  70   _threshold = MIN2(cg1r()->thread_threshold_step() * (_worker_id + 1) + cg1r()->green_zone(),
  71                     cg1r()->yellow_zone());
  72   // A thread deactivates once the number of buffer reached a deactivation threshold
  73    _deactivation_threshold =
  74      MAX2(_threshold - MIN2(_threshold, cg1r()->thread_threshold_step()),
  75           cg1r()->green_zone());
  76 }
  77 
  78 void ConcurrentG1RefineThread::wait_for_completed_buffers() {
  79   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
  80   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
  81   while (!_should_terminate && !is_active()) {
  82     _monitor->wait(Mutex::_no_safepoint_check_flag);
  83   }
  84 }
  85 
  86 bool ConcurrentG1RefineThread::is_active() {
  87   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
  88   return is_primary() ? dcqs.process_completed_buffers() : _active;
  89 }
  90 
  91 void ConcurrentG1RefineThread::activate() {
  92   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
  93   if (!is_primary()) {
  94     set_active(true);
  95   } else {
  96     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
  97     dcqs.set_process_completed(true);
  98   }
  99   _monitor->notify();
 100 }
 101 
 102 void ConcurrentG1RefineThread::deactivate() {
 103   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
 104   if (!is_primary()) {
 105     set_active(false);
 106   } else {
 107     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
 108     dcqs.set_process_completed(false);
 109   }
 110 }
 111 
 112 void ConcurrentG1RefineThread::run_service() {
 113   _vtime_start = os::elapsedVTime();
 114 
 115   while (!_should_terminate) {
 116     // Wait for work
 117     wait_for_completed_buffers();
 118     if (_should_terminate) {
 119       break;
 120     }
 121 
 122     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
 123     log_debug(gc, refine)("Activated %d, on threshold: " SIZE_FORMAT ", current: " SIZE_FORMAT,
 124                           _worker_id, _threshold, dcqs.completed_buffers_num());
 125 
 126     {
 127       SuspendibleThreadSetJoiner sts_join;
 128 
 129       do {
 130         size_t curr_buffer_num = dcqs.completed_buffers_num();
 131         // If the number of the buffers falls down into the yellow zone,
 132         // that means that the transition period after the evacuation pause has ended.
 133         if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) {
 134           dcqs.set_completed_queue_padding(0);
 135         }
 136 
 137         // Check if we need to activate the next thread.
 138         if (_next != NULL && !_next->is_active() && curr_buffer_num > _next->_threshold) {




  61   initialize();
  62 
  63   // set name
  64   set_name("G1 Refine#%d", worker_id);
  65   create_and_start();
  66 }
  67 
  68 void ConcurrentG1RefineThread::initialize() {
  69   // Current thread activation threshold
  70   _threshold = MIN2(cg1r()->thread_threshold_step() * (_worker_id + 1) + cg1r()->green_zone(),
  71                     cg1r()->yellow_zone());
  72   // A thread deactivates once the number of buffer reached a deactivation threshold
  73    _deactivation_threshold =
  74      MAX2(_threshold - MIN2(_threshold, cg1r()->thread_threshold_step()),
  75           cg1r()->green_zone());
  76 }
  77 
  78 void ConcurrentG1RefineThread::wait_for_completed_buffers() {
  79   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
  80   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
  81   while (!should_terminate() && !is_active()) {
  82     _monitor->wait(Mutex::_no_safepoint_check_flag);
  83   }
  84 }
  85 
  86 bool ConcurrentG1RefineThread::is_active() {
  87   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
  88   return is_primary() ? dcqs.process_completed_buffers() : _active;
  89 }
  90 
  91 void ConcurrentG1RefineThread::activate() {
  92   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
  93   if (!is_primary()) {
  94     set_active(true);
  95   } else {
  96     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
  97     dcqs.set_process_completed(true);
  98   }
  99   _monitor->notify();
 100 }
 101 
 102 void ConcurrentG1RefineThread::deactivate() {
 103   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
 104   if (!is_primary()) {
 105     set_active(false);
 106   } else {
 107     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
 108     dcqs.set_process_completed(false);
 109   }
 110 }
 111 
 112 void ConcurrentG1RefineThread::run_service() {
 113   _vtime_start = os::elapsedVTime();
 114 
 115   while (!should_terminate()) {
 116     // Wait for work
 117     wait_for_completed_buffers();
 118     if (should_terminate()) {
 119       break;
 120     }
 121 
 122     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
 123     log_debug(gc, refine)("Activated %d, on threshold: " SIZE_FORMAT ", current: " SIZE_FORMAT,
 124                           _worker_id, _threshold, dcqs.completed_buffers_num());
 125 
 126     {
 127       SuspendibleThreadSetJoiner sts_join;
 128 
 129       do {
 130         size_t curr_buffer_num = dcqs.completed_buffers_num();
 131         // If the number of the buffers falls down into the yellow zone,
 132         // that means that the transition period after the evacuation pause has ended.
 133         if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) {
 134           dcqs.set_completed_queue_padding(0);
 135         }
 136 
 137         // Check if we need to activate the next thread.
 138         if (_next != NULL && !_next->is_active() && curr_buffer_num > _next->_threshold) {


< prev index next >