8139200: Eliminate G1ParClosureSuper::_worker_id
authorkbarrett
Thu, 15 Oct 2015 10:10:13 -0400
changeset 33224 bc5da96c1f0e
parent 33223 3c964cd8be5c
child 33225 7fc698d6044c
8139200: Eliminate G1ParClosureSuper::_worker_id Summary: Moved _worker_id from G1ParClosureSuper to G1ParCopyHelper. Reviewed-by: mgerdin, tschatzl
hotspot/src/share/vm/gc/g1/g1OopClosures.cpp
hotspot/src/share/vm/gc/g1/g1OopClosures.hpp
hotspot/src/share/vm/gc/g1/g1OopClosures.inline.hpp
hotspot/src/share/vm/gc/g1/g1ParScanThreadState.cpp
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.cpp	Fri Oct 16 00:01:49 2015 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1OopClosures.cpp	Thu Oct 15 10:10:13 2015 -0400
@@ -31,32 +31,15 @@
 #include "utilities/stack.inline.hpp"
 
 G1ParCopyHelper::G1ParCopyHelper(G1CollectedHeap* g1,  G1ParScanThreadState* par_scan_state) :
-  G1ParClosureSuper(g1, par_scan_state), _scanned_klass(NULL),
-  _cm(_g1->concurrent_mark()) { }
-
-G1ParCopyHelper::G1ParCopyHelper(G1CollectedHeap* g1) :
-  G1ParClosureSuper(g1), _scanned_klass(NULL),
-  _cm(_g1->concurrent_mark()) { }
-
-G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1) :
-  _g1(g1), _par_scan_state(NULL), _worker_id(UINT_MAX) { }
+  G1ParClosureSuper(g1, par_scan_state),
+  _worker_id(par_scan_state->worker_id()),
+  _scanned_klass(NULL),
+  _cm(_g1->concurrent_mark())
+{ }
 
 G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
-  _g1(g1), _par_scan_state(NULL),
-  _worker_id(UINT_MAX) {
-  set_par_scan_thread_state(par_scan_state);
-}
-
-void G1ParClosureSuper::set_par_scan_thread_state(G1ParScanThreadState* par_scan_state) {
-  assert(_par_scan_state == NULL, "_par_scan_state must only be set once");
-  assert(par_scan_state != NULL, "Must set par_scan_state to non-NULL.");
-
-  _par_scan_state = par_scan_state;
-  _worker_id = par_scan_state->worker_id();
-
-  assert(_worker_id < ParallelGCThreads,
-         "The given worker id %u must be less than the number of threads %u", _worker_id, ParallelGCThreads);
-}
+  _g1(g1), _par_scan_state(par_scan_state)
+{ }
 
 void G1KlassScanClosure::do_klass(Klass* klass) {
   // If the klass has not been dirtied we know that there's
--- a/hotspot/src/share/vm/gc/g1/g1OopClosures.hpp	Fri Oct 16 00:01:49 2015 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1OopClosures.hpp	Thu Oct 15 10:10:13 2015 -0400
@@ -52,15 +52,12 @@
 protected:
   G1CollectedHeap* _g1;
   G1ParScanThreadState* _par_scan_state;
-  uint _worker_id;
+
+  G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
+  ~G1ParClosureSuper() { }
+
 public:
-  // Initializes the instance, leaving _par_scan_state uninitialized. Must be done
-  // later using the set_par_scan_thread_state() method.
-  G1ParClosureSuper(G1CollectedHeap* g1);
-  G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
-  bool apply_to_weak_ref_discovered_field() { return true; }
-
-  void set_par_scan_thread_state(G1ParScanThreadState* par_scan_state);
+  virtual bool apply_to_weak_ref_discovered_field() { return true; }
 };
 
 class G1ParPushHeapRSClosure : public G1ParClosureSuper {
@@ -76,7 +73,8 @@
 
 class G1ParScanClosure : public G1ParClosureSuper {
 public:
-  G1ParScanClosure(G1CollectedHeap* g1) : G1ParClosureSuper(g1) { }
+  G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
+    G1ParClosureSuper(g1, par_scan_state) { }
 
   template <class T> void do_oop_nv(T* p);
   virtual void do_oop(oop* p)          { do_oop_nv(p); }
@@ -88,6 +86,7 @@
 // Add back base class for metadata
 class G1ParCopyHelper : public G1ParClosureSuper {
 protected:
+  uint _worker_id;              // Cache value from par_scan_state.
   Klass* _scanned_klass;
   ConcurrentMark* _cm;
 
@@ -100,10 +99,11 @@
   // objects pointed to by roots that have been forwarded during a
   // GC. It is MT-safe.
   inline void mark_forwarded_object(oop from_obj, oop to_obj);
- public:
+
   G1ParCopyHelper(G1CollectedHeap* g1,  G1ParScanThreadState* par_scan_state);
-  G1ParCopyHelper(G1CollectedHeap* g1);
+  ~G1ParCopyHelper() { }
 
+ public:
   void set_scanned_klass(Klass* k) { _scanned_klass = k; }
   template <class T> inline void do_klass_barrier(T* p, oop new_obj);
 };
@@ -130,10 +130,6 @@
     assert(_ref_processor == NULL, "sanity");
   }
 
-  G1ParCopyClosure(G1CollectedHeap* g1) : G1ParCopyHelper(g1) {
-    assert(_ref_processor == NULL, "sanity");
-  }
-
   template <class T> void do_oop_nv(T* p) { do_oop_work(p); }
   virtual void do_oop(oop* p)       { do_oop_nv(p); }
   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
--- a/hotspot/src/share/vm/gc/g1/g1OopClosures.inline.hpp	Fri Oct 16 00:01:49 2015 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1OopClosures.inline.hpp	Thu Oct 15 10:10:13 2015 -0400
@@ -91,7 +91,7 @@
       if (state.is_humongous()) {
         _g1->set_humongous_is_live(obj);
       }
-      _par_scan_state->update_rs(_from, p, _worker_id);
+      _par_scan_state->update_rs(_from, p);
     }
   }
 }
--- a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.cpp	Fri Oct 16 00:01:49 2015 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.cpp	Thu Oct 15 10:10:13 2015 -0400
@@ -43,10 +43,9 @@
     _worker_id(worker_id),
     _tenuring_threshold(g1h->g1_policy()->tenuring_threshold()),
     _age_table(false),
-    _scanner(g1h),
+    _scanner(g1h, this),
     _old_gen_is_full(false)
 {
-  _scanner.set_par_scan_thread_state(this);
   // we allocate G1YoungSurvRateNumRegions plus one entries, since
   // we "sacrifice" entry 0 to keep track of surviving bytes for
   // non-young regions (where the age is -1)
--- a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp	Fri Oct 16 00:01:49 2015 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp	Thu Oct 15 10:10:13 2015 -0400
@@ -98,7 +98,7 @@
 
   template <class T> void push_on_queue(T* ref);
 
-  template <class T> void update_rs(HeapRegion* from, T* p, uint tid) {
+  template <class T> void update_rs(HeapRegion* from, T* p) {
     // 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(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) {
--- a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.inline.hpp	Fri Oct 16 00:01:49 2015 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.inline.hpp	Thu Oct 15 10:10:13 2015 -0400
@@ -56,7 +56,7 @@
   }
 
   assert(obj != NULL, "Must be");
-  update_rs(from, p, _worker_id);
+  update_rs(from, p);
 }
 
 template <class T> inline void G1ParScanThreadState::push_on_queue(T* ref) {