208 #ifndef PRODUCT
209 // Helpful for debugging
210
211 void ObjPtrQueue::print(const char* name) {
212 print(name, _buf, _index, _sz);
213 }
214
215 void ObjPtrQueue::print(const char* name,
216 void** buf, size_t index, size_t sz) {
217 gclog_or_tty->print_cr(" SATB BUFFER [%s] buf: "PTR_FORMAT" "
218 "index: "SIZE_FORMAT" sz: "SIZE_FORMAT,
219 name, p2i(buf), index, sz);
220 }
221 #endif // PRODUCT
222
223 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
224 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
225 #endif // _MSC_VER
226
227 SATBMarkQueueSet::SATBMarkQueueSet() :
228 PtrQueueSet(), _closures(NULL),
229 _shared_satb_queue(this, true /*perm*/) { }
230
231 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
232 int process_completed_threshold,
233 Mutex* lock) {
234 PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
235 _shared_satb_queue.set_lock(lock);
236 _closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads, mtGC);
237 }
238
239 void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
240 t->satb_mark_queue().handle_zero_index();
241 }
242
243 #ifdef ASSERT
244 void SATBMarkQueueSet::dump_active_states(bool expected_active) {
245 gclog_or_tty->print_cr("Expected SATB active state: %s",
246 expected_active ? "ACTIVE" : "INACTIVE");
247 gclog_or_tty->print_cr("Actual SATB active states:");
248 gclog_or_tty->print_cr(" Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
249 for (JavaThread* t = Threads::first(); t; t = t->next()) {
250 gclog_or_tty->print_cr(" Thread \"%s\" queue: %s", t->name(),
251 t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");
252 }
253 gclog_or_tty->print_cr(" Shared queue: %s",
254 shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
255 }
256
279
280 void SATBMarkQueueSet::set_active_all_threads(bool active, bool expected_active) {
281 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
282 #ifdef ASSERT
283 verify_active_states(expected_active);
284 #endif // ASSERT
285 _all_active = active;
286 for (JavaThread* t = Threads::first(); t; t = t->next()) {
287 t->satb_mark_queue().set_active(active);
288 }
289 shared_satb_queue()->set_active(active);
290 }
291
292 void SATBMarkQueueSet::filter_thread_buffers() {
293 for(JavaThread* t = Threads::first(); t; t = t->next()) {
294 t->satb_mark_queue().filter();
295 }
296 shared_satb_queue()->filter();
297 }
298
299 void SATBMarkQueueSet::set_closure(uint worker, ObjectClosure* closure) {
300 assert(_closures != NULL, "Precondition");
301 assert(worker < ParallelGCThreads, "Worker index must be in range [0...ParallelGCThreads)");
302 _closures[worker] = closure;
303 }
304
305 bool SATBMarkQueueSet::apply_closure_to_completed_buffer(uint worker) {
306 BufferNode* nd = NULL;
307 {
308 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
309 if (_completed_buffers_head != NULL) {
310 nd = _completed_buffers_head;
311 _completed_buffers_head = nd->next();
312 if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL;
313 _n_completed_buffers--;
314 if (_n_completed_buffers == 0) _process_completed = false;
315 }
316 }
317 ObjectClosure* cl = _closures[worker];
318 if (nd != NULL) {
319 void **buf = BufferNode::make_buffer_from_node(nd);
320 ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
321 deallocate_buffer(buf);
322 return true;
323 } else {
324 return false;
325 }
326 }
327
328 void SATBMarkQueueSet::iterate_completed_buffers_read_only(ObjectClosure* cl) {
329 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
330 assert(cl != NULL, "pre-condition");
331
332 BufferNode* nd = _completed_buffers_head;
333 while (nd != NULL) {
334 void** buf = BufferNode::make_buffer_from_node(nd);
335 ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
336 nd = nd->next();
337 }
|
208 #ifndef PRODUCT
209 // Helpful for debugging
210
211 void ObjPtrQueue::print(const char* name) {
212 print(name, _buf, _index, _sz);
213 }
214
215 void ObjPtrQueue::print(const char* name,
216 void** buf, size_t index, size_t sz) {
217 gclog_or_tty->print_cr(" SATB BUFFER [%s] buf: "PTR_FORMAT" "
218 "index: "SIZE_FORMAT" sz: "SIZE_FORMAT,
219 name, p2i(buf), index, sz);
220 }
221 #endif // PRODUCT
222
223 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
224 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
225 #endif // _MSC_VER
226
227 SATBMarkQueueSet::SATBMarkQueueSet() :
228 PtrQueueSet(),
229 _shared_satb_queue(this, true /*perm*/) { }
230
231 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
232 int process_completed_threshold,
233 Mutex* lock) {
234 PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
235 _shared_satb_queue.set_lock(lock);
236 }
237
238 void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
239 t->satb_mark_queue().handle_zero_index();
240 }
241
242 #ifdef ASSERT
243 void SATBMarkQueueSet::dump_active_states(bool expected_active) {
244 gclog_or_tty->print_cr("Expected SATB active state: %s",
245 expected_active ? "ACTIVE" : "INACTIVE");
246 gclog_or_tty->print_cr("Actual SATB active states:");
247 gclog_or_tty->print_cr(" Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
248 for (JavaThread* t = Threads::first(); t; t = t->next()) {
249 gclog_or_tty->print_cr(" Thread \"%s\" queue: %s", t->name(),
250 t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");
251 }
252 gclog_or_tty->print_cr(" Shared queue: %s",
253 shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
254 }
255
278
279 void SATBMarkQueueSet::set_active_all_threads(bool active, bool expected_active) {
280 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
281 #ifdef ASSERT
282 verify_active_states(expected_active);
283 #endif // ASSERT
284 _all_active = active;
285 for (JavaThread* t = Threads::first(); t; t = t->next()) {
286 t->satb_mark_queue().set_active(active);
287 }
288 shared_satb_queue()->set_active(active);
289 }
290
291 void SATBMarkQueueSet::filter_thread_buffers() {
292 for(JavaThread* t = Threads::first(); t; t = t->next()) {
293 t->satb_mark_queue().filter();
294 }
295 shared_satb_queue()->filter();
296 }
297
298 bool SATBMarkQueueSet::apply_closure_to_completed_buffer(ObjectClosure* cl) {
299 BufferNode* nd = NULL;
300 {
301 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
302 if (_completed_buffers_head != NULL) {
303 nd = _completed_buffers_head;
304 _completed_buffers_head = nd->next();
305 if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL;
306 _n_completed_buffers--;
307 if (_n_completed_buffers == 0) _process_completed = false;
308 }
309 }
310 if (nd != NULL) {
311 void **buf = BufferNode::make_buffer_from_node(nd);
312 ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
313 deallocate_buffer(buf);
314 return true;
315 } else {
316 return false;
317 }
318 }
319
320 void SATBMarkQueueSet::iterate_completed_buffers_read_only(ObjectClosure* cl) {
321 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
322 assert(cl != NULL, "pre-condition");
323
324 BufferNode* nd = _completed_buffers_head;
325 while (nd != NULL) {
326 void** buf = BufferNode::make_buffer_from_node(nd);
327 ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
328 nd = nd->next();
329 }
|