diff -r 14ef0f74667b -r 21fdf8d9a8b6 src/hotspot/share/gc/g1/g1OopClosures.inline.hpp --- a/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp Wed Oct 31 13:43:57 2018 +0100 +++ b/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp Wed Oct 31 13:43:57 2018 +0100 @@ -82,12 +82,12 @@ const InCSetState state = _g1h->in_cset_state(obj); if (state.is_in_cset()) { prefetch_and_push(p, obj); - } else { - if (HeapRegion::is_in_same_region(p, obj)) { + } else if (!HeapRegion::is_in_same_region(p, obj)) { + handle_non_cset_obj_common(state, p, obj); + if (_scanning_in_young) { return; } - handle_non_cset_obj_common(state, p, obj); - _par_scan_state->update_rs(_from, p, obj); + _par_scan_state->enqueue_card_if_tracked(p, obj); } } @@ -172,13 +172,9 @@ // Since the source is always from outside the collection set, here we implicitly know // that this is a cross-region reference too. prefetch_and_push(p, obj); - } else { - HeapRegion* to = _g1h->heap_region_containing(obj); - if (_from == to) { - return; - } + } else if (!HeapRegion::is_in_same_region(p, obj)) { handle_non_cset_obj_common(state, p, obj); - to->rem_set()->add_reference(p, _worker_i); + _par_scan_state->enqueue_card_if_tracked(p, obj); } } @@ -193,10 +189,7 @@ const InCSetState state = _g1h->in_cset_state(obj); if (state.is_in_cset()) { prefetch_and_push(p, obj); - } else { - if (HeapRegion::is_in_same_region(p, obj)) { - return; - } + } else if (!HeapRegion::is_in_same_region(p, obj)) { handle_non_cset_obj_common(state, p, obj); } }