hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp
changeset 36371 fd81a4f0ea00
parent 36196 5128f617b0c6
child 36402 7c20aae43c41
equal deleted inserted replaced
36365:bcc9c9afda49 36371:fd81a4f0ea00
    65   create_and_start();
    65   create_and_start();
    66 }
    66 }
    67 
    67 
    68 void ConcurrentG1RefineThread::initialize() {
    68 void ConcurrentG1RefineThread::initialize() {
    69   // Current thread activation threshold
    69   // Current thread activation threshold
    70   _threshold = MIN2<int>(cg1r()->thread_threshold_step() * (_worker_id + 1) + cg1r()->green_zone(),
    70   _threshold = MIN2(cg1r()->thread_threshold_step() * (_worker_id + 1) + cg1r()->green_zone(),
    71                          cg1r()->yellow_zone());
    71                          cg1r()->yellow_zone());
    72   // A thread deactivates once the number of buffer reached a deactivation threshold
    72   // A thread deactivates once the number of buffer reached a deactivation threshold
    73   _deactivation_threshold = MAX2<int>(_threshold - cg1r()->thread_threshold_step(), cg1r()->green_zone());
    73    _deactivation_threshold =
       
    74      MAX2(_threshold - MIN2(_threshold, cg1r()->thread_threshold_step()),
       
    75           cg1r()->green_zone());
    74 }
    76 }
    75 
    77 
    76 void ConcurrentG1RefineThread::wait_for_completed_buffers() {
    78 void ConcurrentG1RefineThread::wait_for_completed_buffers() {
    77   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
    79   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
    78   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
    80   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
   125     if (_should_terminate) {
   127     if (_should_terminate) {
   126       break;
   128       break;
   127     }
   129     }
   128 
   130 
   129     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
   131     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
   130     log_debug(gc, refine)("Activated %d, on threshold: %d, current: %d",
   132     log_debug(gc, refine)("Activated %d, on threshold: " SIZE_FORMAT ", current: " SIZE_FORMAT,
   131                           _worker_id, _threshold, dcqs.completed_buffers_num());
   133                           _worker_id, _threshold, dcqs.completed_buffers_num());
   132 
   134 
   133     {
   135     {
   134       SuspendibleThreadSetJoiner sts_join;
   136       SuspendibleThreadSetJoiner sts_join;
   135 
   137 
   136       do {
   138       do {
   137         int curr_buffer_num = (int)dcqs.completed_buffers_num();
   139         size_t curr_buffer_num = dcqs.completed_buffers_num();
   138         // If the number of the buffers falls down into the yellow zone,
   140         // If the number of the buffers falls down into the yellow zone,
   139         // that means that the transition period after the evacuation pause has ended.
   141         // that means that the transition period after the evacuation pause has ended.
   140         if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) {
   142         if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) {
   141           dcqs.set_completed_queue_padding(0);
   143           dcqs.set_completed_queue_padding(0);
   142         }
   144         }
   149                                                       _worker_id + _worker_id_offset,
   151                                                       _worker_id + _worker_id_offset,
   150                                                       _deactivation_threshold,
   152                                                       _deactivation_threshold,
   151                                                       false /* during_pause */));
   153                                                       false /* during_pause */));
   152 
   154 
   153       deactivate();
   155       deactivate();
   154       log_debug(gc, refine)("Deactivated %d, off threshold: %d, current: %d",
   156       log_debug(gc, refine)("Deactivated %d, off threshold: " SIZE_FORMAT ", current: " SIZE_FORMAT,
   155                             _worker_id, _deactivation_threshold,
   157                             _worker_id, _deactivation_threshold,
   156                             dcqs.completed_buffers_num());
   158                             dcqs.completed_buffers_num());
   157     }
   159     }
   158 
   160 
   159     if (os::supports_vtime()) {
   161     if (os::supports_vtime()) {