Skip to content

Commit 8b67b75

Browse files
author
Kim Barrett
committed
8221361: Eliminate two-phase initialization for PtrQueueSet classes
Move allocator and CBL monitor init to constructor. Reviewed-by: tschatzl, shade
1 parent ea0fbbc commit 8b67b75

17 files changed

+57
-133
lines changed

src/hotspot/share/gc/g1/g1BarrierSet.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ G1BarrierSet::G1BarrierSet(G1CardTable* card_table) :
5757
BarrierSet::FakeRtti(BarrierSet::G1BarrierSet)),
5858
_satb_mark_queue_buffer_allocator("SATB Buffer Allocator", G1SATBBufferSize),
5959
_dirty_card_queue_buffer_allocator("DC Buffer Allocator", G1UpdateBufferSize),
60-
_satb_mark_queue_set(),
61-
_dirty_card_queue_set(),
60+
_satb_mark_queue_set(&_satb_mark_queue_buffer_allocator),
61+
_dirty_card_queue_set(DirtyCardQ_CBL_mon, &_dirty_card_queue_buffer_allocator),
6262
_shared_dirty_card_queue(&_dirty_card_queue_set)
6363
{}
6464

@@ -159,11 +159,3 @@ void G1BarrierSet::on_thread_detach(Thread* thread) {
159159
G1ThreadLocalData::satb_mark_queue(thread).flush();
160160
G1ThreadLocalData::dirty_card_queue(thread).flush();
161161
}
162-
163-
BufferNode::Allocator& G1BarrierSet::satb_mark_queue_buffer_allocator() {
164-
return _satb_mark_queue_buffer_allocator;
165-
}
166-
167-
BufferNode::Allocator& G1BarrierSet::dirty_card_queue_buffer_allocator() {
168-
return _dirty_card_queue_buffer_allocator;
169-
}

src/hotspot/share/gc/g1/g1BarrierSet.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ class G1BarrierSet: public CardTableBarrierSet {
8282
virtual void on_thread_attach(Thread* thread);
8383
virtual void on_thread_detach(Thread* thread);
8484

85-
BufferNode::Allocator& satb_mark_queue_buffer_allocator();
86-
BufferNode::Allocator& dirty_card_queue_buffer_allocator();
87-
8885
static G1SATBMarkQueueSet& satb_mark_queue_set() {
8986
return g1_barrier_set()->_satb_mark_queue_set;
9087
}

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,15 +1678,11 @@ jint G1CollectedHeap::initialize() {
16781678
BarrierSet::set_barrier_set(bs);
16791679
_card_table = ct;
16801680

1681-
G1BarrierSet::satb_mark_queue_set().initialize(this,
1682-
&bs->satb_mark_queue_buffer_allocator(),
1683-
G1SATBProcessCompletedThreshold,
1684-
G1SATBBufferEnqueueingThresholdPercent);
1685-
1686-
// process_cards_threshold and max_cards are updated
1687-
// later, based on the concurrent refinement object.
1688-
G1BarrierSet::dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon,
1689-
&bs->dirty_card_queue_buffer_allocator());
1681+
{
1682+
G1SATBMarkQueueSet& satbqs = bs->satb_mark_queue_set();
1683+
satbqs.set_process_completed_buffers_threshold(G1SATBProcessCompletedThreshold);
1684+
satbqs.set_buffer_enqueue_threshold_percentage(G1SATBBufferEnqueueingThresholdPercent);
1685+
}
16901686

16911687
// Create the hot card cache.
16921688
_hot_card_cache = new G1HotCardCache(this);

src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ void G1DirtyCardQueue::handle_completed_buffer() {
6262
}
6363
}
6464

65-
G1DirtyCardQueueSet::G1DirtyCardQueueSet() :
66-
PtrQueueSet(),
67-
_cbl_mon(NULL),
65+
G1DirtyCardQueueSet::G1DirtyCardQueueSet(Monitor* cbl_mon,
66+
BufferNode::Allocator* allocator) :
67+
PtrQueueSet(allocator),
68+
_cbl_mon(cbl_mon),
6869
_completed_buffers_head(NULL),
6970
_completed_buffers_tail(NULL),
7071
_num_cards(0),
@@ -88,13 +89,6 @@ uint G1DirtyCardQueueSet::num_par_ids() {
8889
return (uint)os::initial_active_processor_count();
8990
}
9091

