8183397: Ensure consistent closure filtering during evacuation
authortschatzl
Mon, 10 Jul 2017 10:10:49 +0200
changeset 46646 5165b3a5b44a
parent 46645 1a4335135ffd
child 46647 634dc786bf96
8183397: Ensure consistent closure filtering during evacuation Summary: Consistently apply the cross-region check for references in the various oop closures. Reviewed-by: sjohanss, ehelin
hotspot/src/share/vm/gc/g1/g1OopClosures.inline.hpp
hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp
hotspot/src/share/vm/gc/g1/g1ParScanThreadState.inline.hpp
--- a/hotspot/src/share/vm/gc/g1/g1OopClosures.inline.hpp	Fri Jul 07 23:53:36 2017 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1OopClosures.inline.hpp	Mon Jul 10 10:10:49 2017 +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);
   }
 }
--- a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp	Fri Jul 07 23:53:36 2017 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp	Mon Jul 10 10:10:49 2017 +0200
@@ -100,9 +100,10 @@
   template <class T> void push_on_queue(T* ref);
 
   template <class T> 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)) {
--- a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.inline.hpp	Fri Jul 07 23:53:36 2017 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.inline.hpp	Mon Jul 10 10:10:49 2017 +0200
@@ -51,11 +51,13 @@
     _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());
+         "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 <class T> inline void G1ParScanThreadState::push_on_queue(T* ref) {