RFR: 8373513: C2: Move ProjNode::other_if_proj() to IfProjNode

Christian Hagedorn chagedorn at openjdk.org
Fri Dec 12 10:03:23 UTC 2025


On Fri, 12 Dec 2025 09:48:28 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

> This is a simple clean-up patch which moves `ProjNode::other_if_proj()` to `IfProjNode` and update its uses. It only makes sense to call `other_if_proj()` on actual `IfProjNodes`.
> 
> It also required to update more types from `ProjNode` to `IfProjNode` which is more type-safe and preciser. While touching the methods, I've also added some `const`/`static` where appropriate.
> 
> Thanks,
> Christian

src/hotspot/share/opto/ifnode.cpp line 794:

> 792:   if (otherproj->outcnt() == 1 && region != nullptr && !region->has_phi()) {
> 793:     for (int i = 0; i < 2; i++) {
> 794:       IfProjNode* next_proj = proj_out(i)->as_IfProj();

Renamed to not shadow the `proj` parameter. We could also think about whether we want to have a new method `if_proj_out(i)` in class `IfNode` at some point.

src/hotspot/share/opto/ifnode.cpp line 863:

> 861: 
> 862:     CallStaticJavaNode* unc = nullptr;
> 863:     IfProjNode* unc_proj = uncommon_trap_proj(unc)->as_IfProj();

I think we can also make `uncommon_trap_proj` return an `IfProjNode`. But I want to tackle that separately.

src/hotspot/share/opto/multnode.cpp line 263:

> 261:     return nullptr;
> 262:   }
> 263:   return as_IfProj()->other_if_proj()->is_uncommon_trap_proj(reason);

`is_uncommon_trap_if_pattern()` could also be moved to `IfProjNode`. I also want to do that separately.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28785#discussion_r2613602266
PR Review Comment: https://git.openjdk.org/jdk/pull/28785#discussion_r2613604562
PR Review Comment: https://git.openjdk.org/jdk/pull/28785#discussion_r2613610175


More information about the hotspot-compiler-dev mailing list