RFR: 8353290: C2: Refactor PhaseIdealLoop::is_counted_loop() [v2]

Kangcheng Xu kxu at openjdk.org
Wed Apr 16 20:34:44 UTC 2025


On Fri, 11 Apr 2025 08:15:28 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> That was my initial thought, too; however, `PhaseIdealLoop::insert_loop_limit_check_predicate()`, `::lazy_replace()`, `::set_subtree_ctrl()` and many other mutations make this impossible.
>
> You might be confusing it with having:
> 
> const PhaseIdealLoop* _phase
> 
> where we cannot call any non-const methods. That's indeed not possible. But what I mean was to make the pointer const:
> 
> PhaseIdealLoop* const _phase;
> 
> such that you cannot do `_phase = xyz` later. You would probably not do that anyway but it's an easy addition and safety for all fields not being reassigned again. It also helps to see which fields are going to be updated as part of the mutable state and which fields are not.

Sorry I neglected your diff. Yes `const` on the pointers make sense. I'm marking immutable fields `const`. Thanks for pointing this out!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24458#discussion_r2047701303


More information about the hotspot-compiler-dev mailing list