< prev index next >

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

Print this page
rev 52688 : imported patch pqs_threshold_types
rev 52689 : [mq]: tschatzl_review

*** 162,192 **** _allocator(NULL), _cbl_mon(NULL), _completed_buffers_head(NULL), _completed_buffers_tail(NULL), _n_completed_buffers(0), ! _process_completed_threshold(0), _process_completed(false), _all_active(false), _notify_when_complete(notify_when_complete), ! _max_completed_queue(0), ! _completed_queue_padding(0) {} PtrQueueSet::~PtrQueueSet() { // There are presently only a couple (derived) instances ever // created, and they are permanent, so no harm currently done by // doing nothing here. } void PtrQueueSet::initialize(Monitor* cbl_mon, ! BufferNode::Allocator* allocator, ! int process_completed_threshold, ! int max_completed_queue) { ! _max_completed_queue = max_completed_queue; ! _process_completed_threshold = process_completed_threshold; ! _completed_queue_padding = 0; assert(cbl_mon != NULL && allocator != NULL, "Init order issue?"); _cbl_mon = cbl_mon; _allocator = allocator; } --- 162,187 ---- _allocator(NULL), _cbl_mon(NULL), _completed_buffers_head(NULL), _completed_buffers_tail(NULL), _n_completed_buffers(0), ! _process_completed_buffers_threshold(ProcessCompletedBuffersThresholdNever), _process_completed(false), _all_active(false), _notify_when_complete(notify_when_complete), ! _max_completed_buffers(MaxCompletedBuffersUnlimited), ! _completed_buffers_padding(0) {} PtrQueueSet::~PtrQueueSet() { // There are presently only a couple (derived) instances ever // created, and they are permanent, so no harm currently done by // doing nothing here. } void PtrQueueSet::initialize(Monitor* cbl_mon, ! BufferNode::Allocator* allocator) { assert(cbl_mon != NULL && allocator != NULL, "Init order issue?"); _cbl_mon = cbl_mon; _allocator = allocator; }
*** 236,252 **** reset(); } bool PtrQueueSet::process_or_enqueue_complete_buffer(BufferNode* node) { if (Thread::current()->is_Java_thread()) { ! // We don't lock. It is fine to be epsilon-precise here. ! if (_max_completed_queue == 0 || ! (_max_completed_queue > 0 && ! _n_completed_buffers >= _max_completed_queue + _completed_queue_padding)) { ! bool b = mut_process_buffer(node); ! if (b) { ! // True here means that the buffer hasn't been deallocated and the caller may reuse it. return true; } } } // The buffer will be enqueued. The caller will have to get a new one. --- 231,248 ---- reset(); } bool PtrQueueSet::process_or_enqueue_complete_buffer(BufferNode* node) { if (Thread::current()->is_Java_thread()) { ! // If the number of buffers exceeds the limit, make this Java ! // thread do the processing itself. We don't lock to access ! // buffer count or padding; it is fine to be imprecise here. The ! // add of padding could overflow, which is treated as unlimited. ! size_t limit = _max_completed_buffers + _completed_buffers_padding; ! if ((_n_completed_buffers > limit) && (limit >= _max_completed_buffers)) { ! if (mut_process_buffer(node)) { ! // Successfully processed; return true to allow buffer reuse. return true; } } } // The buffer will be enqueued. The caller will have to get a new one.
*** 265,276 **** _completed_buffers_tail->set_next(cbn); _completed_buffers_tail = cbn; } _n_completed_buffers++; ! if (!_process_completed && _process_completed_threshold >= 0 && ! _n_completed_buffers >= (size_t)_process_completed_threshold) { _process_completed = true; if (_notify_when_complete) { _cbl_mon->notify(); } } --- 261,272 ---- _completed_buffers_tail->set_next(cbn); _completed_buffers_tail = cbn; } _n_completed_buffers++; ! if (!_process_completed && ! (_n_completed_buffers > _process_completed_buffers_threshold)) { _process_completed = true; if (_notify_when_complete) { _cbl_mon->notify(); } }
*** 325,336 **** "Sanity"); } void PtrQueueSet::notify_if_necessary() { MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); ! assert(_process_completed_threshold >= 0, "_process_completed_threshold is negative"); ! if (_n_completed_buffers >= (size_t)_process_completed_threshold || _max_completed_queue == 0) { _process_completed = true; if (_notify_when_complete) _cbl_mon->notify(); } } --- 321,331 ---- "Sanity"); } void PtrQueueSet::notify_if_necessary() { MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); ! if (_n_completed_buffers > _process_completed_buffers_threshold) { _process_completed = true; if (_notify_when_complete) _cbl_mon->notify(); } }
< prev index next >