index

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

Print this page
rev 7209 : 6979279


 185                          name, buf, index, sz);
 186 }
 187 #endif // PRODUCT
 188 
 189 #ifdef ASSERT
 190 void ObjPtrQueue::verify_oops_in_buffer() {
 191   if (_buf == NULL) return;
 192   for (size_t i = _index; i < _sz; i += oopSize) {
 193     oop obj = (oop)_buf[byte_index_to_index((int)i)];
 194     assert(obj != NULL && obj->is_oop(true /* ignore mark word */),
 195            "Not an oop");
 196   }
 197 }
 198 #endif
 199 
 200 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
 201 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
 202 #endif // _MSC_VER
 203 
 204 SATBMarkQueueSet::SATBMarkQueueSet() :
 205   PtrQueueSet(), _closure(NULL), _par_closures(NULL),
 206   _shared_satb_queue(this, true /*perm*/) { }
 207 
 208 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
 209                                   int process_completed_threshold,
 210                                   Mutex* lock) {
 211   PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
 212   _shared_satb_queue.set_lock(lock);
 213   if (ParallelGCThreads > 0) {
 214     _par_closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads, mtGC);
 215   }
 216 }
 217 
 218 void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
 219   DEBUG_ONLY(t->satb_mark_queue().verify_oops_in_buffer();)
 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 }


 259 
 260 void SATBMarkQueueSet::set_active_all_threads(bool active, bool expected_active) {
 261   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
 262 #ifdef ASSERT
 263   verify_active_states(expected_active);
 264 #endif // ASSERT
 265   _all_active = active;
 266   for (JavaThread* t = Threads::first(); t; t = t->next()) {
 267     t->satb_mark_queue().set_active(active);
 268   }
 269   shared_satb_queue()->set_active(active);
 270 }
 271 
 272 void SATBMarkQueueSet::filter_thread_buffers() {
 273   for(JavaThread* t = Threads::first(); t; t = t->next()) {
 274     t->satb_mark_queue().filter();
 275   }
 276   shared_satb_queue()->filter();
 277 }
 278 
 279 void SATBMarkQueueSet::set_closure(ObjectClosure* closure) {
 280   _closure = closure;
 281 }
 282 
 283 void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) {
 284   assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition");
 285   _par_closures[i] = par_closure;
 286 }
 287 
 288 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par,
 289                                                               uint worker) {
 290   BufferNode* nd = NULL;
 291   {
 292     MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
 293     if (_completed_buffers_head != NULL) {
 294       nd = _completed_buffers_head;
 295       _completed_buffers_head = nd->next();
 296       if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL;
 297       _n_completed_buffers--;
 298       if (_n_completed_buffers == 0) _process_completed = false;
 299     }
 300   }
 301   ObjectClosure* cl = (par ? _par_closures[worker] : _closure);
 302   if (nd != NULL) {
 303     void **buf = BufferNode::make_buffer_from_node(nd);
 304     ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
 305     deallocate_buffer(buf);
 306     return true;
 307   } else {
 308     return false;
 309   }
 310 }
 311 
 312 void SATBMarkQueueSet::iterate_completed_buffers_read_only(ObjectClosure* cl) {
 313   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
 314   assert(cl != NULL, "pre-condition");
 315 
 316   BufferNode* nd = _completed_buffers_head;
 317   while (nd != NULL) {
 318     void** buf = BufferNode::make_buffer_from_node(nd);
 319     ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
 320     nd = nd->next();
 321   }




 185                          name, buf, index, sz);
 186 }
 187 #endif // PRODUCT
 188 
 189 #ifdef ASSERT
 190 void ObjPtrQueue::verify_oops_in_buffer() {
 191   if (_buf == NULL) return;
 192   for (size_t i = _index; i < _sz; i += oopSize) {
 193     oop obj = (oop)_buf[byte_index_to_index((int)i)];
 194     assert(obj != NULL && obj->is_oop(true /* ignore mark word */),
 195            "Not an oop");
 196   }
 197 }
 198 #endif
 199 
 200 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
 201 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
 202 #endif // _MSC_VER
 203 
 204 SATBMarkQueueSet::SATBMarkQueueSet() :
 205   PtrQueueSet(), _closures(NULL),
 206   _shared_satb_queue(this, true /*perm*/) { }
 207 
 208 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
 209                                   int process_completed_threshold,
 210                                   Mutex* lock) {
 211   PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
 212   _shared_satb_queue.set_lock(lock);
 213   _closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads, mtGC);


 214 }
 215 
 216 void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
 217   DEBUG_ONLY(t->satb_mark_queue().verify_oops_in_buffer();)
 218   t->satb_mark_queue().handle_zero_index();
 219 }
 220 
 221 #ifdef ASSERT
 222 void SATBMarkQueueSet::dump_active_states(bool expected_active) {
 223   gclog_or_tty->print_cr("Expected SATB active state: %s",
 224                          expected_active ? "ACTIVE" : "INACTIVE");
 225   gclog_or_tty->print_cr("Actual SATB active states:");
 226   gclog_or_tty->print_cr("  Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
 227   for (JavaThread* t = Threads::first(); t; t = t->next()) {
 228     gclog_or_tty->print_cr("  Thread \"%s\" queue: %s", t->name(),
 229                            t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");
 230   }
 231   gclog_or_tty->print_cr("  Shared queue: %s",
 232                          shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
 233 }


 257 
 258 void SATBMarkQueueSet::set_active_all_threads(bool active, bool expected_active) {
 259   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
 260 #ifdef ASSERT
 261   verify_active_states(expected_active);
 262 #endif // ASSERT
 263   _all_active = active;
 264   for (JavaThread* t = Threads::first(); t; t = t->next()) {
 265     t->satb_mark_queue().set_active(active);
 266   }
 267   shared_satb_queue()->set_active(active);
 268 }
 269 
 270 void SATBMarkQueueSet::filter_thread_buffers() {
 271   for(JavaThread* t = Threads::first(); t; t = t->next()) {
 272     t->satb_mark_queue().filter();
 273   }
 274   shared_satb_queue()->filter();
 275 }
 276 
 277 void SATBMarkQueueSet::set_closure(int i, ObjectClosure* closure) {
 278   assert(_closures != NULL, "Precondition");
 279   _closures[i] = closure;




 280 }
 281 
 282 bool SATBMarkQueueSet::apply_closure_to_completed_buffer(uint worker) {

 283   BufferNode* nd = NULL;
 284   {
 285     MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
 286     if (_completed_buffers_head != NULL) {
 287       nd = _completed_buffers_head;
 288       _completed_buffers_head = nd->next();
 289       if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL;
 290       _n_completed_buffers--;
 291       if (_n_completed_buffers == 0) _process_completed = false;
 292     }
 293   }
 294   ObjectClosure* cl = _closures[worker];
 295   if (nd != NULL) {
 296     void **buf = BufferNode::make_buffer_from_node(nd);
 297     ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
 298     deallocate_buffer(buf);
 299     return true;
 300   } else {
 301     return false;
 302   }
 303 }
 304 
 305 void SATBMarkQueueSet::iterate_completed_buffers_read_only(ObjectClosure* cl) {
 306   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
 307   assert(cl != NULL, "pre-condition");
 308 
 309   BufferNode* nd = _completed_buffers_head;
 310   while (nd != NULL) {
 311     void** buf = BufferNode::make_buffer_from_node(nd);
 312     ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
 313     nd = nd->next();
 314   }


index