RFR: 8348411: C2: Remove the control input of LoadKlassNode and LoadNKlassNode [v4]

Emanuel Peter epeter at openjdk.org
Tue Feb 4 18:47:25 UTC 2025


On Thu, 30 Jan 2025 17:11:08 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Hi,
>> 
>> This patch removes the control input of `LoadKlassNode` and `LoadNKlassNode`. They can only have a control input if created inside `Parse::array_store_check()`, the reason given is:
>> 
>>     // We are allowed to use the constant type only if cast succeeded
>> 
>> But this seems incorrect, the load from the constant type can be done regardless, and it will be constant-folded. This patch only makes that more formal and cleanup `LoadKlassNode::can_remove_control`.
>> 
>> Please take a look and leave your reviews, thanks a lot.
>
> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   format

Nice cleanup.
Though it looks like you are doing more than remove the ctrl input. I don't know the code very well, so I have some questions ;)

src/hotspot/share/opto/parseHelper.cpp line 170:

> 168:       !too_many_traps(Deoptimization::Reason_array_check) &&
> 169:       !tak->klass_is_exact() &&
> 170:       tak->isa_aryklassptr()) {

Looks like an implicit `nullptr` check. Not allowed by code style ;)

src/hotspot/share/opto/parseHelper.cpp line 193:

> 191:       // See issue JDK-8057622 for details.
> 192: 
> 193:     always_see_exact_class = true;

Why is it ok to remove this?
If this branch is not taken, it used to be `false`, and would lead to something different below...

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

Changes requested by epeter (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/23274#pullrequestreview-2593742600
PR Review Comment: https://git.openjdk.org/jdk/pull/23274#discussion_r1941714615
PR Review Comment: https://git.openjdk.org/jdk/pull/23274#discussion_r1941719070


More information about the hotspot-compiler-dev mailing list