RFR: 8286179: Node::find(int) should not traverse from new to old nodes [v2]

Christian Hagedorn chagedorn at openjdk.java.net
Mon May 9 13:14:08 UTC 2022


On Mon, 9 May 2022 10:11:38 GMT, Emanuel Peter <duke at openjdk.java.net> wrote:

>> **Problem:**
>> `Node::find` traverses input and output edges of nodes during its BFS, and searches for nodes with a specific `idx`.
>> However, if `ASSERT` is on, it also traverses `debug_orig`. This not only seems unnecessary. But Mach nodes (after matching) point back to the old IR nodes. This means we traverse from the new graph to the old graph, and potentially find multiple nodes matching the `idx`. Only the last found will be returned, sometimes this happens to be the new node, sometimes the old node. This is inconsistent and can be quite annoying during debugging.
>> 
>> **Implemented Solution:**
>> 1. Remove traversing `debug_orig`.
>> 2. Instead, add debug only functions `old_root`, which finds the old root if it exists. Question: I now put a warning in if the `old_root` cannot be found. I think this is helpful for in the debugger. I could make it an assert if that is preferred.
>> 3. `find_node` and `find_ctrl` only search in new nodes now (start BFS at new root).
>> 4. Added `find_old_node` and `find_old_ctrl`, which search in new nodes (start BFS at old root).
>> 
>> I hope this improves your debugging experience.
>> [running sanity tests to see it doesn't break something]
>
> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   added nullprt check for old_root

Otherwise, it looks good to me.

src/hotspot/share/opto/node.cpp line 1617:

> 1615: Node* find_old_node(const int idx) {
> 1616:   Node* root = old_root();
> 1617:   assert(root != nullptr, "must have old_root() to find old nodes");

I think it's better to avoid assertions here and below and do nothing instead (you already print a warning in `old_root()` which is fine I think) since it would crash and stop the current debugging session.

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

Changes requested by chagedorn (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/8567


More information about the hotspot-compiler-dev mailing list