8383567: [lworld] VM.class_print_layout should use external class names#2375
8383567: [lworld] VM.class_print_layout should use external class names#2375caspernorrbin wants to merge 3 commits intoopenjdk:lworldfrom
Conversation
|
👋 Welcome back cnorrbin! A progress list of the required criteria for merging this PR into |
|
@caspernorrbin This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 246 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dholmes-ora) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
| st->print_cr("Class %s [@%s]:", klass->name()->as_C_string(), | ||
| st->print_cr("Class %s [@%s]:", klass->external_name(), | ||
| klass->class_loader_data()->loader_name()); | ||
| ResourceMark rm; |
There was a problem hiding this comment.
You may still need this to limit the ResourceArea usage, otherwise you will be keeping all allocations from the complete loop alive.
| st->print_cr("Class %s [@%s]:", klass->name()->as_C_string(), | ||
| st->print_cr("Class %s [@%s]:", klass->external_name(), |
There was a problem hiding this comment.
Doesn't it suffice to just make this change? If we convert to Symbol it seems more efficient than using strcmp (though I confess I'm not clear what this closure is actually doing and what set of classes it potentially generates).
There was a problem hiding this comment.
I agree using strcmp is not very efficient, since we iterate the full KlassInfoTable. We still need to keep the external name as the argument however, but I reverted most changes for a different design. Now, we instead convert user input from dotted to slash form once, then use the same logic as before (probe the symbol table, then match on klass->name()). That way, we don't have to worry about comparing strings and we avoid lots of allocations from external_name()
As a side effect, this now also works on both internal and external names, as slashes would be left untouched.
dholmes-ora
left a comment
There was a problem hiding this comment.
I'd missed the fact the user-supplied class name was also expected in internal form and needed to be changed to use Java form instead. I have some thoughts on that below but perhaps that is better handled in a separate RFE.
| if (*p == '.') { | ||
| *p = '/'; |
There was a problem hiding this comment.
This should use JVM_SIGNATURE_DOT and JVM_SIGNATURE_SLASH - though it makes me cringe that we have to do this ad-hoc conversion.
There was a problem hiding this comment.
I didn't know these existed, but I swapped to use these now.
| char* normalized_name = NEW_RESOURCE_ARRAY(char, strlen(class_name) + 1); | ||
| strcpy(normalized_name, class_name); |
There was a problem hiding this comment.
Do we have to make a copy here rather than modifying in place? The user-supplied string is already in a mutable C-heap allocated buffer, as processed by the DCmd framework. If we think it inappropriate to modify at this level perhaps we can push the conversion up into the DCmd framework itself?
There was a problem hiding this comment.
There's already a Symbol::as_klass_external_name(char* buf, int size) method to do the '/'s into '.'s conversion. Should this code be moved to a new Symbol::as_klass_internal_name(char* buf, int size) method?
There was a problem hiding this comment.
I kept it in the same location as of now, but removed the extra allocation. I don't think putting it in Symbol is the right place, because here we are just modifying a mutable char*. So the operation is not really on a symbol. But it could perhaps be moved to where we parse the DCmd instead, if you feel like it doesn't belong here.
| st->print_cr("Class %s [@%s]:", klass->external_name(), | ||
| klass->class_loader_data()->loader_name()); |
There was a problem hiding this comment.
| st->print_cr("Class %s [@%s]:", klass->external_name(), | |
| klass->class_loader_data()->loader_name()); | |
| st->print_cr("Class %s [@%s]:", klass->external_name(), | |
| klass->class_loader_data()->loader_name()); |
Pre-existing indent nit
Hi everyone,
PrintClassLayout::print_class_layoutexpects internal class names as its argument, but is called externally by users throughjcmd. This leads to inconsistencies with other functions. For example:In addition, its output is also in the internal format. This should be changed to also use the external dotted class name instead.
For this fix I changed theI added a conversion from external dotted names to internal slashed names before we start searching for classes. That way we avoid comparing strings and avoid allocations from calls toClosureused for finding classes to instead use external names, and also swapped the output print to use the external name.external_name(). As a side effect, this now works on both internal and external names, as slashes are left untouched.Testing:
jcmdProgress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/2375/head:pull/2375$ git checkout pull/2375Update a local copy of the PR:
$ git checkout pull/2375$ git pull https://git.openjdk.org/valhalla.git pull/2375/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2375View PR using the GUI difftool:
$ git pr show -t 2375Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2375.diff
Using Webrev
Link to Webrev Comment