-
Notifications
You must be signed in to change notification settings - Fork 169
8383567: [lworld] VM.class_print_layout should use external class names #2375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
caspernorrbin
wants to merge
6
commits into
openjdk:lworld
Choose a base branch
from
caspernorrbin:print_class_layout_external_names
base: lworld
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13
−8
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2bdaa63
change print_class_layout to use external class names
caspernorrbin c8df796
feedback fixes
caspernorrbin eb127d3
feedback
caspernorrbin 6baa184
Merge branch 'lworld' into print_class_layout_external_names
caspernorrbin 7a18def
indent fix
caspernorrbin d1ffe8a
merge miss
caspernorrbin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
|
|
@@ -513,16 +513,16 @@ class HistoClosure : public KlassInfoClosure { | |
| } | ||
| }; | ||
|
|
||
| class FindClassByNameClosure : public KlassInfoClosure { | ||
| class FindClassByExternalNameClosure : public KlassInfoClosure { | ||
| private: | ||
| GrowableArray<Klass*>* _klasses; | ||
| Symbol* _classname; | ||
| const char* _classname; | ||
| public: | ||
| FindClassByNameClosure(GrowableArray<Klass*>* klasses, Symbol* classname) : | ||
| FindClassByExternalNameClosure(GrowableArray<Klass*>* klasses, const char* classname) : | ||
| _klasses(klasses), _classname(classname) { } | ||
|
|
||
| void do_cinfo(KlassInfoEntry* cie) { | ||
| if (cie->klass()->name() == _classname) { | ||
| if (strcmp(cie->klass()->external_name(), _classname) == 0) { | ||
| _klasses->append(cie->klass()); | ||
| } | ||
| } | ||
|
|
@@ -600,23 +600,19 @@ void PrintClassLayout::print_class_layout(outputStream* st, char* class_name) { | |
| return; | ||
| } | ||
|
|
||
| Thread* THREAD = Thread::current(); | ||
|
|
||
| Symbol* classname = SymbolTable::probe(class_name, (int)strlen(class_name)); | ||
|
|
||
| GrowableArray<Klass*>* klasses = new (mtServiceability) GrowableArray<Klass*>(100, mtServiceability); | ||
|
|
||
| FindClassByNameClosure fbnc(klasses, classname); | ||
| ResourceMark rm; | ||
| FindClassByExternalNameClosure fbnc(klasses, class_name); | ||
| cit.iterate(&fbnc); | ||
|
|
||
| for(int i = 0; i < klasses->length(); i++) { | ||
| Klass* klass = klasses->at(i); | ||
| if (!klass->is_instance_klass()) continue; // Skip | ||
| InstanceKlass* ik = InstanceKlass::cast(klass); | ||
| int tab = 1; | ||
| 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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may still need this to limit the ResourceArea usage, otherwise you will be keeping all allocations from the complete loop alive. |
||
| GrowableArray<FieldDesc>* fields = new (mtServiceability) GrowableArray<FieldDesc>(100, mtServiceability); | ||
| for (AllFieldStream fd(ik); !fd.done(); fd.next()) { | ||
| if (!fd.access_flags().is_static()) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree using
strcmpis not very efficient, since we iterate the fullKlassInfoTable. 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 onklass->name()). That way, we don't have to worry about comparing strings and we avoid lots of allocations fromexternal_name()As a side effect, this now also works on both internal and external names, as slashes would be left untouched.