--- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2019-08-29 14:09:39.721309086 -0400 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2019-08-29 14:09:39.449294497 -0400 @@ -1687,8 +1687,7 @@ // process_completed_buffers_threshold and max_completed_buffers 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); --- old/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp 2019-08-29 14:09:41.249391043 -0400 +++ new/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp 2019-08-29 14:09:40.961375596 -0400 @@ -91,7 +91,7 @@ _notify_when_complete(notify_when_complete), _max_completed_buffers(MaxCompletedBuffersUnlimited), _completed_buffers_padding(0), - _free_ids(NULL), + _free_ids(0, num_par_ids()), _processed_buffers_mut(0), _processed_buffers_rs_thread(0) { @@ -100,7 +100,6 @@ G1DirtyCardQueueSet::~G1DirtyCardQueueSet() { abandon_completed_buffers(); - delete _free_ids; } // Determines how many mutator threads can process the buffers in parallel. @@ -109,14 +108,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) { @@ -291,12 +286,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()); --- old/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp 2019-08-29 14:09:42.761472142 -0400 +++ new/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp 2019-08-29 14:09:42.469456480 -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; @@ -118,7 +118,7 @@ size_t _completed_buffers_padding; static const size_t MaxCompletedBuffersUnlimited = SIZE_MAX; - G1FreeIdSet* _free_ids; + G1FreeIdSet _free_ids; // The number of completed buffers processed by mutator and rs thread, // respectively. @@ -129,9 +129,7 @@ G1DirtyCardQueueSet(bool notify_when_complete = true); ~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. --- old/src/hotspot/share/gc/g1/g1FreeIdSet.hpp 2019-08-29 14:09:44.257552383 -0400 +++ new/src/hotspot/share/gc/g1/g1FreeIdSet.hpp 2019-08-29 14:09:43.965536721 -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 { +class G1FreeIdSet { Semaphore _sem; uint* _next; uint _start;