< prev index next >
src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
Print this page
*** 2176,2257 ****
_mark_stats_cache.reset();
}
bool G1CMTask::should_exit_termination() {
! regular_clock_call();
// This is called when we are in the termination protocol. We should
// quit if, for some reason, this task wants to abort or the global
// stack is not empty (this means that we can get work from it).
return !_cm->mark_stack_empty() || has_aborted();
}
void G1CMTask::reached_limit() {
assert(_words_scanned >= _words_scanned_limit ||
_refs_reached >= _refs_reached_limit ,
"shouldn't have been called otherwise");
! regular_clock_call();
}
! void G1CMTask::regular_clock_call() {
if (has_aborted()) {
! return;
}
// First, we need to recalculate the words scanned and refs reached
// limits for the next clock call.
recalculate_limits();
// During the regular clock call we do the following
// (1) If an overflow has been flagged, then we abort.
if (_cm->has_overflown()) {
! set_has_aborted();
! return;
}
// If we are not concurrent (i.e. we're doing remark) we don't need
// to check anything else. The other steps are only needed during
// the concurrent marking phase.
if (!_cm->concurrent()) {
! return;
}
// (2) If marking has been aborted for Full GC, then we also abort.
if (_cm->has_aborted()) {
! set_has_aborted();
! return;
}
double curr_time_ms = os::elapsedVTime() * 1000.0;
// (4) We check whether we should yield. If we have to, then we abort.
if (SuspendibleThreadSet::should_yield()) {
// We should yield. To do this we abort the task. The caller is
// responsible for yielding.
! set_has_aborted();
! return;
}
// (5) We check whether we've reached our time quota. If we have,
// then we abort.
double elapsed_time_ms = curr_time_ms - _start_time_ms;
if (elapsed_time_ms > _time_target_ms) {
- set_has_aborted();
_has_timed_out = true;
! return;
}
// (6) Finally, we check whether there are enough completed STAB
// buffers available for processing. If there are, we abort.
SATBMarkQueueSet& satb_mq_set = G1BarrierSet::satb_mark_queue_set();
if (!_draining_satb_buffers && satb_mq_set.process_completed_buffers()) {
// we do need to process SATB buffers, we'll abort and restart
// the marking task to do so
! set_has_aborted();
! return;
}
}
void G1CMTask::recalculate_limits() {
_real_words_scanned_limit = _words_scanned + words_scanned_period;
_words_scanned_limit = _real_words_scanned_limit;
--- 2176,2258 ----
_mark_stats_cache.reset();
}
bool G1CMTask::should_exit_termination() {
! if (!regular_clock_call()) {
! return true;
! }
!
// This is called when we are in the termination protocol. We should
// quit if, for some reason, this task wants to abort or the global
// stack is not empty (this means that we can get work from it).
return !_cm->mark_stack_empty() || has_aborted();
}
void G1CMTask::reached_limit() {
assert(_words_scanned >= _words_scanned_limit ||
_refs_reached >= _refs_reached_limit ,
"shouldn't have been called otherwise");
! if (!regular_clock_call()) {
! set_has_aborted();
! }
}
! bool G1CMTask::regular_clock_call() {
if (has_aborted()) {
! return false;
}
// First, we need to recalculate the words scanned and refs reached
// limits for the next clock call.
recalculate_limits();
// During the regular clock call we do the following
// (1) If an overflow has been flagged, then we abort.
if (_cm->has_overflown()) {
! return false;
}
// If we are not concurrent (i.e. we're doing remark) we don't need
// to check anything else. The other steps are only needed during
// the concurrent marking phase.
if (!_cm->concurrent()) {
! return true;
}
// (2) If marking has been aborted for Full GC, then we also abort.
if (_cm->has_aborted()) {
! return false;
}
double curr_time_ms = os::elapsedVTime() * 1000.0;
// (4) We check whether we should yield. If we have to, then we abort.
if (SuspendibleThreadSet::should_yield()) {
// We should yield. To do this we abort the task. The caller is
// responsible for yielding.
! return false;
}
// (5) We check whether we've reached our time quota. If we have,
// then we abort.
double elapsed_time_ms = curr_time_ms - _start_time_ms;
if (elapsed_time_ms > _time_target_ms) {
_has_timed_out = true;
! return false;
}
// (6) Finally, we check whether there are enough completed STAB
// buffers available for processing. If there are, we abort.
SATBMarkQueueSet& satb_mq_set = G1BarrierSet::satb_mark_queue_set();
if (!_draining_satb_buffers && satb_mq_set.process_completed_buffers()) {
// we do need to process SATB buffers, we'll abort and restart
// the marking task to do so
! return false;
}
+ return true;
}
void G1CMTask::recalculate_limits() {
_real_words_scanned_limit = _words_scanned + words_scanned_period;
_words_scanned_limit = _real_words_scanned_limit;
*** 2402,2412 ****
// This keeps claiming and applying the closure to completed buffers
// until we run out of buffers or we need to abort.
while (!has_aborted() &&
satb_mq_set.apply_closure_to_completed_buffer(&satb_cl)) {
! regular_clock_call();
}
_draining_satb_buffers = false;
assert(has_aborted() ||
--- 2403,2415 ----
// This keeps claiming and applying the closure to completed buffers
// until we run out of buffers or we need to abort.
while (!has_aborted() &&
satb_mq_set.apply_closure_to_completed_buffer(&satb_cl)) {
! if(!regular_clock_call()) {
! set_has_aborted();
! }
}
_draining_satb_buffers = false;
assert(has_aborted() ||
*** 2645,2667 ****
// Otherwise, let's iterate over the bitmap of the part of the region
// that is left.
// If the iteration is successful, give up the region.
if (mr.is_empty()) {
giveup_current_region();
! regular_clock_call();
} else if (_curr_region->is_humongous() && mr.start() == _curr_region->bottom()) {
if (_next_mark_bitmap->is_marked(mr.start())) {
// The object is marked - apply the closure
bitmap_closure.do_addr(mr.start());
}
// Even if this task aborted while scanning the humongous object
// we can (and should) give up the current region.
giveup_current_region();
! regular_clock_call();
} else if (_next_mark_bitmap->iterate(&bitmap_closure, mr)) {
giveup_current_region();
! regular_clock_call();
} else {
assert(has_aborted(), "currently the only way to do so");
// The only way to abort the bitmap iteration is to return
// false from the do_bit() method. However, inside the
// do_bit() method we move the _finger to point to the
--- 2648,2676 ----
// Otherwise, let's iterate over the bitmap of the part of the region
// that is left.
// If the iteration is successful, give up the region.
if (mr.is_empty()) {
giveup_current_region();
! if (!regular_clock_call()) {
! set_has_aborted();
! }
} else if (_curr_region->is_humongous() && mr.start() == _curr_region->bottom()) {
if (_next_mark_bitmap->is_marked(mr.start())) {
// The object is marked - apply the closure
bitmap_closure.do_addr(mr.start());
}
// Even if this task aborted while scanning the humongous object
// we can (and should) give up the current region.
giveup_current_region();
! if (!regular_clock_call()) {
! set_has_aborted();
! }
} else if (_next_mark_bitmap->iterate(&bitmap_closure, mr)) {
giveup_current_region();
! if (!regular_clock_call()) {
! set_has_aborted();
! }
} else {
assert(has_aborted(), "currently the only way to do so");
// The only way to abort the bitmap iteration is to return
// false from the do_bit() method. However, inside the
// do_bit() method we move the _finger to point to the
*** 2712,2722 ****
// It is important to call the regular clock here. It might take
// a while to claim a region if, for example, we hit a large
// block of empty regions. So we need to call the regular clock
// method once round the loop to make sure it's called
// frequently enough.
! regular_clock_call();
}
if (!has_aborted() && _curr_region == NULL) {
assert(_cm->out_of_regions(),
"at this point we should be out of regions");
--- 2721,2733 ----
// It is important to call the regular clock here. It might take
// a while to claim a region if, for example, we hit a large
// block of empty regions. So we need to call the regular clock
// method once round the loop to make sure it's called
// frequently enough.
! if (!regular_clock_call()) {
! set_has_aborted();
! }
}
if (!has_aborted() && _curr_region == NULL) {
assert(_cm->out_of_regions(),
"at this point we should be out of regions");
*** 2790,2799 ****
--- 2801,2811 ----
// which one.
guarantee(_cm->out_of_regions(), "only way to reach here");
guarantee(_cm->mark_stack_empty(), "only way to reach here");
guarantee(_task_queue->size() == 0, "only way to reach here");
guarantee(!_cm->has_overflown(), "only way to reach here");
+ guarantee(!has_aborted(), "should never happen if termination is completed");
} else {
// Apparently there's more work to do. Let's abort this task. It
// will restart it and we can hopefully find more things to do.
set_has_aborted();
}
< prev index next >