src/share/vm/gc_implementation/g1/satbQueue.cpp

changeset 6396
f99e331f6ef6
parent 4037
da91efe96a93
child 6552
8847586c9037
     1.1 --- a/src/share/vm/gc_implementation/g1/satbQueue.cpp	Fri Jan 10 09:53:53 2014 +0100
     1.2 +++ b/src/share/vm/gc_implementation/g1/satbQueue.cpp	Fri Jan 10 09:54:25 2014 +0100
     1.3 @@ -219,58 +219,52 @@
     1.4  }
     1.5  
     1.6  #ifdef ASSERT
     1.7 -void SATBMarkQueueSet::dump_active_values(JavaThread* first,
     1.8 -                                          bool expected_active) {
     1.9 -  gclog_or_tty->print_cr("SATB queue active values for Java Threads");
    1.10 -  gclog_or_tty->print_cr(" SATB queue set: active is %s",
    1.11 -                         (is_active()) ? "TRUE" : "FALSE");
    1.12 -  gclog_or_tty->print_cr(" expected_active is %s",
    1.13 -                         (expected_active) ? "TRUE" : "FALSE");
    1.14 -  for (JavaThread* t = first; t; t = t->next()) {
    1.15 -    bool active = t->satb_mark_queue().is_active();
    1.16 -    gclog_or_tty->print_cr("  thread %s, active is %s",
    1.17 -                           t->name(), (active) ? "TRUE" : "FALSE");
    1.18 +void SATBMarkQueueSet::dump_active_states(bool expected_active) {
    1.19 +  gclog_or_tty->print_cr("Expected SATB active state: %s",
    1.20 +                         expected_active ? "ACTIVE" : "INACTIVE");
    1.21 +  gclog_or_tty->print_cr("Actual SATB active states:");
    1.22 +  gclog_or_tty->print_cr("  Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
    1.23 +  for (JavaThread* t = Threads::first(); t; t = t->next()) {
    1.24 +    gclog_or_tty->print_cr("  Thread \"%s\" queue: %s", t->name(),
    1.25 +                           t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");
    1.26 +  }
    1.27 +  gclog_or_tty->print_cr("  Shared queue: %s",
    1.28 +                         shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
    1.29 +}
    1.30 +
    1.31 +void SATBMarkQueueSet::verify_active_states(bool expected_active) {
    1.32 +  // Verify queue set state
    1.33 +  if (is_active() != expected_active) {
    1.34 +    dump_active_states(expected_active);
    1.35 +    guarantee(false, "SATB queue set has an unexpected active state");
    1.36 +  }
    1.37 +
    1.38 +  // Verify thread queue states
    1.39 +  for (JavaThread* t = Threads::first(); t; t = t->next()) {
    1.40 +    if (t->satb_mark_queue().is_active() != expected_active) {
    1.41 +      dump_active_states(expected_active);
    1.42 +      guarantee(false, "Thread SATB queue has an unexpected active state");
    1.43 +    }
    1.44 +  }
    1.45 +
    1.46 +  // Verify shared queue state
    1.47 +  if (shared_satb_queue()->is_active() != expected_active) {
    1.48 +    dump_active_states(expected_active);
    1.49 +    guarantee(false, "Shared SATB queue has an unexpected active state");
    1.50    }
    1.51  }
    1.52  #endif // ASSERT
    1.53  
    1.54 -void SATBMarkQueueSet::set_active_all_threads(bool b,
    1.55 -                                              bool expected_active) {
    1.56 +void SATBMarkQueueSet::set_active_all_threads(bool active, bool expected_active) {
    1.57    assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
    1.58 -  JavaThread* first = Threads::first();
    1.59 -
    1.60  #ifdef ASSERT
    1.61 -  if (_all_active != expected_active) {
    1.62 -    dump_active_values(first, expected_active);
    1.63 -
    1.64 -    // I leave this here as a guarantee, instead of an assert, so
    1.65 -    // that it will still be compiled in if we choose to uncomment
    1.66 -    // the #ifdef ASSERT in a product build. The whole block is
    1.67 -    // within an #ifdef ASSERT so the guarantee will not be compiled
    1.68 -    // in a product build anyway.
    1.69 -    guarantee(false,
    1.70 -              "SATB queue set has an unexpected active value");
    1.71 +  verify_active_states(expected_active);
    1.72 +#endif // ASSERT
    1.73 +  _all_active = active;
    1.74 +  for (JavaThread* t = Threads::first(); t; t = t->next()) {
    1.75 +    t->satb_mark_queue().set_active(active);
    1.76    }
    1.77 -#endif // ASSERT
    1.78 -  _all_active = b;
    1.79 -
    1.80 -  for (JavaThread* t = first; t; t = t->next()) {
    1.81 -#ifdef ASSERT
    1.82 -    bool active = t->satb_mark_queue().is_active();
    1.83 -    if (active != expected_active) {
    1.84 -      dump_active_values(first, expected_active);
    1.85 -
    1.86 -      // I leave this here as a guarantee, instead of an assert, so
    1.87 -      // that it will still be compiled in if we choose to uncomment
    1.88 -      // the #ifdef ASSERT in a product build. The whole block is
    1.89 -      // within an #ifdef ASSERT so the guarantee will not be compiled
    1.90 -      // in a product build anyway.
    1.91 -      guarantee(false,
    1.92 -                "thread has an unexpected active value in its SATB queue");
    1.93 -    }
    1.94 -#endif // ASSERT
    1.95 -    t->satb_mark_queue().set_active(b);
    1.96 -  }
    1.97 +  shared_satb_queue()->set_active(active);
    1.98  }
    1.99  
   1.100  void SATBMarkQueueSet::filter_thread_buffers() {

mercurial