8230327: Make G1DirtyCardQueueSet free-id init unconditional
authorkbarrett
Fri, 30 Aug 2019 14:05:00 -0400
changeset 57969 6f0215981777
parent 57967 481a6a3449c8
child 57970 f249fc6665d5
8230327: Make G1DirtyCardQueueSet free-id init unconditional Summary: Remove conditional init and make the set an inline member. Reviewed-by: sjohanss, lkorinth, tschatzl
src/hotspot/share/gc/g1/g1CollectedHeap.cpp
src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp
src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp
src/hotspot/share/gc/g1/g1FreeIdSet.hpp
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Fri Aug 30 16:17:21 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Fri Aug 30 14:05:00 2019 -0400
@@ -1687,8 +1687,7 @@
   // process_cards_threshold and max_cards are updated
   // later, based on the concurrent refinement object.
   G1BarrierSet::dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon,
-                                                  &bs->dirty_card_queue_buffer_allocator(),
-                                                  true); // init_free_ids
+                                                  &bs->dirty_card_queue_buffer_allocator());
 
   // Create the hot card cache.
   _hot_card_cache = new G1HotCardCache(this);
--- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp	Fri Aug 30 16:17:21 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp	Fri Aug 30 14:05:00 2019 -0400
@@ -90,7 +90,7 @@
   _process_completed_buffers(false),
   _max_cards(MaxCardsUnlimited),
   _max_cards_padding(0),
-  _free_ids(NULL),
+  _free_ids(0, num_par_ids()),
   _processed_buffers_mut(0),
   _processed_buffers_rs_thread(0)
 {
@@ -99,7 +99,6 @@
 
 G1DirtyCardQueueSet::~G1DirtyCardQueueSet() {
   abandon_completed_buffers();
-  delete _free_ids;
 }
 
 // Determines how many mutator threads can process the buffers in parallel.
@@ -108,14 +107,10 @@
 }
 
 void G1DirtyCardQueueSet::initialize(Monitor* cbl_mon,
-                                     BufferNode::Allocator* allocator,
-                                     bool init_free_ids) {
+                                     BufferNode::Allocator* allocator) {
   PtrQueueSet::initialize(allocator);
   assert(_cbl_mon == NULL, "Init order issue?");
   _cbl_mon = cbl_mon;
-  if (init_free_ids) {
-    _free_ids = new G1FreeIdSet(0, num_par_ids());
-  }
 }
 
 void G1DirtyCardQueueSet::handle_zero_index_for_thread(Thread* t) {
@@ -286,12 +281,10 @@
 }
 
 bool G1DirtyCardQueueSet::mut_process_buffer(BufferNode* node) {
-  guarantee(_free_ids != NULL, "must be");
-
-  uint worker_i = _free_ids->claim_par_id(); // temporarily claim an id
+  uint worker_id = _free_ids.claim_par_id(); // temporarily claim an id
   G1RefineCardConcurrentlyClosure cl;
-  bool result = apply_closure_to_buffer(&cl, node, worker_i);
-  _free_ids->release_par_id(worker_i); // release the id
+  bool result = apply_closure_to_buffer(&cl, node, worker_id);
+  _free_ids.release_par_id(worker_id); // release the id
 
   if (result) {
     assert_fully_consumed(node, buffer_size());
--- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp	Fri Aug 30 16:17:21 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp	Fri Aug 30 14:05:00 2019 -0400
@@ -25,12 +25,12 @@
 #ifndef SHARE_GC_G1_G1DIRTYCARDQUEUE_HPP
 #define SHARE_GC_G1_G1DIRTYCARDQUEUE_HPP
 
+#include "gc/g1/g1FreeIdSet.hpp"
 #include "gc/shared/ptrQueue.hpp"
 #include "memory/allocation.hpp"
 
 class G1CardTableEntryClosure;
 class G1DirtyCardQueueSet;
-class G1FreeIdSet;
 class G1RedirtyCardsQueueSet;
 class Thread;
 class Monitor;
@@ -115,7 +115,7 @@
   size_t _max_cards_padding;
   static const size_t MaxCardsUnlimited = SIZE_MAX;
 
-  G1FreeIdSet* _free_ids;
+  G1FreeIdSet _free_ids;
 
   // The number of completed buffers processed by mutator and rs thread,
   // respectively.
@@ -126,9 +126,7 @@
   G1DirtyCardQueueSet();
   ~G1DirtyCardQueueSet();
 
-  void initialize(Monitor* cbl_mon,
-                  BufferNode::Allocator* allocator,
-                  bool init_free_ids = false);
+  void initialize(Monitor* cbl_mon, BufferNode::Allocator* allocator);
 
   // The number of parallel ids that can be claimed to allow collector or
   // mutator threads to do card-processing work.
--- a/src/hotspot/share/gc/g1/g1FreeIdSet.hpp	Fri Aug 30 16:17:21 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1FreeIdSet.hpp	Fri Aug 30 14:05:00 2019 -0400
@@ -25,7 +25,6 @@
 #ifndef SHARE_GC_G1_G1FREEIDSET_HPP
 #define SHARE_GC_G1_G1FREEIDSET_HPP
 
-#include "memory/allocation.hpp"
 #include "runtime/semaphore.hpp"
 #include "utilities/globalDefinitions.hpp"
 
@@ -34,7 +33,7 @@
 // contiguous range from 'start' to 'start + size'.  Used to obtain a
 // distinct worker_id value for a mutator thread that doesn't normally
 // have such an id.
-class G1FreeIdSet : public CHeapObj<mtGC> {
+class G1FreeIdSet {
   Semaphore _sem;
   uint* _next;
   uint _start;