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

Reviewed-by: kvn, coleenp, eosterlund
This commit is contained in:
Vladimir Ivanov 2021-02-26 08:19:47 +00:00
parent 722142ee6c
commit 0a4e710ff6
3 changed files with 104 additions and 105 deletions

View file

@ -4284,3 +4284,24 @@ void InstanceKlass::log_to_classlist(const ClassFileStream* stream) const {
}
#endif // INCLUDE_CDS
}
// Make a step iterating over the class hierarchy under the root class.
// Skips subclasses if requested.
void ClassHierarchyIterator::next() {
assert(_current != NULL, "required");
if (_visit_subclasses && _current->subklass() != NULL) {
_current = _current->subklass();
return; // visit next subclass
}
_visit_subclasses = true; // reset
while (_current->next_sibling() == NULL && _current != _root) {
_current = _current->superklass(); // backtrack; no more sibling subclasses left
}
if (_current == _root) {
// Iteration is over (back at root after backtracking). Invalidate the iterator.
_current = NULL;
return;
}
_current = _current->next_sibling();
return; // visit next sibling subclass
}