8178151: Clean up G1RemSet files
authortschatzl
Wed, 28 Jun 2017 14:15:56 +0200
changeset 46575 d6fb8a7a7843
parent 46574 9920d284b066
child 46576 0b817584e8a9
child 46578 43f78fdf4859
8178151: Clean up G1RemSet files Summary: Remove unnecessary class members, improve method visibility and naming Reviewed-by: ehelin, sjohanss
hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp
hotspot/src/share/vm/gc/g1/g1RemSet.cpp
hotspot/src/share/vm/gc/g1/g1RemSet.hpp
hotspot/src/share/vm/gc/g1/g1RemSet.inline.hpp
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Wed Jun 28 12:11:55 2017 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Wed Jun 28 14:15:56 2017 +0200
@@ -1108,7 +1108,7 @@
 
 class RebuildRSOutOfRegionClosure: public HeapRegionClosure {
   G1CollectedHeap*   _g1h;
-  UpdateRSOopClosure _cl;
+  RebuildRSOopClosure _cl;
 public:
   RebuildRSOutOfRegionClosure(G1CollectedHeap* g1, uint worker_i = 0) :
     _cl(g1->g1_rem_set(), worker_i),
--- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp	Wed Jun 28 12:11:55 2017 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp	Wed Jun 28 14:15:56 2017 +0200
@@ -326,10 +326,10 @@
   }
 }
 
-G1ScanRSClosure::G1ScanRSClosure(G1RemSetScanState* scan_state,
-                                 G1ScanObjsDuringScanRSClosure* scan_obj_on_card,
-                                 CodeBlobClosure* code_root_cl,
-                                 uint worker_i) :
+G1ScanRSForRegionClosure::G1ScanRSForRegionClosure(G1RemSetScanState* scan_state,
+                                                   G1ScanObjsDuringScanRSClosure* scan_obj_on_card,
+                                                   CodeBlobClosure* code_root_cl,
+                                                   uint worker_i) :
   _scan_state(scan_state),
   _scan_objs_on_card_cl(scan_obj_on_card),
   _code_root_cl(code_root_cl),
@@ -341,10 +341,9 @@
   _g1h = G1CollectedHeap::heap();
   _bot = _g1h->bot();
   _ct_bs = _g1h->g1_barrier_set();
-  _block_size = MAX2<size_t>(G1RSetScanBlockSize, 1);
 }
 
-void G1ScanRSClosure::scan_card(size_t index, HeapWord* card_start, HeapRegion *r) {
+void G1ScanRSForRegionClosure::scan_card(size_t index, HeapWord* card_start, HeapRegion *r) {
   MemRegion card_region(card_start, BOTConstants::N_words);
   MemRegion pre_gc_allocated(r->bottom(), _scan_state->scan_top(r->hrm_index()));
   MemRegion mr = pre_gc_allocated.intersection(card_region);
@@ -359,13 +358,13 @@
   }
 }
 
