Skip to content

Commit

Permalink
8230327: Make G1DirtyCardQueueSet free-id init unconditional
Browse files Browse the repository at this point in the history
Remove conditional init and make the set an inline member.

Reviewed-by: sjohanss, lkorinth, tschatzl
  • Loading branch information
Kim Barrett committed Aug 30, 2019
1 parent 79c14f0 commit 1668370
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 5 additions & 12 deletions src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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.
Expand All @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down
8 changes: 3 additions & 5 deletions src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -126,9 +126,7 @@ class G1DirtyCardQueueSet: public PtrQueueSet {
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.
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/gc/g1/g1FreeIdSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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;
Expand Down

0 comments on commit 1668370

Please sign in to comment.