8151781: DirtyCardQueue::apply_closure is unused
authorkbarrett
Wed, 16 Mar 2016 00:28:33 -0400
changeset 37112 fe72d1d082ff
parent 37111 98572401ab0a
child 37114 f9047a59010f
8151781: DirtyCardQueue::apply_closure is unused Summary: Remove dead code, followup cleanups. Reviewed-by: brutisso, pliden
hotspot/src/share/vm/gc/g1/dirtyCardQueue.cpp
hotspot/src/share/vm/gc/g1/dirtyCardQueue.hpp
--- a/hotspot/src/share/vm/gc/g1/dirtyCardQueue.cpp	Tue Mar 15 20:37:35 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/dirtyCardQueue.cpp	Wed Mar 16 00:28:33 2016 -0400
@@ -110,46 +110,6 @@
   }
 }
 
-bool DirtyCardQueue::apply_closure(CardTableEntryClosure* cl,
-                                   bool consume,
-                                   uint worker_i) {
-  bool res = true;
-  if (_buf != NULL) {
-    BufferNode* node = BufferNode::make_node_from_buffer(_buf, _index);
-    res = apply_closure_to_buffer(cl, node, _sz, consume, worker_i);
-    if (res && consume) {
-      _index = _sz;
-    }
-  }
-  return res;
-}
-
-bool DirtyCardQueue::apply_closure_to_buffer(CardTableEntryClosure* cl,
-                                             BufferNode* node,
-                                             size_t buffer_size,
-                                             bool consume,
-                                             uint worker_i) {
-  if (cl == NULL) return true;
-  void** buf = BufferNode::make_buffer_from_node(node);
-  size_t limit = byte_index_to_index(buffer_size);
-  for (size_t i = byte_index_to_index(node->index()); i < limit; ++i) {
-    jbyte* card_ptr = static_cast<jbyte*>(buf[i]);
-    assert(card_ptr != NULL, "invariant");
-    if (!cl->do_card_ptr(card_ptr, worker_i)) {
-      if (consume) {
-        size_t new_index = index_to_byte_index(i + 1);
-        assert(new_index <= buffer_size, "invariant");
-        node->set_index(new_index);
-      }
-      return false;
-    }
-  }
-  if (consume) {
-    node->set_index(buffer_size);
-  }
-  return true;
-}
-
 DirtyCardQueueSet::DirtyCardQueueSet(bool notify_when_complete) :
   PtrQueueSet(notify_when_complete),
   _mut_process_closure(NULL),
@@ -190,15 +150,39 @@
   t->dirty_card_queue().handle_zero_index();
 }
 
+bool DirtyCardQueueSet::apply_closure_to_buffer(CardTableEntryClosure* cl,
+                                                BufferNode* node,
+                                                bool consume,
+                                                uint worker_i) {
+  if (cl == NULL) return true;
+  void** buf = BufferNode::make_buffer_from_node(node);
+  size_t limit = DirtyCardQueue::byte_index_to_index(buffer_size());
+  size_t start = DirtyCardQueue::byte_index_to_index(node->index());
+  for (size_t i = start; i < limit; ++i) {
+    jbyte* card_ptr = static_cast<jbyte*>(buf[i]);
+    assert(card_ptr != NULL, "invariant");
+    if (!cl->do_card_ptr(card_ptr, worker_i)) {
+      if (consume) {
+        size_t new_index = DirtyCardQueue::index_to_byte_index(i + 1);
+        assert(new_index <= buffer_size(), "invariant");
+        node->set_index(new_index);
+      }
+      return false;
+    }
+  }
+  if (consume) {
+    node->set_index(buffer_size());
+  }
+  return true;
+}
+
 bool DirtyCardQueueSet::mut_process_buffer(BufferNode* node) {
   guarantee(_free_ids != NULL, "must be");
 
   // claim a par id
   uint worker_i = _free_ids->claim_par_id();
 
-  bool b = DirtyCardQueue::apply_closure_to_buffer(_mut_process_closure,
-                                                   node, _sz,
-                                                   true, worker_i);
+  bool b = apply_closure_to_buffer(_mut_process_closure, node, true, worker_i);
   if (b) {
     Atomic::inc(&_processed_buffers_mut);
   }
@@ -242,7 +226,7 @@
   if (nd == NULL) {
     return false;
   } else {
-    if (DirtyCardQueue::apply_closure_to_buffer(cl, nd, _sz, true, worker_i)) {
+    if (apply_closure_to_buffer(cl, nd, true, worker_i)) {
       // Done with fully processed buffer.
       deallocate_buffer(nd);
       Atomic::inc(&_processed_buffers_rs_thread);
@@ -261,7 +245,7 @@
     BufferNode* next = nd->next();
     void* actual = Atomic::cmpxchg_ptr(next, &_cur_par_buffer_node, nd);
     if (actual == nd) {
-      bool b = DirtyCardQueue::apply_closure_to_buffer(cl, nd, _sz, false);
+      bool b = apply_closure_to_buffer(cl, nd, false);
       guarantee(b, "Should not stop early.");
       nd = next;
     } else {
--- a/hotspot/src/share/vm/gc/g1/dirtyCardQueue.hpp	Tue Mar 15 20:37:35 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/dirtyCardQueue.hpp	Wed Mar 16 00:28:33 2016 -0400
@@ -37,7 +37,7 @@
 public:
   // Process the card whose card table entry is "card_ptr".  If returns
   // "false", terminate the iteration early.
-  virtual bool do_card_ptr(jbyte* card_ptr, uint worker_i = 0) = 0;
+  virtual bool do_card_ptr(jbyte* card_ptr, uint worker_i) = 0;
 };
 
 // A ptrQueue whose elements are "oops", pointers to object heads.
@@ -52,26 +52,6 @@
   // Process queue entries and release resources.
   void flush() { flush_impl(); }
 
-  // Apply the closure to the elements from _index to _sz.  If all
-  // closure applications return true, then returns true.  Stops
-  // processing after the first closure application that returns
-  // false, and returns false from this function.  If "consume" is
-  // true, _index is updated to follow the last processed element.
-  bool apply_closure(CardTableEntryClosure* cl,
-                     bool consume = true,
-                     uint worker_i = 0);
-
-  // Apply the closure to the elements of "node" from it's index to
-  // buffer_size.  If all closure applications return true, then
-  // returns true.  Stops processing after the first closure
-  // application that returns false, and returns false from this
-  // function.  If "consume" is true, the node's index is updated to
-  // follow the last processed element.
-  static bool apply_closure_to_buffer(CardTableEntryClosure* cl,
-                                      BufferNode* node,
-                                      size_t buffer_size,
-                                      bool consume = true,
-                                      uint worker_i = 0);
   void **get_buf() { return _buf;}
   size_t get_index() { return _index;}
   void reinitialize() { _buf = 0; _sz = 0; _index = 0;}
@@ -97,6 +77,17 @@
 
   DirtyCardQueue _shared_dirty_card_queue;
 
+  // Apply the closure to the elements of "node" from it's index to
+  // buffer_size.  If all closure applications return true, then
+  // returns true.  Stops processing after the first closure
+  // application that returns false, and returns false from this
+  // function.  If "consume" is true, the node's index is updated to
+  // follow the last processed element.
+  bool apply_closure_to_buffer(CardTableEntryClosure* cl,
+                               BufferNode* node,
+                               bool consume,
+                               uint worker_i = 0);
+
   bool mut_process_buffer(BufferNode* node);
 
   // Protected by the _cbl_mon.