1.1 --- a/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp Mon Jul 21 09:40:19 2014 +0200 1.2 +++ b/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp Mon Jul 21 09:40:19 2014 +0200 1.3 @@ -70,7 +70,7 @@ 1.4 1.5 DirtyCardQueueSet::DirtyCardQueueSet(bool notify_when_complete) : 1.6 PtrQueueSet(notify_when_complete), 1.7 - _closure(NULL), 1.8 + _mut_process_closure(NULL), 1.9 _shared_dirty_card_queue(this, true /*perm*/), 1.10 _free_ids(NULL), 1.11 _processed_buffers_mut(0), _processed_buffers_rs_thread(0) 1.12 @@ -83,10 +83,11 @@ 1.13 return (uint)os::processor_count(); 1.14 } 1.15 1.16 -void DirtyCardQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock, 1.17 +void DirtyCardQueueSet::initialize(CardTableEntryClosure* cl, Monitor* cbl_mon, Mutex* fl_lock, 1.18 int process_completed_threshold, 1.19 int max_completed_queue, 1.20 Mutex* lock, PtrQueueSet* fl_owner) { 1.21 + _mut_process_closure = cl; 1.22 PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, 1.23 max_completed_queue, fl_owner); 1.24 set_buffer_size(G1UpdateBufferSize); 1.25 @@ -98,18 +99,15 @@ 1.26 t->dirty_card_queue().handle_zero_index(); 1.27 } 1.28 1.29 -void DirtyCardQueueSet::set_closure(CardTableEntryClosure* closure) { 1.30 - _closure = closure; 1.31 -} 1.32 - 1.33 -void DirtyCardQueueSet::iterate_closure_all_threads(bool consume, 1.34 +void DirtyCardQueueSet::iterate_closure_all_threads(CardTableEntryClosure* cl, 1.35 + bool consume, 1.36 uint worker_i) { 1.37 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); 1.38 for(JavaThread* t = Threads::first(); t; t = t->next()) { 1.39 - bool b = t->dirty_card_queue().apply_closure(_closure, consume); 1.40 + bool b = t->dirty_card_queue().apply_closure(cl, consume); 1.41 guarantee(b, "Should not be interrupted."); 1.42 } 1.43 - bool b = shared_dirty_card_queue()->apply_closure(_closure, 1.44 + bool b = shared_dirty_card_queue()->apply_closure(cl, 1.45 consume, 1.46 worker_i); 1.47 guarantee(b, "Should not be interrupted."); 1.48 @@ -143,7 +141,7 @@ 1.49 1.50 bool b = false; 1.51 if (worker_i != UINT_MAX) { 1.52 - b = DirtyCardQueue::apply_closure_to_buffer(_closure, buf, 0, 1.53 + b = DirtyCardQueue::apply_closure_to_buffer(_mut_process_closure, buf, 0, 1.54 _sz, true, worker_i); 1.55 if (b) Atomic::inc(&_processed_buffers_mut); 1.56 1.57 @@ -218,18 +216,11 @@ 1.58 return res; 1.59 } 1.60 1.61 -bool DirtyCardQueueSet::apply_closure_to_completed_buffer(uint worker_i, 1.62 - int stop_at, 1.63 - bool during_pause) { 1.64 - return apply_closure_to_completed_buffer(_closure, worker_i, 1.65 - stop_at, during_pause); 1.66 -} 1.67 - 1.68 -void DirtyCardQueueSet::apply_closure_to_all_completed_buffers() { 1.69 +void DirtyCardQueueSet::apply_closure_to_all_completed_buffers(CardTableEntryClosure* cl) { 1.70 BufferNode* nd = _completed_buffers_head; 1.71 while (nd != NULL) { 1.72 bool b = 1.73 - DirtyCardQueue::apply_closure_to_buffer(_closure, 1.74 + DirtyCardQueue::apply_closure_to_buffer(cl, 1.75 BufferNode::make_buffer_from_node(nd), 1.76 0, _sz, false); 1.77 guarantee(b, "Should not stop early."); 1.78 @@ -237,6 +228,24 @@ 1.79 } 1.80 } 1.81 1.82 +void DirtyCardQueueSet::par_apply_closure_to_all_completed_buffers(CardTableEntryClosure* cl) { 1.83 + BufferNode* nd = _cur_par_buffer_node; 1.84 + while (nd != NULL) { 1.85 + BufferNode* next = (BufferNode*)nd->next(); 1.86 + BufferNode* actual = (BufferNode*)Atomic::cmpxchg_ptr((void*)next, (volatile void*)&_cur_par_buffer_node, (void*)nd); 1.87 + if (actual == nd) { 1.88 + bool b = 1.89 + DirtyCardQueue::apply_closure_to_buffer(cl, 1.90 + BufferNode::make_buffer_from_node(actual), 1.91 + 0, _sz, false); 1.92 + guarantee(b, "Should not stop early."); 1.93 + nd = next; 1.94 + } else { 1.95 + nd = actual; 1.96 + } 1.97 + } 1.98 +} 1.99 + 1.100 // Deallocates any completed log buffers 1.101 void DirtyCardQueueSet::clear() { 1.102 BufferNode* buffers_to_delete = NULL;