RFR: 8261954: Dependencies: Improve iteration over class hierarchy under context class

Vladimir Kozlov kvn at openjdk.java.net
Thu Feb 18 17:58:40 UTC 2021


On Thu, 18 Feb 2021 17:05:08 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

> Simplify `ClassHierarchyWalker::find_witness_anywhere()` which iterates over class hierarchy under context class searching for witnesses.
> 
> Current implementation traverses the hierarchy in a breadth-first manner and keeps a stack-allocated array to keep a worklist.
> But all the subclasses are already part of a singly linked list formed by `Klass::subklass()`/`next_sibling()`/`superklass()`.
> 
> Proposed refactoring gets rid of the explicit worklist and switches to the traversal over the linked list (encapsulated into `ClassHierarchyIterator`). It performs depth-first pre-order hierarchy traversal. 
> 
> (There are some other minor refactorings applied in `ClassHierarchyWalker` along the way.) 
> 
> Testing:
> - [x] hs-tier1 - hs-tier8
> - [x] additional verification that CHA decisions aren't affected

Except `do_counts` changes seem fine to me.

src/hotspot/share/code/dependencies.cpp line 1329:

> 1327:   assert_locked_or_safepoint(Compile_lock);
> 1328: 
> 1329:   bool do_counts = count_find_witness_calls();

Does count_find_witness_calls() have side effects and required to be called here in product? If not,
`do_counts` is used only for not_product code, so consider enclose it into  NOT_PRODUCT() here and where it is used.

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

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


More information about the hotspot-runtime-dev mailing list