RFR: 8356328: Some C2 IR nodes miss size_of() function

kuaiwei duke at openjdk.org
Wed May 7 07:38:16 UTC 2025


On Wed, 7 May 2025 07:24:30 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

> Good catch! It would currently only be a problem when we clone nodes which is probably hard to check statically (could, for example, be part of a loop body and then be cloned).
> 
> Some questions:
> 
> * Have you also checked the Mach nodes?
> * Have you also checked that `cmp()` is overridden in case `hash()` is not `NO_HASH` for those nodes that specify at least one field?
> 
> Just a side node, you can also just use `sizeof(*this)` which is often done in the code.

I checked node list in share/opto/classes.hpp, so MachNode/MachNullCheckNode/MachProjNode are checked. For mach nodes created by adlc, I found adlc will always add size_of function.
I haven't checked `cmp() and hash()` , I will check if my test can cover these.

IMO,  `sizeof(SomeNode)` is more clear than `sizeof(*this)`  , so I choose this style.

Thanks for your comments.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/25081#issuecomment-2857436783


More information about the hotspot-compiler-dev mailing list