src/hotspot/share/gc/g1/g1HeapVerifier.cpp
changeset 49632 64f9ebc85e67
parent 49607 acffe6ff3ae7
child 49643 a3453bbd5418
equal deleted inserted replaced
49631:2520a95cddf7 49632:64f9ebc85e67
   518 void G1HeapVerifier::verify_region_sets() {
   518 void G1HeapVerifier::verify_region_sets() {
   519   assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
   519   assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
   520 
   520 
   521   // First, check the explicit lists.
   521   // First, check the explicit lists.
   522   _g1h->_hrm.verify();
   522   _g1h->_hrm.verify();
   523   {
       
   524     // Given that a concurrent operation might be adding regions to
       
   525     // the secondary free list we have to take the lock before
       
   526     // verifying it.
       
   527     MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
       
   528     _g1h->_secondary_free_list.verify_list();
       
   529   }
       
   530 
       
   531   // If a concurrent region freeing operation is in progress it will
       
   532   // be difficult to correctly attributed any free regions we come
       
   533   // across to the correct free list given that they might belong to
       
   534   // one of several (free_list, secondary_free_list, any local lists,
       
   535   // etc.). So, if that's the case we will skip the rest of the
       
   536   // verification operation. Alternatively, waiting for the concurrent
       
   537   // operation to complete will have a non-trivial effect on the GC's
       
   538   // operation (no concurrent operation will last longer than the
       
   539   // interval between two calls to verification) and it might hide
       
   540   // any issues that we would like to catch during testing.
       
   541   if (_g1h->free_regions_coming()) {
       
   542     return;
       
   543   }
       
   544 
       
   545   // Make sure we append the secondary_free_list on the free_list so
       
   546   // that all free regions we will come across can be safely
       
   547   // attributed to the free_list.
       
   548   _g1h->append_secondary_free_list_if_not_empty_with_lock();
       
   549 
   523 
   550   // Finally, make sure that the region accounting in the lists is
   524   // Finally, make sure that the region accounting in the lists is
   551   // consistent with what we see in the heap.
   525   // consistent with what we see in the heap.
   552 
   526 
   553   VerifyRegionListsClosure cl(&_g1h->_old_set, &_g1h->_humongous_set, &_g1h->_hrm);
   527   VerifyRegionListsClosure cl(&_g1h->_old_set, &_g1h->_humongous_set, &_g1h->_hrm);