--- old/src/share/vm/gc/g1/g1OopClosures.inline.hpp 2017-07-03 12:19:00.455833137 +0200 +++ new/src/share/vm/gc/g1/g1OopClosures.inline.hpp 2017-07-03 12:19:00.324829101 +0200 @@ -78,8 +78,10 @@ if (state.is_in_cset()) { prefetch_and_push(p, obj); } else { + if (HeapRegion::is_in_same_region(p, obj)) { + return; + } handle_non_cset_obj_common(state, p, obj); - _par_scan_state->update_rs(_from, p, obj); } } @@ -171,9 +173,7 @@ if (_from == to) { return; } - handle_non_cset_obj_common(state, p, obj); - to->rem_set()->add_reference(p, _worker_i); } } @@ -190,6 +190,9 @@ if (state.is_in_cset()) { prefetch_and_push(p, obj); } else { + if (HeapRegion::is_in_same_region(p, obj)) { + return; + } handle_non_cset_obj_common(state, p, obj); } } --- old/src/share/vm/gc/g1/g1ParScanThreadState.hpp 2017-07-03 12:19:01.097852920 +0200 +++ new/src/share/vm/gc/g1/g1ParScanThreadState.hpp 2017-07-03 12:19:00.965848853 +0200 @@ -100,9 +100,10 @@ template void push_on_queue(T* ref); template void update_rs(HeapRegion* from, T* p, oop o) { - // If the new value of the field points to the same region or - // is the to-space, we don't need to include it in the Rset updates. - if (!HeapRegion::is_in_same_region(p, o) && !from->is_young()) { + assert(!HeapRegion::is_in_same_region(p, o), "Caller should have filtered out cross-region references already."); + // If the field originates from the to-space, we don't need to include it + // in the remembered set updates. + if (!from->is_young()) { size_t card_index = ctbs()->index_for(p); // If the card hasn't been added to the buffer, do it. if (ctbs()->mark_card_deferred(card_index)) { --- old/src/share/vm/gc/g1/g1ParScanThreadState.inline.hpp 2017-07-03 12:19:01.760873350 +0200 +++ new/src/share/vm/gc/g1/g1ParScanThreadState.inline.hpp 2017-07-03 12:19:01.627869252 +0200 @@ -47,15 +47,19 @@ obj = copy_to_survivor_space(in_cset_state, obj, m); } oopDesc::encode_store_heap_oop(p, obj); - } else if (in_cset_state.is_humongous()) { - _g1h->set_humongous_is_live(obj); } else { - assert(in_cset_state.is_default() || in_cset_state.is_ext(), + if (in_cset_state.is_humongous()) { + _g1h->set_humongous_is_live(obj); + } else { + assert(in_cset_state.is_default() || in_cset_state.is_ext(), "In_cset_state must be NotInCSet or Ext here, but is " CSETSTATE_FORMAT, in_cset_state.value()); + } } assert(obj != NULL, "Must be"); - update_rs(from, p, obj); + if (!HeapRegion::is_in_same_region(p, obj)) { + update_rs(from, p, obj); + } } template inline void G1ParScanThreadState::push_on_queue(T* ref) {