8078021: SATB apply_closure_to_completed_buffer should have closure argument

Fri, 17 Apr 2015 13:49:04 -0400

author
kbarrett
date
Fri, 17 Apr 2015 13:49:04 -0400
changeset 7832
b5d14ef905b5
parent 7831
2e5e058881f4
child 7833
0f8f1250fed5

8078021: SATB apply_closure_to_completed_buffer should have closure argument
Summary: Apply closure directly, eliminating registration.
Reviewed-by: stefank, tschatzl

src/share/vm/gc_implementation/g1/concurrentMark.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/satbQueue.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/satbQueue.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Apr 15 16:37:57 2015 -0400
     1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Fri Apr 17 13:49:04 2015 -0400
     1.3 @@ -4003,32 +4003,16 @@
     1.4  
     1.5    CMObjectClosure oc(this);
     1.6    SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
     1.7 -  if (G1CollectedHeap::use_parallel_gc_threads()) {
     1.8 -    satb_mq_set.set_par_closure(_worker_id, &oc);
     1.9 -  } else {
    1.10 -    satb_mq_set.set_closure(&oc);
    1.11 -  }
    1.12  
    1.13    // This keeps claiming and applying the closure to completed buffers
    1.14    // until we run out of buffers or we need to abort.
    1.15 -  if (G1CollectedHeap::use_parallel_gc_threads()) {
    1.16 -    while (!has_aborted() &&
    1.17 -           satb_mq_set.par_apply_closure_to_completed_buffer(_worker_id)) {
    1.18 -      if (_cm->verbose_medium()) {
    1.19 -        gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id);
    1.20 -      }
    1.21 -      statsOnly( ++_satb_buffers_processed );
    1.22 -      regular_clock_call();
    1.23 +  while (!has_aborted() &&
    1.24 +         satb_mq_set.apply_closure_to_completed_buffer(&oc)) {
    1.25 +    if (_cm->verbose_medium()) {
    1.26 +      gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id);
    1.27      }
    1.28 -  } else {
    1.29 -    while (!has_aborted() &&
    1.30 -           satb_mq_set.apply_closure_to_completed_buffer()) {
    1.31 -      if (_cm->verbose_medium()) {
    1.32 -        gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id);
    1.33 -      }
    1.34 -      statsOnly( ++_satb_buffers_processed );
    1.35 -      regular_clock_call();
    1.36 -    }
    1.37 +    statsOnly( ++_satb_buffers_processed );
    1.38 +    regular_clock_call();
    1.39    }
    1.40  
    1.41    _draining_satb_buffers = false;
    1.42 @@ -4037,12 +4021,6 @@
    1.43           concurrent() ||
    1.44           satb_mq_set.completed_buffers_num() == 0, "invariant");
    1.45  
    1.46 -  if (G1CollectedHeap::use_parallel_gc_threads()) {
    1.47 -    satb_mq_set.set_par_closure(_worker_id, NULL);
    1.48 -  } else {
    1.49 -    satb_mq_set.set_closure(NULL);
    1.50 -  }
    1.51 -
    1.52    // again, this was a potentially expensive operation, decrease the
    1.53    // limits to get the regular clock call early
    1.54    decrease_limits();
     2.1 --- a/src/share/vm/gc_implementation/g1/satbQueue.cpp	Wed Apr 15 16:37:57 2015 -0400
     2.2 +++ b/src/share/vm/gc_implementation/g1/satbQueue.cpp	Fri Apr 17 13:49:04 2015 -0400
     2.3 @@ -227,7 +227,7 @@
     2.4  #endif // _MSC_VER
     2.5  
     2.6  SATBMarkQueueSet::SATBMarkQueueSet() :
     2.7 -  PtrQueueSet(), _closure(NULL), _par_closures(NULL),
     2.8 +  PtrQueueSet(),
     2.9    _shared_satb_queue(this, true /*perm*/) { }
    2.10  
    2.11  void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
    2.12 @@ -235,9 +235,6 @@
    2.13                                    Mutex* lock) {
    2.14    PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
    2.15    _shared_satb_queue.set_lock(lock);
    2.16 -  if (ParallelGCThreads > 0) {
    2.17 -    _par_closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads, mtGC);
    2.18 -  }
    2.19  }
    2.20  
    2.21  void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
    2.22 @@ -300,17 +297,7 @@
    2.23    shared_satb_queue()->filter();
    2.24  }
    2.25  
    2.26 -void SATBMarkQueueSet::set_closure(ObjectClosure* closure) {
    2.27 -  _closure = closure;
    2.28 -}
    2.29 -
    2.30 -void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) {
    2.31 -  assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition");
    2.32 -  _par_closures[i] = par_closure;
    2.33 -}
    2.34 -
    2.35 -bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par,
    2.36 -                                                              uint worker) {
    2.37 +bool SATBMarkQueueSet::apply_closure_to_completed_buffer(ObjectClosure* cl) {
    2.38    BufferNode* nd = NULL;
    2.39    {
    2.40      MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
    2.41 @@ -322,7 +309,6 @@
    2.42        if (_n_completed_buffers == 0) _process_completed = false;
    2.43      }
    2.44    }
    2.45 -  ObjectClosure* cl = (par ? _par_closures[worker] : _closure);
    2.46    if (nd != NULL) {
    2.47      void **buf = BufferNode::make_buffer_from_node(nd);
    2.48      ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
     3.1 --- a/src/share/vm/gc_implementation/g1/satbQueue.hpp	Wed Apr 15 16:37:57 2015 -0400
     3.2 +++ b/src/share/vm/gc_implementation/g1/satbQueue.hpp	Fri Apr 17 13:49:04 2015 -0400
     3.3 @@ -75,16 +75,8 @@
     3.4  };
     3.5  
     3.6  class SATBMarkQueueSet: public PtrQueueSet {
     3.7 -  ObjectClosure* _closure;
     3.8 -  ObjectClosure** _par_closures;  // One per ParGCThread.
     3.9 -
    3.10    ObjPtrQueue _shared_satb_queue;
    3.11  
    3.12 -  // Utility function to support sequential and parallel versions.  If
    3.13 -  // "par" is true, then "worker" is the par thread id; if "false", worker
    3.14 -  // is ignored.
    3.15 -  bool apply_closure_to_completed_buffer_work(bool par, uint worker);
    3.16 -
    3.17  #ifdef ASSERT
    3.18    void dump_active_states(bool expected_active);
    3.19    void verify_active_states(bool expected_active);
    3.20 @@ -108,26 +100,10 @@
    3.21    // Filter all the currently-active SATB buffers.
    3.22    void filter_thread_buffers();
    3.23  
    3.24 -  // Register "blk" as "the closure" for all queues.  Only one such closure
    3.25 -  // is allowed.  The "apply_closure_to_completed_buffer" method will apply
    3.26 -  // this closure to a completed buffer, and "iterate_closure_all_threads"
    3.27 -  // applies it to partially-filled buffers (the latter should only be done
    3.28 -  // with the world stopped).
    3.29 -  void set_closure(ObjectClosure* closure);
    3.30 -  // Set the parallel closures: pointer is an array of pointers to
    3.31 -  // closures, one for each parallel GC thread.
    3.32 -  void set_par_closure(int i, ObjectClosure* closure);
    3.33 -
    3.34    // If there exists some completed buffer, pop it, then apply the
    3.35 -  // registered closure to all its elements, and return true.  If no
    3.36 +  // closure to all its elements, and return true.  If no
    3.37    // completed buffers exist, return false.
    3.38 -  bool apply_closure_to_completed_buffer() {
    3.39 -    return apply_closure_to_completed_buffer_work(false, 0);
    3.40 -  }
    3.41 -  // Parallel version of the above.
    3.42 -  bool par_apply_closure_to_completed_buffer(uint worker) {
    3.43 -    return apply_closure_to_completed_buffer_work(true, worker);
    3.44 -  }
    3.45 +  bool apply_closure_to_completed_buffer(ObjectClosure* closure);
    3.46  
    3.47    // Apply the given closure on enqueued and currently-active buffers
    3.48    // respectively. Both methods are read-only, i.e., they do not

mercurial