Thu, 01 Apr 2010 11:23:01 -0400
Merge
1.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Fri Mar 26 11:10:26 2010 -0400 1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Thu Apr 01 11:23:01 2010 -0400 1.3 @@ -760,7 +760,10 @@ 1.4 rp->setup_policy(false); // snapshot the soft ref policy to be used in this cycle 1.5 1.6 SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); 1.7 - satb_mq_set.set_active_all_threads(true); 1.8 + // This is the start of the marking cycle, we're expected all 1.9 + // threads to have SATB queues with active set to false. 1.10 + satb_mq_set.set_active_all_threads(true, /* new active value */ 1.11 + false /* expected_active */); 1.12 1.13 // update_g1_committed() will be called at the end of an evac pause 1.14 // when marking is on. So, it's also called at the end of the 1.15 @@ -1079,7 +1082,11 @@ 1.16 gclog_or_tty->print_cr("\nRemark led to restart for overflow."); 1.17 } else { 1.18 // We're done with marking. 1.19 - JavaThread::satb_mark_queue_set().set_active_all_threads(false); 1.20 + // This is the end of the marking cycle, we're expected all 1.21 + // threads to have SATB queues with active set to true. 1.22 + JavaThread::satb_mark_queue_set().set_active_all_threads( 1.23 + false, /* new active value */ 1.24 + true /* expected_active */); 1.25 1.26 if (VerifyDuringGC) { 1.27 HandleMark hm; // handle scope 1.28 @@ -2586,7 +2593,11 @@ 1.29 1.30 SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); 1.31 satb_mq_set.abandon_partial_marking(); 1.32 - satb_mq_set.set_active_all_threads(false); 1.33 + // This can be called either during or outside marking, we'll read 1.34 + // the expected_active value from the SATB queue set. 1.35 + satb_mq_set.set_active_all_threads( 1.36 + false, /* new active value */ 1.37 + satb_mq_set.is_active() /* expected_active */); 1.38 } 1.39 1.40 static void print_ms_time_info(const char* prefix, const char* name,
2.1 --- a/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp Fri Mar 26 11:10:26 2010 -0400 2.2 +++ b/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp Thu Apr 01 11:23:01 2010 -0400 2.3 @@ -35,7 +35,7 @@ 2.4 2.5 void G1SATBCardTableModRefBS::enqueue(oop pre_val) { 2.6 assert(pre_val->is_oop_or_null(true), "Error"); 2.7 - if (!JavaThread::satb_mark_queue_set().active()) return; 2.8 + if (!JavaThread::satb_mark_queue_set().is_active()) return; 2.9 Thread* thr = Thread::current(); 2.10 if (thr->is_Java_thread()) { 2.11 JavaThread* jt = (JavaThread*)thr; 2.12 @@ -51,7 +51,7 @@ 2.13 G1SATBCardTableModRefBS::write_ref_field_pre_static(T* field, 2.14 oop new_val, 2.15 JavaThread* jt) { 2.16 - if (!JavaThread::satb_mark_queue_set().active()) return; 2.17 + if (!JavaThread::satb_mark_queue_set().is_active()) return; 2.18 T heap_oop = oopDesc::load_heap_oop(field); 2.19 if (!oopDesc::is_null(heap_oop)) { 2.20 oop pre_val = oopDesc::decode_heap_oop_not_null(heap_oop); 2.21 @@ -62,7 +62,7 @@ 2.22 2.23 template <class T> void 2.24 G1SATBCardTableModRefBS::write_ref_array_pre_work(T* dst, int count) { 2.25 - if (!JavaThread::satb_mark_queue_set().active()) return; 2.26 + if (!JavaThread::satb_mark_queue_set().is_active()) return; 2.27 T* elem_ptr = dst; 2.28 for (int i = 0; i < count; i++, elem_ptr++) { 2.29 T heap_oop = oopDesc::load_heap_oop(elem_ptr);
3.1 --- a/src/share/vm/gc_implementation/g1/ptrQueue.cpp Fri Mar 26 11:10:26 2010 -0400 3.2 +++ b/src/share/vm/gc_implementation/g1/ptrQueue.cpp Thu Apr 01 11:23:01 2010 -0400 3.3 @@ -25,8 +25,8 @@ 3.4 # include "incls/_precompiled.incl" 3.5 # include "incls/_ptrQueue.cpp.incl" 3.6 3.7 -PtrQueue::PtrQueue(PtrQueueSet* qset_, bool perm) : 3.8 - _qset(qset_), _buf(NULL), _index(0), _active(false), 3.9 +PtrQueue::PtrQueue(PtrQueueSet* qset_, bool perm, bool active) : 3.10 + _qset(qset_), _buf(NULL), _index(0), _active(active), 3.11 _perm(perm), _lock(NULL) 3.12 {} 3.13
4.1 --- a/src/share/vm/gc_implementation/g1/ptrQueue.hpp Fri Mar 26 11:10:26 2010 -0400 4.2 +++ b/src/share/vm/gc_implementation/g1/ptrQueue.hpp Thu Apr 01 11:23:01 2010 -0400 4.3 @@ -62,7 +62,7 @@ 4.4 public: 4.5 // Initialize this queue to contain a null buffer, and be part of the 4.6 // given PtrQueueSet. 4.7 - PtrQueue(PtrQueueSet*, bool perm = false); 4.8 + PtrQueue(PtrQueueSet*, bool perm = false, bool active = false); 4.9 // Release any contained resources. 4.10 void flush(); 4.11 // Calls flush() when destroyed. 4.12 @@ -101,6 +101,8 @@ 4.13 } 4.14 } 4.15 4.16 + bool is_active() { return _active; } 4.17 + 4.18 static int byte_index_to_index(int ind) { 4.19 assert((ind % oopSize) == 0, "Invariant."); 4.20 return ind / oopSize; 4.21 @@ -257,7 +259,7 @@ 4.22 bool process_completed_buffers() { return _process_completed; } 4.23 void set_process_completed(bool x) { _process_completed = x; } 4.24 4.25 - bool active() { return _all_active; } 4.26 + bool is_active() { return _all_active; } 4.27 4.28 // Set the buffer size. Should be called before any "enqueue" operation 4.29 // can be called. And should only be called once.
5.1 --- a/src/share/vm/gc_implementation/g1/satbQueue.cpp Fri Mar 26 11:10:26 2010 -0400 5.2 +++ b/src/share/vm/gc_implementation/g1/satbQueue.cpp Thu Apr 01 11:23:01 2010 -0400 5.3 @@ -82,9 +82,57 @@ 5.4 t->satb_mark_queue().handle_zero_index(); 5.5 } 5.6 5.7 -void SATBMarkQueueSet::set_active_all_threads(bool b) { 5.8 +#ifdef ASSERT 5.9 +void SATBMarkQueueSet::dump_active_values(JavaThread* first, 5.10 + bool expected_active) { 5.11 + gclog_or_tty->print_cr("SATB queue active values for Java Threads"); 5.12 + gclog_or_tty->print_cr(" SATB queue set: active is %s", 5.13 + (is_active()) ? "TRUE" : "FALSE"); 5.14 + gclog_or_tty->print_cr(" expected_active is %s", 5.15 + (expected_active) ? "TRUE" : "FALSE"); 5.16 + for (JavaThread* t = first; t; t = t->next()) { 5.17 + bool active = t->satb_mark_queue().is_active(); 5.18 + gclog_or_tty->print_cr(" thread %s, active is %s", 5.19 + t->name(), (active) ? "TRUE" : "FALSE"); 5.20 + } 5.21 +} 5.22 +#endif // ASSERT 5.23 + 5.24 +void SATBMarkQueueSet::set_active_all_threads(bool b, 5.25 + bool expected_active) { 5.26 + assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); 5.27 + JavaThread* first = Threads::first(); 5.28 + 5.29 +#ifdef ASSERT 5.30 + if (_all_active != expected_active) { 5.31 + dump_active_values(first, expected_active); 5.32 + 5.33 + // I leave this here as a guarantee, instead of an assert, so 5.34 + // that it will still be compiled in if we choose to uncomment 5.35 + // the #ifdef ASSERT in a product build. The whole block is 5.36 + // within an #ifdef ASSERT so the guarantee will not be compiled 5.37 + // in a product build anyway. 5.38 + guarantee(false, 5.39 + "SATB queue set has an unexpected active value"); 5.40 + } 5.41 +#endif // ASSERT 5.42 _all_active = b; 5.43 - for(JavaThread* t = Threads::first(); t; t = t->next()) { 5.44 + 5.45 + for (JavaThread* t = first; t; t = t->next()) { 5.46 +#ifdef ASSERT 5.47 + bool active = t->satb_mark_queue().is_active(); 5.48 + if (active != expected_active) { 5.49 + dump_active_values(first, expected_active); 5.50 + 5.51 + // I leave this here as a guarantee, instead of an assert, so 5.52 + // that it will still be compiled in if we choose to uncomment 5.53 + // the #ifdef ASSERT in a product build. The whole block is 5.54 + // within an #ifdef ASSERT so the guarantee will not be compiled 5.55 + // in a product build anyway. 5.56 + guarantee(false, 5.57 + "thread has an unexpected active value in its SATB queue"); 5.58 + } 5.59 +#endif // ASSERT 5.60 t->satb_mark_queue().set_active(b); 5.61 } 5.62 }
6.1 --- a/src/share/vm/gc_implementation/g1/satbQueue.hpp Fri Mar 26 11:10:26 2010 -0400 6.2 +++ b/src/share/vm/gc_implementation/g1/satbQueue.hpp Thu Apr 01 11:23:01 2010 -0400 6.3 @@ -29,8 +29,7 @@ 6.4 class ObjPtrQueue: public PtrQueue { 6.5 public: 6.6 ObjPtrQueue(PtrQueueSet* qset_, bool perm = false) : 6.7 - PtrQueue(qset_, perm) 6.8 - {} 6.9 + PtrQueue(qset_, perm, qset_->is_active()) { } 6.10 // Apply the closure to all elements, and reset the index to make the 6.11 // buffer empty. 6.12 void apply_closure(ObjectClosure* cl); 6.13 @@ -55,6 +54,9 @@ 6.14 // is ignored. 6.15 bool apply_closure_to_completed_buffer_work(bool par, int worker); 6.16 6.17 +#ifdef ASSERT 6.18 + void dump_active_values(JavaThread* first, bool expected_active); 6.19 +#endif // ASSERT 6.20 6.21 public: 6.22 SATBMarkQueueSet(); 6.23 @@ -65,9 +67,11 @@ 6.24 6.25 static void handle_zero_index_for_thread(JavaThread* t); 6.26 6.27 - // Apply "set_active(b)" to all thread tloq's. Should be called only 6.28 - // with the world stopped. 6.29 - void set_active_all_threads(bool b); 6.30 + // Apply "set_active(b)" to all Java threads' SATB queues. It should be 6.31 + // called only with the world stopped. The method will assert that the 6.32 + // SATB queues of all threads it visits, as well as the SATB queue 6.33 + // set itself, has an active value same as expected_active. 6.34 + void set_active_all_threads(bool b, bool expected_active); 6.35 6.36 // Register "blk" as "the closure" for all queues. Only one such closure 6.37 // is allowed. The "apply_closure_to_completed_buffer" method will apply