Prepare for verification?

Jesper Wilhelmsson jesper.wilhelmsson at oracle.com
Thu Aug 21 06:58:54 UTC 2014


Thanks Jon!

Bengt had the theory that the fixing up was only needed before GC since 
afterwards the GC itself has fixed everything already. That sounds reasonable to 
me so I'll just keep the current behavior in my change. Later we should consider 
renaming prepare_for_verify() to prepare_for_verify_before_gc() to indicate that 
it's only needed at this point.
/Jesper


Jon Masamitsu skrev 20/8/14 18:43:
> prepare_for_verify() was needed by CMS, partly, because CMS could
> have dead objects in the CMS generation after the collection.  I think
> it was needed with the VerifyDuringGC for CMS.  There was something
> like a scan of the CMS generation to check that all the objects on the
> freelists were dead and objects not on the freelists were live.  The
> prepare_for_verify() is not optional.
>
> The linear allocation blocks were used for perm gen allocation.
> Maybe also for the initial allocations from the cms gen.  Linear
> allocation blocks are allocated from the cms gen and then
> objects are allocated from them by pointer bumps.  Generally
> the coalescing of the free blocks isn't good enough to get
> contiguous chunks of space big enough for the linear
> allocation blocks.  Don't recall why they need to be
> fixed up for verification.  Maybe filler objects had to be
> inserted.
>
> Jon
>
>
> On 8/20/2014 7:23 AM, Jesper Wilhelmsson wrote:
>> Hi,
>>
>> When removing the generations array I ran in to the following question.
>>
>> In GenCollectedHeap::do_collection() there is this code:
>>
>> if (VerifyBeforeGC && i >= VerifyGCLevel &&
>>     total_collections() >= VerifyGCStartAt) {
>>   HandleMark hm;  // Discard invalid handles created during verification
>>   if (!prepared_for_verification) {
>>     prepare_for_verify();
>>     prepared_for_verification = true;
>>   }
>>   Universe::verify(" VerifyBeforeGC:");
>> }
>>
>> Note that we make sure to run prepare_for_verify() before calling
>> Universe::verify().
>>
>> Later there is this code:
>>
>> if (VerifyAfterGC && i >= VerifyGCLevel &&
>>     total_collections() >= VerifyGCStartAt) {
>>   HandleMark hm;  // Discard invalid handles created during verification
>>   Universe::verify(" VerifyAfterGC:");
>> }
>>
>> Here we do not prepare for verification.
>>
>>
>> Now, what happens if we run with VerifyBeforeGC=false and VerifyAfterGC=true?
>>
>> As far as I can see, only CMS has an implementation for prepare_for_verify(),
>> where it does things like
>> CompactibleFreeListSpace::repairLinearAllocationBlocks()
>>
>> I have been playing around with CMS trying to provoke something here but I
>> can't say that I understand the linear allocation blocks well enough to know
>> how to create a potentially bad situation. Could there be a problem here or is
>> the preparation before verification voluntary?
>>
>> Since I'm rewriting this code slightly I need to know if I should preserve
>> this behavior or make sure that we have prepared in the after GC case as well.
>>
>> Thanks,
>> /Jesper
>



More information about the hotspot-gc-dev mailing list