RFR: 8264644: Add PrintClassLoaderDataGraphAtExit to print the detailed CLD graph [v3]

David Holmes david.holmes at oracle.com
Wed Apr 7 06:04:28 UTC 2021


On 7/04/2021 3:30 pm, Yi Yang wrote:
> On Wed, 7 Apr 2021 05:07:54 GMT, David Holmes <dholmes at openjdk.org> wrote:
> 
>>> Yi Yang has updated the pull request incrementally with two additional commits since the last revision:
>>>
>>>   - add CLDG_lock
>>>   - use PTR_FORMAT
>>
>> src/hotspot/share/classfile/classLoaderData.cpp line 952:
>>
>>> 950:     out->print_cr("");
>>> 951:   }
>>> 952:   out->print_cr(" - class loader        " PTR_FORMAT, p2i(_class_loader.ptr_raw()));
>>
>> I'm surprised the p2i's were added. If the values are pointers then p2i should not be needed. If using p2i then INTPTR_FORMAT is the correct format specifier to use.
> 
> I'm not sure the original intentions of these two macros. It looks like the definitions of PRT_FORMAT and INTPTR_FORMAT are identical:
> 
> https://github.com/openjdk/jdk/blob/c3abdc9aadc734053dbcc43d5294d5f16a0b0ce3/src/hotspot/share/utilities/globalDefinitions.hpp#L129-L132

Yes the ultimate definitions are currently identical. The issue is about 
semantic correctness: if printing a pointer type use PTR_FORMAT; if 
printing an integer representation of a pointer (as provided by p2i()) 
then use INTPTR_FORMAT.

> Also I find many occurrences that using p2i while format specifier is PRT_FORMAT. If this is indeed wrong, I may fix them later.

Yes unfortunately there is a lot of inconsistency here. p2i was 
introduced with:

http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/53a41e7cbe05

and it was a very large change. Since then, in parts of runtime at 
least, we have tried to use them in a consistent way.

Thanks,
David

> -------------
> 
> PR: https://git.openjdk.java.net/jdk/pull/3323
> 


More information about the hotspot-dev mailing list