Skip to content
Permalink
Browse files
8258508: Merge G1RedirtyCardsQueue into qset
Reviewed-by: tschatzl, iwalulya
  • Loading branch information
Kim Barrett committed Feb 3, 2021
1 parent bec6043 commit d423d368e79e4c7da7d165d827d6ba90bd113450
@@ -41,19 +41,16 @@ class UpdateLogBuffersDeferred : public BasicOopIterateClosure {
private:
G1CollectedHeap* _g1h;
G1RedirtyCardsLocalQueueSet* _rdc_local_qset;
G1RedirtyCardsQueue* _rdcq;
G1CardTable* _ct;

// Remember the last enqueued card to avoid enqueuing the same card over and over;
// since we only ever handle a card once, this is sufficient.
size_t _last_enqueued_card;

public:
UpdateLogBuffersDeferred(G1RedirtyCardsLocalQueueSet* rdc_local_qset,
G1RedirtyCardsQueue* rdcq) :
UpdateLogBuffersDeferred(G1RedirtyCardsLocalQueueSet* rdc_local_qset) :
_g1h(G1CollectedHeap::heap()),
_rdc_local_qset(rdc_local_qset),
_rdcq(rdcq),
_ct(_g1h->card_table()),
_last_enqueued_card(SIZE_MAX) {}

@@ -73,7 +70,7 @@ class UpdateLogBuffersDeferred : public BasicOopIterateClosure {
}
size_t card_index = _ct->index_for(p);
if (card_index != _last_enqueued_card) {
_rdc_local_qset->enqueue(*_rdcq, _ct->byte_for_index(card_index));
_rdc_local_qset->enqueue(_ct->byte_for_index(card_index));
_last_enqueued_card = card_index;
}
}
@@ -206,20 +203,17 @@ class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure {
uint _worker_id;

G1RedirtyCardsLocalQueueSet _rdc_local_qset;
G1RedirtyCardsQueue _rdcq;
UpdateLogBuffersDeferred _log_buffer_cl;

public:
RemoveSelfForwardPtrHRClosure(G1RedirtyCardsQueueSet* rdcqs, uint worker_id) :
_g1h(G1CollectedHeap::heap()),
_worker_id(worker_id),
_rdc_local_qset(rdcqs),
_rdcq(&_rdc_local_qset),
_log_buffer_cl(&_rdc_local_qset, &_rdcq) {
_log_buffer_cl(&_rdc_local_qset) {
}

~RemoveSelfForwardPtrHRClosure() {
_rdc_local_qset.flush_queue(_rdcq);
_rdc_local_qset.flush();
}

@@ -59,7 +59,6 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h,
: _g1h(g1h),
_task_queue(g1h->task_queue(worker_id)),
_rdc_local_qset(rdcqs),
_rdcq(&_rdc_local_qset),
_ct(g1h->card_table()),
_closures(NULL),
_plab_allocator(NULL),
@@ -114,7 +113,6 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h,
}

size_t G1ParScanThreadState::flush(size_t* surviving_young_words) {
_rdc_local_qset.flush_queue(_rdcq);
_rdc_local_qset.flush();
flush_numa_stats();
// Update allocation statistics.
@@ -49,7 +49,6 @@ class G1ParScanThreadState : public CHeapObj<mtGC> {
G1CollectedHeap* _g1h;
G1ScannerTasksQueue* _task_queue;
G1RedirtyCardsLocalQueueSet _rdc_local_qset;
G1RedirtyCardsQueue _rdcq;
G1CardTable* _ct;
G1EvacuationRootClosures* _closures;

@@ -148,7 +147,7 @@ class G1ParScanThreadState : public CHeapObj<mtGC> {
size_t card_index = ct()->index_for(p);
// If the card hasn't been added to the buffer, do it.
if (_last_enqueued_card != card_index) {
_rdc_local_qset.enqueue(_rdcq, ct()->byte_for_index(card_index));
_rdc_local_qset.enqueue(ct()->byte_for_index(card_index));
_last_enqueued_card = card_index;
}
}
@@ -33,7 +33,8 @@
G1RedirtyCardsLocalQueueSet::G1RedirtyCardsLocalQueueSet(G1RedirtyCardsQueueSet* shared_qset) :
PtrQueueSet(shared_qset->allocator()),
_shared_qset(shared_qset),
_buffers()
_buffers(),
_queue(this)
{}

#ifdef ASSERT
@@ -53,33 +54,30 @@ void G1RedirtyCardsLocalQueueSet::enqueue_completed_buffer(BufferNode* node) {
}
}

void G1RedirtyCardsLocalQueueSet::enqueue(G1RedirtyCardsQueue& queue, void* value) {
if (!try_enqueue(queue, value)) {
BufferNode* old_node = exchange_buffer_with_new(queue);
void G1RedirtyCardsLocalQueueSet::enqueue(void* value) {
if (!try_enqueue(_queue, value)) {
BufferNode* old_node = exchange_buffer_with_new(_queue);
if (old_node != nullptr) {
enqueue_completed_buffer(old_node);
}
retry_enqueue(queue, value);
retry_enqueue(_queue, value);
}
}

void G1RedirtyCardsLocalQueueSet::flush() {
flush_queue(_queue);
_shared_qset->add_bufferlist(_buffers);
_buffers = G1BufferNodeList();
}

void G1RedirtyCardsLocalQueueSet::flush_queue(G1RedirtyCardsQueue& queue) {
PtrQueueSet::flush_queue(queue);
}

// G1RedirtyCardsQueue
// G1RedirtyCardsLocalQueueSet::Queue

G1RedirtyCardsQueue::G1RedirtyCardsQueue(G1RedirtyCardsLocalQueueSet* qset) :
G1RedirtyCardsLocalQueueSet::Queue::Queue(G1RedirtyCardsLocalQueueSet* qset) :
PtrQueue(qset)
{}

#ifdef ASSERT
G1RedirtyCardsQueue::~G1RedirtyCardsQueue() {
G1RedirtyCardsLocalQueueSet::Queue::~Queue() {
assert(buffer() == nullptr, "unflushed queue");
}
#endif // ASSERT
@@ -28,37 +28,34 @@
#include "gc/g1/g1BufferNodeList.hpp"
#include "gc/shared/ptrQueue.hpp"
#include "memory/padded.hpp"
#include "utilities/macros.hpp"

class G1RedirtyCardsQueue;
class G1RedirtyCardsQueueSet;

// Provide G1RedirtyCardsQueue with a thread-local qset. It provides an
// uncontended staging area for completed buffers, to be flushed to the
// shared qset en masse.
class G1RedirtyCardsLocalQueueSet : public PtrQueueSet {
// A thread-local qset and queue. It provides an uncontended staging
// area for completed buffers, to be flushed to the shared qset en masse.
class G1RedirtyCardsLocalQueueSet : private PtrQueueSet {
class Queue : public PtrQueue {
public:
Queue(G1RedirtyCardsLocalQueueSet* qset);
~Queue() NOT_DEBUG(= default);
};

G1RedirtyCardsQueueSet* _shared_qset;
G1BufferNodeList _buffers;
Queue _queue;

// Add the buffer to the local list.
virtual void enqueue_completed_buffer(BufferNode* node);

public:
G1RedirtyCardsLocalQueueSet(G1RedirtyCardsQueueSet* shared_qset);
~G1RedirtyCardsLocalQueueSet() NOT_DEBUG(= default);

void enqueue(G1RedirtyCardsQueue& queue, void* value);

// Add the buffer to the local list.
virtual void enqueue_completed_buffer(BufferNode* node);
void enqueue(void* value);

// Transfer all completed buffers to the shared qset.
void flush();

void flush_queue(G1RedirtyCardsQueue& queue);
};

// Worker-local queues of card table entries.
class G1RedirtyCardsQueue : public PtrQueue {
public:
G1RedirtyCardsQueue(G1RedirtyCardsLocalQueueSet* qset);
~G1RedirtyCardsQueue() NOT_DEBUG(= default);
};

// Card table entries to be redirtied and the cards reprocessed later.

0 comments on commit d423d36

Please sign in to comment.