< prev index next >

src/share/vm/gc/g1/satbMarkQueue.cpp

Print this page




 182          "SATB queues must only be processed at safepoints");
 183   if (_buf != NULL) {
 184     assert(_index % sizeof(void*) == 0, "invariant");
 185     assert(_sz % sizeof(void*) == 0, "invariant");
 186     assert(_index <= _sz, "invariant");
 187     cl->do_buffer(_buf + byte_index_to_index(_index),
 188                   byte_index_to_index(_sz - _index));
 189     _index = _sz;
 190   }
 191 }
 192 
 193 #ifndef PRODUCT
 194 // Helpful for debugging
 195 
 196 void SATBMarkQueue::print(const char* name) {
 197   print(name, _buf, _index, _sz);
 198 }
 199 
 200 void SATBMarkQueue::print(const char* name,
 201                           void** buf, size_t index, size_t sz) {
 202   gclog_or_tty->print_cr("  SATB BUFFER [%s] buf: " PTR_FORMAT " "
 203                          "index: " SIZE_FORMAT " sz: " SIZE_FORMAT,
 204                          name, p2i(buf), index, sz);
 205 }
 206 #endif // PRODUCT
 207 
 208 SATBMarkQueueSet::SATBMarkQueueSet() :
 209   PtrQueueSet(),
 210   _shared_satb_queue(this, true /* permanent */) { }
 211 
 212 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
 213                                   int process_completed_threshold,
 214                                   Mutex* lock) {
 215   PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
 216   _shared_satb_queue.set_lock(lock);
 217 }
 218 
 219 void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
 220   t->satb_mark_queue().handle_zero_index();
 221 }
 222 
 223 #ifdef ASSERT
 224 void SATBMarkQueueSet::dump_active_states(bool expected_active) {
 225   gclog_or_tty->print_cr("Expected SATB active state: %s",
 226                          expected_active ? "ACTIVE" : "INACTIVE");
 227   gclog_or_tty->print_cr("Actual SATB active states:");
 228   gclog_or_tty->print_cr("  Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
 229   for (JavaThread* t = Threads::first(); t; t = t->next()) {
 230     gclog_or_tty->print_cr("  Thread \"%s\" queue: %s", t->name(),
 231                            t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");
 232   }
 233   gclog_or_tty->print_cr("  Shared queue: %s",
 234                          shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
 235 }
 236 
 237 void SATBMarkQueueSet::verify_active_states(bool expected_active) {
 238   // Verify queue set state
 239   if (is_active() != expected_active) {
 240     dump_active_states(expected_active);
 241     guarantee(false, "SATB queue set has an unexpected active state");
 242   }
 243 
 244   // Verify thread queue states
 245   for (JavaThread* t = Threads::first(); t; t = t->next()) {
 246     if (t->satb_mark_queue().is_active() != expected_active) {
 247       dump_active_states(expected_active);
 248       guarantee(false, "Thread SATB queue has an unexpected active state");
 249     }
 250   }
 251 
 252   // Verify shared queue state
 253   if (shared_satb_queue()->is_active() != expected_active) {
 254     dump_active_states(expected_active);


 301         cl->do_buffer(buf + i, limit - i);
 302         break;
 303       }
 304     }
 305     deallocate_buffer(buf);
 306     return true;
 307   } else {
 308     return false;
 309   }
 310 }
 311 
 312 #ifndef PRODUCT
 313 // Helpful for debugging
 314 
 315 #define SATB_PRINTER_BUFFER_SIZE 256
 316 
 317 void SATBMarkQueueSet::print_all(const char* msg) {
 318   char buffer[SATB_PRINTER_BUFFER_SIZE];
 319   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
 320 
 321   gclog_or_tty->cr();
 322   gclog_or_tty->print_cr("SATB BUFFERS [%s]", msg);
 323 
 324   BufferNode* nd = _completed_buffers_head;
 325   int i = 0;
 326   while (nd != NULL) {
 327     void** buf = BufferNode::make_buffer_from_node(nd);
 328     jio_snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Enqueued: %d", i);
 329     SATBMarkQueue::print(buffer, buf, 0, _sz);
 330     nd = nd->next();
 331     i += 1;
 332   }
 333 
 334   for (JavaThread* t = Threads::first(); t; t = t->next()) {
 335     jio_snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name());
 336     t->satb_mark_queue().print(buffer);
 337   }
 338 
 339   shared_satb_queue()->print("Shared");
 340 
 341   gclog_or_tty->cr();
 342 }
 343 #endif // PRODUCT
 344 
 345 void SATBMarkQueueSet::abandon_partial_marking() {
 346   BufferNode* buffers_to_delete = NULL;
 347   {
 348     MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
 349     while (_completed_buffers_head != NULL) {
 350       BufferNode* nd = _completed_buffers_head;
 351       _completed_buffers_head = nd->next();
 352       nd->set_next(buffers_to_delete);
 353       buffers_to_delete = nd;
 354     }
 355     _completed_buffers_tail = NULL;
 356     _n_completed_buffers = 0;
 357     DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked());
 358   }
 359   while (buffers_to_delete != NULL) {
 360     BufferNode* nd = buffers_to_delete;
 361     buffers_to_delete = nd->next();


 182          "SATB queues must only be processed at safepoints");
 183   if (_buf != NULL) {
 184     assert(_index % sizeof(void*) == 0, "invariant");
 185     assert(_sz % sizeof(void*) == 0, "invariant");
 186     assert(_index <= _sz, "invariant");
 187     cl->do_buffer(_buf + byte_index_to_index(_index),
 188                   byte_index_to_index(_sz - _index));
 189     _index = _sz;
 190   }
 191 }
 192 
 193 #ifndef PRODUCT
 194 // Helpful for debugging
 195 
 196 void SATBMarkQueue::print(const char* name) {
 197   print(name, _buf, _index, _sz);
 198 }
 199 
 200 void SATBMarkQueue::print(const char* name,
 201                           void** buf, size_t index, size_t sz) {
 202   tty->print_cr("  SATB BUFFER [%s] buf: " PTR_FORMAT " index: " SIZE_FORMAT " sz: " SIZE_FORMAT,

 203                 name, p2i(buf), index, sz);
 204 }
 205 #endif // PRODUCT
 206 
 207 SATBMarkQueueSet::SATBMarkQueueSet() :
 208   PtrQueueSet(),
 209   _shared_satb_queue(this, true /* permanent */) { }
 210 
 211 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
 212                                   int process_completed_threshold,
 213                                   Mutex* lock) {
 214   PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
 215   _shared_satb_queue.set_lock(lock);
 216 }
 217 
 218 void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
 219   t->satb_mark_queue().handle_zero_index();
 220 }
 221 
 222 #ifdef ASSERT
 223 void SATBMarkQueueSet::dump_active_states(bool expected_active) {
 224   log_info(gc, verify)("Expected SATB active state: %s", expected_active ? "ACTIVE" : "INACTIVE");
 225   log_info(gc, verify)("Actual SATB active states:");
 226   log_info(gc, verify)("  Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");

 227   for (JavaThread* t = Threads::first(); t; t = t->next()) {
 228     log_info(gc, verify)("  Thread \"%s\" queue: %s", t->name(), t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");

 229   }
 230   log_info(gc, verify)("  Shared queue: %s", shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");

 231 }
 232 
 233 void SATBMarkQueueSet::verify_active_states(bool expected_active) {
 234   // Verify queue set state
 235   if (is_active() != expected_active) {
 236     dump_active_states(expected_active);
 237     guarantee(false, "SATB queue set has an unexpected active state");
 238   }
 239 
 240   // Verify thread queue states
 241   for (JavaThread* t = Threads::first(); t; t = t->next()) {
 242     if (t->satb_mark_queue().is_active() != expected_active) {
 243       dump_active_states(expected_active);
 244       guarantee(false, "Thread SATB queue has an unexpected active state");
 245     }
 246   }
 247 
 248   // Verify shared queue state
 249   if (shared_satb_queue()->is_active() != expected_active) {
 250     dump_active_states(expected_active);


 297         cl->do_buffer(buf + i, limit - i);
 298         break;
 299       }
 300     }
 301     deallocate_buffer(buf);
 302     return true;
 303   } else {
 304     return false;
 305   }
 306 }
 307 
 308 #ifndef PRODUCT
 309 // Helpful for debugging
 310 
 311 #define SATB_PRINTER_BUFFER_SIZE 256
 312 
 313 void SATBMarkQueueSet::print_all(const char* msg) {
 314   char buffer[SATB_PRINTER_BUFFER_SIZE];
 315   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
 316 
 317   tty->cr();
 318   tty->print_cr("SATB BUFFERS [%s]", msg);
 319 
 320   BufferNode* nd = _completed_buffers_head;
 321   int i = 0;
 322   while (nd != NULL) {
 323     void** buf = BufferNode::make_buffer_from_node(nd);
 324     jio_snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Enqueued: %d", i);
 325     SATBMarkQueue::print(buffer, buf, 0, _sz);
 326     nd = nd->next();
 327     i += 1;
 328   }
 329 
 330   for (JavaThread* t = Threads::first(); t; t = t->next()) {
 331     jio_snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name());
 332     t->satb_mark_queue().print(buffer);
 333   }
 334 
 335   shared_satb_queue()->print("Shared");
 336 
 337   tty->cr();
 338 }
 339 #endif // PRODUCT
 340 
 341 void SATBMarkQueueSet::abandon_partial_marking() {
 342   BufferNode* buffers_to_delete = NULL;
 343   {
 344     MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
 345     while (_completed_buffers_head != NULL) {
 346       BufferNode* nd = _completed_buffers_head;
 347       _completed_buffers_head = nd->next();
 348       nd->set_next(buffers_to_delete);
 349       buffers_to_delete = nd;
 350     }
 351     _completed_buffers_tail = NULL;
 352     _n_completed_buffers = 0;
 353     DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked());
 354   }
 355   while (buffers_to_delete != NULL) {
 356     BufferNode* nd = buffers_to_delete;
 357     buffers_to_delete = nd->next();
< prev index next >