RFR: 8287647: VM debug support: find node by pattern in name or dump

Emanuel Peter epeter at openjdk.java.net
Mon Jun 13 11:19:53 UTC 2022


On Mon, 13 Jun 2022 09:33:31 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:

>> **Goal**
>> Refactor `Node::find`, allow not just searching for `node->_idx`, but also matching for `node->Name()` and even `node->dump()`.
>> 
>> **Proposal**
>> Refactor `Node::find` into `visit_nodes`, which visits all nodes and calls a `callback` on them. This callback can be used to filter by `idx` (`find_node_by_idx`, `Node::find`, `find_node` etc.). It can also be used to match node names (`find_node_by_name`) and even node dump (`find_node_by_dump`).
>> 
>> Thus, I present these additional functions:
>> `Node* find_node_by_name(const char* name)`: find all nodes matching the `name` pattern.
>> `Node* find_node_by_dump(const char* pattern)`: find all nodes matching the `pattern`.
>> The nodes are sorted by node idx, and then dumped.
>> 
>> Patterns can contain `*` characters to match any characters (eg. `Con*L` matches both `ConL` and `ConvI2L`)
>> 
>> **Usecase**
>> Find all `CastII` nodes. Find all `Loop` nodes. Use `find_node_by_name`.
>> 
>> Find all all `CastII` nodes that depend on a rangecheck. Use `find_node_by_dump("CastII*range check dependency")`.
>> Find all `Bool` nodes that perform a `[ne]` check. Use `find_node_by_dump("Bool*[ne]")`.
>> Find all `Phi` nodes that are `tripcount`. Use `find_node_by_dump("Phi*tripcount")`.
>> 
>> Find all `Load` nodes that are associated with line 301 in some file. Use `find_node_by_dump("Load*line 301")`.
>> 
>> You can probably find more usecases yourself ;)
>
> src/hotspot/share/opto/node.cpp line 1692:
> 
>> 1690:   }
>> 1691:   return nullptr; // no i was a match
>> 1692: }
> 
> Suggesting: move this code to `src/hotspot/share/utilities/stringUtils.cpp`.

moving the two string functions to that file, thanks for the suggestion!

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

PR: https://git.openjdk.org/jdk/pull/8988


More information about the hotspot-compiler-dev mailing list