8230327: Make G1DirtyCardQueueSet free-id init unconditional

Remove conditional init and make the set an inline member.

Reviewed-by: sjohanss, lkorinth, tschatzl
This commit is contained in:
Kim Barrett 2019-08-30 14:05:00 -04:00
parent 79c14f088c
commit 1668370dfe
4 changed files with 10 additions and 21 deletions

View File

@ -1687,8 +1687,7 @@ jint G1CollectedHeap::initialize() {
// 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);

View File

@ -90,7 +90,7 @@ G1DirtyCardQueueSet::G1DirtyCardQueueSet() :
_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() :
G1DirtyCardQueueSet::~G1DirtyCardQueueSet() {
abandon_completed_buffers();
delete _free_ids;
}
// Determines how many mutator threads can process the buffers in parallel.
@ -108,14 +107,10 @@ uint G1DirtyCardQueueSet::num_par_ids() {
}
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::process_or_enqueue_completed_buffer(BufferNode* node)
}
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());

View File

@ -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 @@ class G1DirtyCardQueueSet: public PtrQueueSet {
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 @@ public:
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.

View File

@ -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;