65 _closure(NULL), _par_closures(NULL), |
65 _closure(NULL), _par_closures(NULL), |
66 _shared_satb_queue(this, true /*perm*/) |
66 _shared_satb_queue(this, true /*perm*/) |
67 {} |
67 {} |
68 |
68 |
69 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock, |
69 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock, |
70 int max_completed_queue, |
70 int process_completed_threshold, |
71 Mutex* lock) { |
71 Mutex* lock) { |
72 PtrQueueSet::initialize(cbl_mon, fl_lock, max_completed_queue); |
72 PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1); |
73 _shared_satb_queue.set_lock(lock); |
73 _shared_satb_queue.set_lock(lock); |
74 if (ParallelGCThreads > 0) { |
74 if (ParallelGCThreads > 0) { |
75 _par_closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads); |
75 _par_closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads); |
76 } |
76 } |
77 } |
77 } |
120 } |
120 } |
121 } |
121 } |
122 |
122 |
123 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, |
123 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, |
124 int worker) { |
124 int worker) { |
125 CompletedBufferNode* nd = NULL; |
125 BufferNode* nd = NULL; |
126 { |
126 { |
127 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
127 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
128 if (_completed_buffers_head != NULL) { |
128 if (_completed_buffers_head != NULL) { |
129 nd = _completed_buffers_head; |
129 nd = _completed_buffers_head; |
130 _completed_buffers_head = nd->next; |
130 _completed_buffers_head = nd->next(); |
131 if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL; |
131 if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL; |
132 _n_completed_buffers--; |
132 _n_completed_buffers--; |
133 if (_n_completed_buffers == 0) _process_completed = false; |
133 if (_n_completed_buffers == 0) _process_completed = false; |
134 } |
134 } |
135 } |
135 } |
136 ObjectClosure* cl = (par ? _par_closures[worker] : _closure); |
136 ObjectClosure* cl = (par ? _par_closures[worker] : _closure); |
137 if (nd != NULL) { |
137 if (nd != NULL) { |
138 ObjPtrQueue::apply_closure_to_buffer(cl, nd->buf, 0, _sz); |
138 void **buf = BufferNode::make_buffer_from_node(nd); |
139 deallocate_buffer(nd->buf); |
139 ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz); |
140 delete nd; |
140 deallocate_buffer(buf); |
141 return true; |
141 return true; |
142 } else { |
142 } else { |
143 return false; |
143 return false; |
144 } |
144 } |
145 } |
145 } |
146 |
146 |
147 void SATBMarkQueueSet::abandon_partial_marking() { |
147 void SATBMarkQueueSet::abandon_partial_marking() { |
148 CompletedBufferNode* buffers_to_delete = NULL; |
148 BufferNode* buffers_to_delete = NULL; |
149 { |
149 { |
150 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
150 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
151 while (_completed_buffers_head != NULL) { |
151 while (_completed_buffers_head != NULL) { |
152 CompletedBufferNode* nd = _completed_buffers_head; |
152 BufferNode* nd = _completed_buffers_head; |
153 _completed_buffers_head = nd->next; |
153 _completed_buffers_head = nd->next(); |
154 nd->next = buffers_to_delete; |
154 nd->set_next(buffers_to_delete); |
155 buffers_to_delete = nd; |
155 buffers_to_delete = nd; |
156 } |
156 } |
157 _completed_buffers_tail = NULL; |
157 _completed_buffers_tail = NULL; |
158 _n_completed_buffers = 0; |
158 _n_completed_buffers = 0; |
159 DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked()); |
159 DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked()); |
160 } |
160 } |
161 while (buffers_to_delete != NULL) { |
161 while (buffers_to_delete != NULL) { |
162 CompletedBufferNode* nd = buffers_to_delete; |
162 BufferNode* nd = buffers_to_delete; |
163 buffers_to_delete = nd->next; |
163 buffers_to_delete = nd->next(); |
164 deallocate_buffer(nd->buf); |
164 deallocate_buffer(BufferNode::make_buffer_from_node(nd)); |
165 delete nd; |
|
166 } |
165 } |
167 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
166 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
168 // So we can safely manipulate these queues. |
167 // So we can safely manipulate these queues. |
169 for (JavaThread* t = Threads::first(); t; t = t->next()) { |
168 for (JavaThread* t = Threads::first(); t; t = t->next()) { |
170 t->satb_mark_queue().reset(); |
169 t->satb_mark_queue().reset(); |