8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
authorehelin
Fri, 27 Nov 2015 13:39:56 +0100
changeset 34617 943740ea0d17
parent 34616 421a6405ca30
child 34618 445eb59995bb
8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved Reviewed-by: tschatzl, mgerdin
hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp
hotspot/src/share/vm/gc/g1/heapRegion.hpp
--- a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp	Fri Nov 27 13:39:50 2015 +0100
+++ b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp	Fri Nov 27 13:39:56 2015 +0100
@@ -101,7 +101,7 @@
   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 (!from->is_in_reserved(o) && !from->is_young()) {
+    if (!HeapRegion::is_in_same_region(p, o) && !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/heapRegion.hpp	Fri Nov 27 13:39:50 2015 +0100
+++ b/hotspot/src/share/vm/gc/g1/heapRegion.hpp	Fri Nov 27 13:39:56 2015 +0100
@@ -351,6 +351,15 @@
                                       ~((1 << (size_t) LogOfHRGrainBytes) - 1);
   }
 
+
+  // Returns whether a field is in the same region as the obj it points to.
+  template <typename T>
+  static bool is_in_same_region(T* p, oop obj) {
+    assert(p != NULL, "p can't be NULL");
+    assert(obj != NULL, "obj can't be NULL");
+    return (((uintptr_t) p ^ cast_from_oop<uintptr_t>(obj)) >> LogOfHRGrainBytes) == 0;
+  }
+
   static size_t max_region_size();
   static size_t min_region_size_in_words();