hrs_err_msg("[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: "PTR_FORMAT" prev0: "PTR_FORMAT" ""prev1: "PTR_FORMAT" length: %u",name(),count,curr,prev0,prev1,length()));
capacity+=curr->capacity();
prev1=prev0;
prev0=curr;
curr=curr->next();
}
guarantee(tail()==prev0,err_msg("Expected %s to end with %u but it ended with %u.",name(),tail()->hrs_index(),prev0->hrs_index()));
guarantee(length()==count,err_msg("%s count mismatch. Expected %u, actual %u.",name(),length(),count));
guarantee(total_capacity_bytes()==capacity,err_msg("%s capacity mismatch. Expected "SIZE_FORMAT", actual "SIZE_FORMAT,
name(),total_capacity_bytes(),capacity));
}
// Note on the check_mt_safety() methods below:
//
// Verification of the "master" heap region sets / lists that are
// maintained by G1CollectedHeap is always done during a STW pause and
// by the VM thread at the start / end of the pause. The standard
// verification methods all assert check_mt_safety(). This is
// important as it ensures that verification is done without
// concurrent updates taking place at the same time. It follows, that,
// for the "master" heap region sets / lists, the check_mt_safety()
// method should include the VM thread / STW case.
voidMasterFreeRegionListMtSafeChecker::check(){
// Master Free List MT safety protocol:
// (a) If we're at a safepoint, operations on the master free list
// should be invoked by either the VM thread (which will serialize
// them) or by the GC workers while holding the
// FreeList_lock.
// (b) If we're not at a safepoint, operations on the master free
// list should be invoked while holding the Heap_lock.
if(SafepointSynchronize::is_at_safepoint()){
guarantee(Thread::current()->is_VM_thread()||
FreeList_lock->owned_by_self(),"master free list MT safety protocol at a safepoint");
}else{
guarantee(Heap_lock->owned_by_self(),"master free list MT safety protocol outside a safepoint");
// Verification of the "master" heap region sets / lists that are
// maintained by G1CollectedHeap is always done during a STW pause and
// by the VM thread at the start / end of the pause. The standard
// verification methods all assert check_mt_safety(). This is
// important as it ensures that verification is done without
// concurrent updates taking place at the same time. It follows, that,
// for the "master" heap region sets / lists, the check_mt_safety()
// method should include the VM thread / STW case.
voidFreeRegionList::verify_list(){
HeapRegion*curr=head();
HeapRegion*prev1=NULL;
HeapRegion*prev0=NULL;
uintcount=0;
size_tcapacity=0;
while(curr!=NULL){
verify_region(curr);
count++;
guarantee(count<_unrealistically_long_length,
hrs_err_msg("[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: "PTR_FORMAT" prev0: "PTR_FORMAT" ""prev1: "PTR_FORMAT" length: %u",name(),count,curr,prev0,prev1,length()));
capacity+=curr->capacity();
prev1=prev0;
prev0=curr;
curr=curr->next();
}
guarantee(tail()==prev0,err_msg("Expected %s to end with %u but it ended with %u.",name(),tail()->hrs_index(),prev0->hrs_index()));
guarantee(length()==count,err_msg("%s count mismatch. Expected %u, actual %u.",name(),length(),count));
guarantee(total_capacity_bytes()==capacity,err_msg("%s capacity mismatch. Expected "SIZE_FORMAT", actual "SIZE_FORMAT,
name(),total_capacity_bytes(),capacity));
}
voidMasterFreeRegionListMtSafeChecker::check(){
// Master Free List MT safety protocol:
// (a) If we're at a safepoint, operations on the master free list
// should be invoked by either the VM thread (which will serialize
// them) or by the GC workers while holding the
// FreeList_lock.
// (b) If we're not at a safepoint, operations on the master free
// list should be invoked while holding the Heap_lock.
if(SafepointSynchronize::is_at_safepoint()){
guarantee(Thread::current()->is_VM_thread()||
FreeList_lock->owned_by_self(),"master free list MT safety protocol at a safepoint");
}else{
guarantee(Heap_lock->owned_by_self(),"master free list MT safety protocol outside a safepoint");