8234000: Make HeapRegion::bottom/end/hrm_index const
authortschatzl
Fri, 22 Nov 2019 10:03:38 +0100
changeset 59220 72e15d757e6c
parent 59219 01cc6bb2a090
child 59221 cc3a82fc7bcb
8234000: Make HeapRegion::bottom/end/hrm_index const Reviewed-by: kbarrett, sjohanss
src/hotspot/share/gc/g1/heapRegion.cpp
src/hotspot/share/gc/g1/heapRegion.hpp
src/hotspot/share/gc/g1/heapRegionManager.cpp
src/hotspot/share/gc/g1/vmStructs_g1.hpp
--- a/src/hotspot/share/gc/g1/heapRegion.cpp	Fri Nov 22 10:03:38 2019 +0100
+++ b/src/hotspot/share/gc/g1/heapRegion.cpp	Fri Nov 22 10:03:38 2019 +0100
@@ -238,8 +238,8 @@
 HeapRegion::HeapRegion(uint hrm_index,
                        G1BlockOffsetTable* bot,
                        MemRegion mr) :
-  _bottom(NULL),
-  _end(NULL),
+  _bottom(mr.start()),
+  _end(mr.end()),
   _top(NULL),
   _compaction_top(NULL),
   _bot_part(bot, this),
@@ -262,19 +262,16 @@
   _recorded_rs_length(0), _predicted_elapsed_time_ms(0),
   _node_index(G1NUMA::UnknownNodeIndex)
 {
-  _rem_set = new HeapRegionRemSet(bot, this);
-
-  initialize(mr);
-}
-
-void HeapRegion::initialize(MemRegion mr, bool clear_space, bool mangle_space) {
-  assert(_rem_set->is_empty(), "Remembered set must be empty");
-
   assert(Universe::on_page_boundary(mr.start()) && Universe::on_page_boundary(mr.end()),
          "invalid space boundaries");
 
-  set_bottom(mr.start());
-  set_end(mr.end());
+  _rem_set = new HeapRegionRemSet(bot, this);
+  initialize();
+}
+
+void HeapRegion::initialize(bool clear_space, bool mangle_space) {
+  assert(_rem_set->is_empty(), "Remembered set must be empty");
+
   if (clear_space) {
     clear(mangle_space);
   }
--- a/src/hotspot/share/gc/g1/heapRegion.hpp	Fri Nov 22 10:03:38 2019 +0100
+++ b/src/hotspot/share/gc/g1/heapRegion.hpp	Fri Nov 22 10:03:38 2019 +0100
@@ -67,8 +67,8 @@
 class HeapRegion : public CHeapObj<mtGC> {
   friend class VMStructs;
 
-  HeapWord* _bottom;
-  HeapWord* _end;
+  HeapWord* const _bottom;
+  HeapWord* const _end;
 
   HeapWord* volatile _top;
   HeapWord* _compaction_top;
@@ -84,10 +84,7 @@
   HeapWord* _pre_dummy_top;
 
 public:
-  void set_bottom(HeapWord* value) { _bottom = value; }
   HeapWord* bottom() const         { return _bottom; }
-
-  void set_end(HeapWord* value)    { _end = value; }
   HeapWord* end() const            { return _end;    }
 
   void set_compaction_top(HeapWord* compaction_top) { _compaction_top = compaction_top; }
@@ -202,7 +199,7 @@
   HeapRegionRemSet* _rem_set;
 
   // Cached index of this region in the heap region sequence.
-  uint  _hrm_index;
+  const uint _hrm_index;
 
   HeapRegionType _type;
 
@@ -301,7 +298,7 @@
   // resets the BOT for that heap region.
   // The default values for clear_space means that we will do the clearing if
   // there's clearing to be done ourselves. We also always mangle the space.
-  void initialize(MemRegion mr, bool clear_space = false, bool mangle_space = SpaceDecorator::Mangle);
+  void initialize(bool clear_space = false, bool mangle_space = SpaceDecorator::Mangle);
 
   static int    LogOfHRGrainBytes;
   static int    LogOfHRGrainWords;
--- a/src/hotspot/share/gc/g1/heapRegionManager.cpp	Fri Nov 22 10:03:38 2019 +0100
+++ b/src/hotspot/share/gc/g1/heapRegionManager.cpp	Fri Nov 22 10:03:38 2019 +0100
@@ -217,10 +217,8 @@
     if (G1CollectedHeap::heap()->hr_printer()->is_active()) {
       G1CollectedHeap::heap()->hr_printer()->commit(hr);
     }
-    HeapWord* bottom = G1CollectedHeap::heap()->bottom_addr_for_region(i);
-    MemRegion mr(bottom, bottom + HeapRegion::GrainWords);
 
-    hr->initialize(mr);
+    hr->initialize();
     hr->set_node_index(G1NUMA::numa()->index_for_region(hr));
     insert_into_free_list(at(i));
   }
--- a/src/hotspot/share/gc/g1/vmStructs_g1.hpp	Fri Nov 22 10:03:38 2019 +0100
+++ b/src/hotspot/share/gc/g1/vmStructs_g1.hpp	Fri Nov 22 10:03:38 2019 +0100
@@ -38,9 +38,9 @@
   static_field(HeapRegion, LogOfHRGrainBytes, int)                            \
                                                                               \
   nonstatic_field(HeapRegion, _type,           HeapRegionType)                \
-  nonstatic_field(HeapRegion, _bottom,         HeapWord*)                     \
+  nonstatic_field(HeapRegion, _bottom,         HeapWord* const)               \
   nonstatic_field(HeapRegion, _top,            HeapWord* volatile)            \
-  nonstatic_field(HeapRegion, _end,            HeapWord*)                     \
+  nonstatic_field(HeapRegion, _end,            HeapWord* const)               \
   nonstatic_field(HeapRegion, _compaction_top, HeapWord*)                     \
                                                                               \
   nonstatic_field(HeapRegionType, _tag,       HeapRegionType::Tag volatile)   \