src/hotspot/share/gc/g1/satbMarkQueue.cpp
changeset 48196 5ee29f4ec472
parent 48105 8d15b1369c7a
child 49007 82d9d5744e5f
equal deleted inserted replaced
48087:f5d7096cfdc0 48196:5ee29f4ec472
    30 #include "memory/allocation.inline.hpp"
    30 #include "memory/allocation.inline.hpp"
    31 #include "oops/oop.inline.hpp"
    31 #include "oops/oop.inline.hpp"
    32 #include "runtime/mutexLocker.hpp"
    32 #include "runtime/mutexLocker.hpp"
    33 #include "runtime/safepoint.hpp"
    33 #include "runtime/safepoint.hpp"
    34 #include "runtime/thread.hpp"
    34 #include "runtime/thread.hpp"
       
    35 #include "runtime/threadSMR.hpp"
    35 #include "runtime/vmThread.hpp"
    36 #include "runtime/vmThread.hpp"
    36 
    37 
    37 SATBMarkQueue::SATBMarkQueue(SATBMarkQueueSet* qset, bool permanent) :
    38 SATBMarkQueue::SATBMarkQueue(SATBMarkQueueSet* qset, bool permanent) :
    38   // SATB queues are only active during marking cycles. We create
    39   // SATB queues are only active during marking cycles. We create
    39   // them with their active field set to false. If a thread is
    40   // them with their active field set to false. If a thread is
   212 #ifdef ASSERT
   213 #ifdef ASSERT
   213 void SATBMarkQueueSet::dump_active_states(bool expected_active) {
   214 void SATBMarkQueueSet::dump_active_states(bool expected_active) {
   214   log_error(gc, verify)("Expected SATB active state: %s", expected_active ? "ACTIVE" : "INACTIVE");
   215   log_error(gc, verify)("Expected SATB active state: %s", expected_active ? "ACTIVE" : "INACTIVE");
   215   log_error(gc, verify)("Actual SATB active states:");
   216   log_error(gc, verify)("Actual SATB active states:");
   216   log_error(gc, verify)("  Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
   217   log_error(gc, verify)("  Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
   217   for (JavaThread* t = Threads::first(); t; t = t->next()) {
   218   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
   218     log_error(gc, verify)("  Thread \"%s\" queue: %s", t->name(), t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");
   219     log_error(gc, verify)("  Thread \"%s\" queue: %s", t->name(), t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");
   219   }
   220   }
   220   log_error(gc, verify)("  Shared queue: %s", shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
   221   log_error(gc, verify)("  Shared queue: %s", shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
   221 }
   222 }
   222 
   223 
   226     dump_active_states(expected_active);
   227     dump_active_states(expected_active);
   227     guarantee(false, "SATB queue set has an unexpected active state");
   228     guarantee(false, "SATB queue set has an unexpected active state");
   228   }
   229   }
   229 
   230 
   230   // Verify thread queue states
   231   // Verify thread queue states
   231   for (JavaThread* t = Threads::first(); t; t = t->next()) {
   232   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
   232     if (t->satb_mark_queue().is_active() != expected_active) {
   233     if (t->satb_mark_queue().is_active() != expected_active) {
   233       dump_active_states(expected_active);
   234       dump_active_states(expected_active);
   234       guarantee(false, "Thread SATB queue has an unexpected active state");
   235       guarantee(false, "Thread SATB queue has an unexpected active state");
   235     }
   236     }
   236   }
   237   }
   247   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
   248   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
   248 #ifdef ASSERT
   249 #ifdef ASSERT
   249   verify_active_states(expected_active);
   250   verify_active_states(expected_active);
   250 #endif // ASSERT
   251 #endif // ASSERT
   251   _all_active = active;
   252   _all_active = active;
   252   for (JavaThread* t = Threads::first(); t; t = t->next()) {
   253   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
   253     t->satb_mark_queue().set_active(active);
   254     t->satb_mark_queue().set_active(active);
   254   }
   255   }
   255   shared_satb_queue()->set_active(active);
   256   shared_satb_queue()->set_active(active);
   256 }
   257 }
   257 
   258 
   258 void SATBMarkQueueSet::filter_thread_buffers() {
   259 void SATBMarkQueueSet::filter_thread_buffers() {
   259   for(JavaThread* t = Threads::first(); t; t = t->next()) {
   260   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
   260     t->satb_mark_queue().filter();
   261     t->satb_mark_queue().filter();
   261   }
   262   }
   262   shared_satb_queue()->filter();
   263   shared_satb_queue()->filter();
   263 }
   264 }
   264 
   265 
   307     print_satb_buffer(buffer, buf, nd->index(), buffer_size());
   308     print_satb_buffer(buffer, buf, nd->index(), buffer_size());
   308     nd = nd->next();
   309     nd = nd->next();
   309     i += 1;
   310     i += 1;
   310   }
   311   }
   311 
   312 
   312   for (JavaThread* t = Threads::first(); t; t = t->next()) {
   313   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
   313     jio_snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name());
   314     jio_snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name());
   314     t->satb_mark_queue().print(buffer);
   315     t->satb_mark_queue().print(buffer);
   315   }
   316   }
   316 
   317 
   317   shared_satb_queue()->print("Shared");
   318   shared_satb_queue()->print("Shared");
   339     buffers_to_delete = nd->next();
   340     buffers_to_delete = nd->next();
   340     deallocate_buffer(nd);
   341     deallocate_buffer(nd);
   341   }
   342   }
   342   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
   343   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
   343   // So we can safely manipulate these queues.
   344   // So we can safely manipulate these queues.
   344   for (JavaThread* t = Threads::first(); t; t = t->next()) {
   345   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
   345     t->satb_mark_queue().reset();
   346     t->satb_mark_queue().reset();
   346   }
   347   }
   347  shared_satb_queue()->reset();
   348   shared_satb_queue()->reset();
   348 }
   349 }