142 // without needing to check for overflow in "x OP y", because the |
142 // without needing to check for overflow in "x OP y", because the |
143 // ranges for x and y have been restricted. |
143 // ranges for x and y have been restricted. |
144 STATIC_ASSERT(sizeof(LP64_ONLY(jint) NOT_LP64(jshort)) <= (sizeof(size_t)/2)); |
144 STATIC_ASSERT(sizeof(LP64_ONLY(jint) NOT_LP64(jshort)) <= (sizeof(size_t)/2)); |
145 const size_t max_yellow_zone = LP64_ONLY(max_jint) NOT_LP64(max_jshort); |
145 const size_t max_yellow_zone = LP64_ONLY(max_jint) NOT_LP64(max_jshort); |
146 const size_t max_green_zone = max_yellow_zone / 2; |
146 const size_t max_green_zone = max_yellow_zone / 2; |
147 const size_t max_red_zone = INT_MAX; // For dcqs.set_max_completed_queue. |
147 const size_t max_red_zone = INT_MAX; // For dcqs.set_max_completed_buffers. |
148 STATIC_ASSERT(max_yellow_zone <= max_red_zone); |
148 STATIC_ASSERT(max_yellow_zone <= max_red_zone); |
149 |
149 |
150 // Range check assertions for green zone values. |
150 // Range check assertions for green zone values. |
151 #define assert_zone_constraints_g(green) \ |
151 #define assert_zone_constraints_g(green) \ |
152 do { \ |
152 do { \ |
384 update_zones(update_rs_time, update_rs_processed_buffers, goal_ms); |
384 update_zones(update_rs_time, update_rs_processed_buffers, goal_ms); |
385 |
385 |
386 // Change the barrier params |
386 // Change the barrier params |
387 if (max_num_threads() == 0) { |
387 if (max_num_threads() == 0) { |
388 // Disable dcqs notification when there are no threads to notify. |
388 // Disable dcqs notification when there are no threads to notify. |
389 dcqs.set_process_completed_threshold(INT_MAX); |
389 dcqs.set_process_completed_buffers_threshold(DirtyCardQueueSet::ProcessCompletedBuffersThresholdNever); |
390 } else { |
390 } else { |
391 // Worker 0 is the primary; wakeup is via dcqs notification. |
391 // Worker 0 is the primary; wakeup is via dcqs notification. |
392 STATIC_ASSERT(max_yellow_zone <= INT_MAX); |
392 STATIC_ASSERT(max_yellow_zone <= INT_MAX); |
393 size_t activate = activation_threshold(0); |
393 size_t activate = activation_threshold(0); |
394 dcqs.set_process_completed_threshold((int)activate); |
394 dcqs.set_process_completed_buffers_threshold(activate); |
395 } |
395 } |
396 dcqs.set_max_completed_queue((int)red_zone()); |
396 dcqs.set_max_completed_buffers(red_zone()); |
397 } |
397 } |
398 |
398 |
399 size_t curr_queue_size = dcqs.completed_buffers_num(); |
399 size_t curr_queue_size = dcqs.completed_buffers_num(); |
400 if (curr_queue_size >= yellow_zone()) { |
400 if ((dcqs.max_completed_buffers() > 0) && |
401 dcqs.set_completed_queue_padding(curr_queue_size); |
401 (curr_queue_size >= yellow_zone())) { |
|
402 dcqs.set_completed_buffers_padding(curr_queue_size); |
402 } else { |
403 } else { |
403 dcqs.set_completed_queue_padding(0); |
404 dcqs.set_completed_buffers_padding(0); |
404 } |
405 } |
405 dcqs.notify_if_necessary(); |
406 dcqs.notify_if_necessary(); |
406 } |
407 } |
407 |
408 |
408 size_t G1ConcurrentRefine::activation_threshold(uint worker_id) const { |
409 size_t G1ConcurrentRefine::activation_threshold(uint worker_id) const { |
431 size_t curr_buffer_num = dcqs.completed_buffers_num(); |
432 size_t curr_buffer_num = dcqs.completed_buffers_num(); |
432 // If the number of the buffers falls down into the yellow zone, |
433 // If the number of the buffers falls down into the yellow zone, |
433 // that means that the transition period after the evacuation pause has ended. |
434 // that means that the transition period after the evacuation pause has ended. |
434 // Since the value written to the DCQS is the same for all threads, there is no |
435 // Since the value written to the DCQS is the same for all threads, there is no |
435 // need to synchronize. |
436 // need to synchronize. |
436 if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= yellow_zone()) { |
437 if (dcqs.completed_buffers_padding() > 0 && curr_buffer_num <= yellow_zone()) { |
437 dcqs.set_completed_queue_padding(0); |
438 dcqs.set_completed_buffers_padding(0); |
438 } |
439 } |
439 |
440 |
440 maybe_activate_more_threads(worker_id, curr_buffer_num); |
441 maybe_activate_more_threads(worker_id, curr_buffer_num); |
441 |
442 |
442 // Process the next buffer, if there are enough left. |
443 // Process the next buffer, if there are enough left. |