-void G1ScanRSClosure::scan_strong_code_roots(HeapRegion* r) {
+void G1ScanRSForRegionClosure::scan_strong_code_roots(HeapRegion* r) {
   double scan_start = os::elapsedTime();
   r->strong_code_roots_do(_code_root_cl);
   _strong_code_root_scan_time_sec += (os::elapsedTime() - scan_start);
 }
 
-bool G1ScanRSClosure::doHeapRegion(HeapRegion* r) {
+bool G1ScanRSForRegionClosure::doHeapRegion(HeapRegion* r) {
   assert(r->in_collection_set(), "should only be called on elements of CS.");
   uint region_idx = r->hrm_index();
 
@@ -379,15 +378,16 @@
     _scan_state->add_dirty_region(region_idx);
   }
 
+  // We claim cards in blocks so as to reduce the contention.
+  size_t const block_size = G1RSetScanBlockSize;
+
   HeapRegionRemSetIterator iter(r->rem_set());
   size_t card_index;
 
-  // We claim cards in block so as to reduce the contention. The block size is determined by
-  // the G1RSetScanBlockSize parameter.
-  size_t claimed_card_block = _scan_state->iter_claimed_next(region_idx, _block_size);
+  size_t claimed_card_block = _scan_state->iter_claimed_next(region_idx, block_size);
   for (size_t current_card = 0; iter.has_next(card_index); current_card++) {
-    if (current_card >= claimed_card_block + _block_size) {
-      claimed_card_block = _scan_state->iter_claimed_next(region_idx, _block_size);
+    if (current_card >= claimed_card_block + block_size) {
+      claimed_card_block = _scan_state->iter_claimed_next(region_idx, block_size);
     }
     if (current_card < claimed_card_block) {
       _cards_skipped++;
@@ -419,7 +419,7 @@
   double rs_time_start = os::elapsedTime();
 
   G1ScanObjsDuringScanRSClosure scan_cl(_g1, pss);
-  G1ScanRSClosure cl(_scan_state, &scan_cl, heap_region_codeblobs, worker_i);
+  G1ScanRSForRegionClosure cl(_scan_state, &scan_cl, heap_region_codeblobs, worker_i);
   _g1->collection_set_iterate_from(&cl, worker_i);
 
   double scan_rs_time_sec = (os::elapsedTime() - rs_time_start) -
--- a/hotspot/src/share/vm/gc/g1/g1RemSet.hpp	Wed Jun 28 12:11:55 2017 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1RemSet.hpp	Wed Jun 28 14:15:56 2017 +0200
@@ -65,6 +65,16 @@
   // set in the event of an evacuation failure.
   DirtyCardQueueSet _into_cset_dirty_card_queue_set;
 
+  // Scan all remembered sets of the collection set for references into the collection
+  // set.
+  void scan_rem_set(G1ParScanThreadState* pss,
+                    CodeBlobClosure* heap_region_codeblobs,
+                    uint worker_i);
+
+  // Flush remaining refinement buffers for cross-region references to either evacuate references
+  // into the collection set or update the remembered set.
+  void update_rem_set(DirtyCardQueue* into_cset_dcq, G1ParScanThreadState* pss, uint worker_i);
+
 protected:
   G1CollectedHeap* _g1;
   size_t _conc_refine_cards;
@@ -107,39 +117,28 @@
 
   // Prepare for and cleanup after an oops_into_collection_set_do
   // call.  Must call each of these once before and after (in sequential
-  // code) any threads call oops_into_collection_set_do.  (This offers an
-  // opportunity to sequential setup and teardown of structures needed by a
-  // parallel iteration over the CS's RS.)
+  // code) any thread calls oops_into_collection_set_do.
   void prepare_for_oops_into_collection_set_do();
   void cleanup_after_oops_into_collection_set_do();
 
-  void scan_rem_set(G1ParScanThreadState* pss,
-                    CodeBlobClosure* heap_region_codeblobs,
-                    uint worker_i);
-
   G1RemSetScanState* scan_state() const { return _scan_state; }
 
-  // Flush remaining refinement buffers into the remembered set.
-  void update_rem_set(DirtyCardQueue* into_cset_dcq, G1ParScanThreadState* pss, uint worker_i);
-
   // Record, if necessary, the fact that *p (where "p" is in region "from",
   // which is required to be non-NULL) has changed to a new non-NULL value.
   template <class T> void par_write_ref(HeapRegion* from, T* p, uint tid);
 
-  // Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region
-  // or card, respectively, such that a region or card with a corresponding
-  // 0 bit contains no part of any live object.  Eliminates any remembered
-  // set entries that correspond to dead heap ranges. "worker_num" is the
-  // parallel thread id of the current thread, and "hrclaimer" is the
-  // HeapRegionClaimer that should be used.
+  // Eliminates any remembered set entries that correspond to dead heap ranges.
   void scrub(uint worker_num, HeapRegionClaimer* hrclaimer);
 
-  // Refine the card corresponding to "card_ptr".
+  // Refine the card corresponding to "card_ptr". Safe to be called concurrently
+  // to the mutator.
   void refine_card_concurrently(jbyte* card_ptr,
                                 uint worker_i);
 
-  // Refine the card corresponding to "card_ptr". Returns "true" if the given card contains
-  // oops that have references into the current collection set.
+  // Refine the card corresponding to "card_ptr", applying the given closure to
+  // all references found. Returns "true" if the given card contains
+  // oops that have references into the current collection set. Must only be
+  // called during gc.
   bool refine_card_during_gc(jbyte* card_ptr,
                              G1ScanObjsDuringUpdateRSClosure* update_rs_cl);
 
@@ -152,9 +151,7 @@
   // Prepare remembered set for verification.
   void prepare_for_verify();
 
-  size_t conc_refine_cards() const {
-    return _conc_refine_cards;
-  }
+  size_t conc_refine_cards() const { return _conc_refine_cards; }
 
   void create_card_live_data(WorkGang* workers, G1CMBitMap* mark_bitmap);
   void finalize_card_live_data(WorkGang* workers, G1CMBitMap* mark_bitmap);
@@ -170,7 +167,7 @@
 #endif
 };
 
-class G1ScanRSClosure : public HeapRegionClosure {
+class G1ScanRSForRegionClosure : public HeapRegionClosure {
   G1RemSetScanState* _scan_state;
 
   size_t _cards_scanned;
@@ -187,15 +184,14 @@
 
   double _strong_code_root_scan_time_sec;
   uint   _worker_i;
-  size_t _block_size;
 
   void scan_card(size_t index, HeapWord* card_start, HeapRegion *r);
   void scan_strong_code_roots(HeapRegion* r);
 public:
-  G1ScanRSClosure(G1RemSetScanState* scan_state,
-                  G1ScanObjsDuringScanRSClosure* scan_obj_on_card,
-                  CodeBlobClosure* code_root_cl,
-                  uint worker_i);
+  G1ScanRSForRegionClosure(G1RemSetScanState* scan_state,
+                           G1ScanObjsDuringScanRSClosure* scan_obj_on_card,
+                           CodeBlobClosure* code_root_cl,
+                           uint worker_i);
 
   bool doHeapRegion(HeapRegion* r);
 
@@ -208,7 +204,7 @@
   size_t cards_skipped() const { return _cards_skipped; }
 };
 
-class UpdateRSOopClosure: public ExtendedOopClosure {
+class RebuildRSOopClosure: public ExtendedOopClosure {
   HeapRegion* _from;
   G1RemSet* _rs;
   uint _worker_i;
@@ -216,7 +212,7 @@
   template <class T> void do_oop_work(T* p);
 
 public:
-  UpdateRSOopClosure(G1RemSet* rs, uint worker_i = 0) :
+  RebuildRSOopClosure(G1RemSet* rs, uint worker_i = 0) :
     _from(NULL), _rs(rs), _worker_i(worker_i)
   {}
 
--- a/hotspot/src/share/vm/gc/g1/g1RemSet.inline.hpp	Wed Jun 28 12:11:55 2017 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1RemSet.inline.hpp	Wed Jun 28 14:15:56 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@
 }
 
 template <class T>
-inline void UpdateRSOopClosure::do_oop_work(T* p) {
+inline void RebuildRSOopClosure::do_oop_work(T* p) {
   assert(_from != NULL, "from region must be non-NULL");
   _rs->par_write_ref(_from, p, _worker_i);
 }