91-
void G1DirtyCardQueueSet::initialize(Monitor* cbl_mon,
92-
BufferNode::Allocator* allocator) {
93-
PtrQueueSet::initialize(allocator);
94-
assert(_cbl_mon == NULL, "Init order issue?");
95-
_cbl_mon = cbl_mon;
96-
}
97-
9892
void G1DirtyCardQueueSet::handle_zero_index_for_thread(Thread* t) {
9993
G1ThreadLocalData::dirty_card_queue(t).handle_zero_index();
10094
}

src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,9 @@ class G1DirtyCardQueueSet: public PtrQueueSet {
103103
jint _processed_buffers_rs_thread;
104104

105105
public:
106-
G1DirtyCardQueueSet();
106+
G1DirtyCardQueueSet(Monitor* cbl_mon, BufferNode::Allocator* allocator);
107107
~G1DirtyCardQueueSet();
108108

109-
void initialize(Monitor* cbl_mon, BufferNode::Allocator* allocator);
110-
111109
// The number of parallel ids that can be claimed to allow collector or
112110
// mutator threads to do card-processing work.
113111
static uint num_par_ids();

src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@
3131
// G1RedirtyCardsQueueBase::LocalQSet
3232

3333
G1RedirtyCardsQueueBase::LocalQSet::LocalQSet(G1RedirtyCardsQueueSet* shared_qset) :
34-
PtrQueueSet(),
34+
PtrQueueSet(shared_qset->allocator()),
3535
_shared_qset(shared_qset),
3636
_buffers()
37-
{
38-
PtrQueueSet::initialize(_shared_qset->allocator());
39-
}
37+
{}
4038

4139
G1RedirtyCardsQueueBase::LocalQSet::~LocalQSet() {
4240
assert(_buffers._head == NULL, "unflushed qset");
@@ -86,14 +84,12 @@ void G1RedirtyCardsQueue::flush() {
8684
// G1RedirtyCardsQueueSet
8785

8886
G1RedirtyCardsQueueSet::G1RedirtyCardsQueueSet(BufferNode::Allocator* allocator) :
89-
PtrQueueSet(),
87+
PtrQueueSet(allocator),
9088
_list(),
9189
_entry_count(0),
9290
_tail(NULL)
9391
DEBUG_ONLY(COMMA _collecting(true))
94-
{
95-
initialize(allocator);
96-
}
92+
{}
9793

9894
G1RedirtyCardsQueueSet::~G1RedirtyCardsQueueSet() {
9995
verify_empty();

src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,9 @@
3232
#include "utilities/debug.hpp"
3333
#include "utilities/globalDefinitions.hpp"
3434

35-
G1SATBMarkQueueSet::G1SATBMarkQueueSet() : _g1h(NULL) {}
36-
37-
void G1SATBMarkQueueSet::initialize(G1CollectedHeap* g1h,
38-
BufferNode::Allocator* allocator,
39-
size_t process_completed_buffers_threshold,
40-
uint buffer_enqueue_threshold_percentage) {
41-
SATBMarkQueueSet::initialize(allocator,
42-
process_completed_buffers_threshold,
43-
buffer_enqueue_threshold_percentage);
44-
_g1h = g1h;
45-
}
35+
G1SATBMarkQueueSet::G1SATBMarkQueueSet(BufferNode::Allocator* allocator) :
36+
SATBMarkQueueSet(allocator)
37+
{}
4638

4739
void G1SATBMarkQueueSet::handle_zero_index_for_thread(Thread* t) {
4840
G1ThreadLocalData::satb_mark_queue(t).handle_zero_index();
@@ -112,7 +104,7 @@ class G1SATBMarkQueueFilterFn {
112104
G1CollectedHeap* _g1h;
113105

114106
public:
115-
G1SATBMarkQueueFilterFn(G1CollectedHeap* g1h) : _g1h(g1h) {}
107+
G1SATBMarkQueueFilterFn() : _g1h(G1CollectedHeap::heap()) {}
116108

117109
// Return true if entry should be filtered out (removed), false if
118110
// it should be retained.
@@ -122,6 +114,5 @@ class G1SATBMarkQueueFilterFn {
122114
};
123115

124116
void G1SATBMarkQueueSet::filter(SATBMarkQueue* queue) {
125-
assert(_g1h != NULL, "SATB queue set not initialized");
126-
apply_filter(G1SATBMarkQueueFilterFn(_g1h), queue);
117+
apply_filter(G1SATBMarkQueueFilterFn(), queue);
127118
}

src/hotspot/share/gc/g1/g1SATBMarkQueueSet.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@ class G1SATBMarkQueueSet : public SATBMarkQueueSet {
3535
G1CollectedHeap* _g1h;
3636

3737
public:
38-
G1SATBMarkQueueSet();
39-
40-
void initialize(G1CollectedHeap* g1h,
41-
BufferNode::Allocator* allocator,
42-
size_t process_completed_buffers_threshold,
43-
uint buffer_enqueue_threshold_percentage);
38+
G1SATBMarkQueueSet(BufferNode::Allocator* allocator);
4439

4540
static void handle_zero_index_for_thread(Thread* t);
4641
virtual SATBMarkQueue& satb_queue_for_thread(Thread* const t) const;

src/hotspot/share/gc/shared/ptrQueue.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ PtrQueue::PtrQueue(PtrQueueSet* qset, bool active) :
4040
_qset(qset),
4141
_active(active),
4242
_index(0),
43-
_capacity_in_bytes(0),
43+
_capacity_in_bytes(index_to_byte_index(qset->buffer_size())),
4444
_buf(NULL)
4545
{}
4646

@@ -80,13 +80,6 @@ void PtrQueue::handle_zero_index() {
8080
if (_buf != NULL) {
8181
handle_completed_buffer();
8282
} else {
83-
// Bootstrapping kludge; lazily initialize capacity. The initial
84-
// thread's queues are constructed before the second phase of the
85-
// two-phase initialization of the associated qsets. As a result,
86-
// we can't initialize _capacity_in_bytes in the queue constructor.
87-
if (_capacity_in_bytes == 0) {
88-
_capacity_in_bytes = index_to_byte_index(qset()->buffer_size());
89-
}
9083
allocate_buffer();
9184
}
9285
}
@@ -250,18 +243,13 @@ size_t BufferNode::Allocator::reduce_free_list(size_t remove_goal) {
250243
return removed;
251244
}
252245

253-
PtrQueueSet::PtrQueueSet() :
254-
_allocator(NULL),
246+
PtrQueueSet::PtrQueueSet(BufferNode::Allocator* allocator) :
247+
_allocator(allocator),
255248
_all_active(false)
256249
{}
257250

258251
PtrQueueSet::~PtrQueueSet() {}
259252

260-
void PtrQueueSet::initialize(BufferNode::Allocator* allocator) {
261-
assert(allocator != NULL, "Init order issue?");
262-
_allocator = allocator;
263-
}
264-
265253
void** PtrQueueSet::allocate_buffer() {
266254
BufferNode* node = _allocator->allocate();
267255
return BufferNode::make_buffer_from_node(node);

src/hotspot/share/gc/shared/ptrQueue.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,9 @@ class PtrQueueSet {
303303
bool _all_active;
304304

305305
// Create an empty ptr queue set.
306-
PtrQueueSet();
306+
PtrQueueSet(BufferNode::Allocator* allocator);
307307
~PtrQueueSet();
308308

309-
// Because of init-order concerns, we can't pass these as constructor
310-
// arguments.
311-
void initialize(BufferNode::Allocator* allocator);
312-
313309
public:
314310

315311
// Return the associated BufferNode allocator.

0 commit comments

Comments
 (0)