RFR: 8370220: C2: rename methods and improve documentation around get_ctrl and idom lazy updating/forwarding of ctrl and idom via dead ctrl nodes
    Christian Hagedorn 
    chagedorn at openjdk.org
       
    Mon Oct 20 13:59:37 UTC 2025
    
    
  
On Mon, 20 Oct 2025 13:17:29 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> When working on https://github.com/openjdk/jdk/pull/27889, I was irritated by the lack of documentation and suboptimal naming.
>> 
>> Here, I'm doing the following:
>> - Add more documentation, and improve it in other cases.
>> - Rename "lazy" methods: "lazy" could indicate that we delay it somehow until later, but it is unclear what is delayed.
>>   - `lazy_replace` -> `replace_ctrl_node_and_forward_ctrl_and_idom`
>>   - `lazy_update` -> `install_lazy_ctrl_and_idom_forwarding`
>> - Made some methods private, and added some additional asserts.
>> 
>> I'd be more than happy for even better names, and suggestions how to improve the documentation further :)
>> 
>> Related issues:
>> https://github.com/openjdk/jdk/pull/27889
>> https://github.com/openjdk/jdk/pull/15720
>> 
>> TODO: improve `VerifyLoopOptimizations` to check that we can call `get_ctrl` on all live nodes after loop-opts.
>
> src/hotspot/share/opto/loopnode.hpp line 1176:
> 
>> 1174:   // - Update the node inputs of all uses.
>> 1175:   // - Lazily update the ctrl and idom info of all uses, via a ctrl/idom forwarding.
>> 1176:   void replace_ctrl_node_and_forward_ctrl_and_idom(Node *old_node, Node *new_node) {
> 
> Maybe add here and/or in `install_lazy_ctrl_and_idom_forwarding()` an assert that we have a CFG nodes (i.e. `is_CFG()`) additionally to the `!has_ctrl()` asserts.
Just noticed this: We often (intuitively?) seem to use "control" when talking about just some control nodes and "ctrl" when talking about the nodes found/fetched from `_loop_or_ctrl`. Under this light, we might want to name the method "replace_control_node_and_forward_ctrl_and_idom" to better distinguish them. But I don't have a strong opinion about it - your call 👍
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27892#discussion_r2445046836
    
    
More information about the hotspot-compiler-dev
mailing list