8078021: SATB apply_closure_to_completed_buffer should have closure argument
authorkbarrett
Fri, 17 Apr 2015 13:49:04 -0400
changeset 30268 d28a9aa10804
parent 30267 e35e0c092042
child 30269 041d6fdcfa65
8078021: SATB apply_closure_to_completed_buffer should have closure argument Summary: Apply closure directly, eliminating registration. Reviewed-by: stefank, tschatzl
hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp
hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Fri Apr 17 16:08:41 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Fri Apr 17 13:49:04 2015 -0400
@@ -3720,12 +3720,11 @@
 
   CMObjectClosure oc(this);
   SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
-  satb_mq_set.set_closure(_worker_id, &oc);
 
   // This keeps claiming and applying the closure to completed buffers
   // until we run out of buffers or we need to abort.
   while (!has_aborted() &&
-         satb_mq_set.apply_closure_to_completed_buffer(_worker_id)) {
+         satb_mq_set.apply_closure_to_completed_buffer(&oc)) {
     if (_cm->verbose_medium()) {
       gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id);
     }
@@ -3739,8 +3738,6 @@
          concurrent() ||
          satb_mq_set.completed_buffers_num() == 0, "invariant");
 
-  satb_mq_set.set_closure(_worker_id, NULL);
-
   // again, this was a potentially expensive operation, decrease the
   // limits to get the regular clock call early
   decrease_limits();
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp	Fri Apr 17 16:08:41 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp	Fri Apr 17 13:49:04 2015 -0400
@@ -225,7 +225,7 @@
 #endif // _MSC_VER
 
 SATBMarkQueueSet::SATBMarkQueueSet() :
-  PtrQueueSet(), _closures(NULL),
+  PtrQueueSet(),
   _shared_satb_queue(this, true /*perm*/) { }
 
 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
@@ -233,7 +233,6 @@
                                   Mutex* lock) {
   PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
   _shared_satb_queue.set_lock(lock);
-  _closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads, mtGC);
 }
 
 void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
@@ -296,13 +295,7 @@
   shared_satb_queue()->filter();
 }
 
-void SATBMarkQueueSet::set_closure(uint worker, ObjectClosure* closure) {
-  assert(_closures != NULL, "Precondition");
-  assert(worker < ParallelGCThreads, "Worker index must be in range [0...ParallelGCThreads)");
-  _closures[worker] = closure;
-}
-
-bool SATBMarkQueueSet::apply_closure_to_completed_buffer(uint worker) {
+bool SATBMarkQueueSet::apply_closure_to_completed_buffer(ObjectClosure* cl) {
   BufferNode* nd = NULL;
   {
     MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
@@ -314,7 +307,6 @@
       if (_n_completed_buffers == 0) _process_completed = false;
     }
   }
-  ObjectClosure* cl = _closures[worker];
   if (nd != NULL) {
     void **buf = BufferNode::make_buffer_from_node(nd);
     ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp	Fri Apr 17 16:08:41 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp	Fri Apr 17 13:49:04 2015 -0400
@@ -75,8 +75,6 @@
 };
 
 class SATBMarkQueueSet: public PtrQueueSet {
-  ObjectClosure** _closures;  // One per ParGCThread.
-
   ObjPtrQueue _shared_satb_queue;
 
 #ifdef ASSERT
@@ -102,16 +100,10 @@
   // Filter all the currently-active SATB buffers.
   void filter_thread_buffers();
 
-  // Register closure for the given worker thread. The "apply_closure_to_completed_buffer"
-  // method will apply this closure to a completed buffer, and "iterate_closure_all_threads"
-  // applies it to partially-filled buffers (the latter should only be done
-  // with the world stopped).
-  void set_closure(uint worker, ObjectClosure* closure);
-
   // If there exists some completed buffer, pop it, then apply the
-  // registered closure to all its elements, and return true.  If no
+  // closure to all its elements, and return true.  If no
   // completed buffers exist, return false.
-  bool apply_closure_to_completed_buffer(uint worker);
+  bool apply_closure_to_completed_buffer(ObjectClosure* closure);
 
   // Apply the given closure on enqueued and currently-active buffers
   // respectively. Both methods are read-only, i.e., they do not