-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8295893: Improve printing of Constant Pool Cache Entries #10860
Conversation
👋 Welcome back matsaave! A progress list of the required criteria for merging this PR into |
@matias9927 The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
Can you post an example how it looks for method and field entries ? |
Calling findmethod will result in this output for an invokedynamic call:
You can see that the flag value is currently decoded twice, once as a quick translation and once in full detail. Printing will look nearly identical for a field but with different flags and no appendix. |
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.
Hi Matias,
A quick skim through showed a couple of minor issues to fix. I don't really use this output so I can't say whether the expanded format is helpful or too verbose (there are certainly a lot more lines printed now).
Thanks.
I added a null check for method, a ResourseMark, and I replaced the else if with an else and an assert. Thank you for the corrections! |
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.
Updates look good. One further nit, but otherwise seems okay. But someone who is actively going to be using this needs to comment on the format/content changes. Thanks.
For testing the handling of uninitialized ConstantPoolEntry's, you can do something like this:
This should catch the problem in your earlier commit where you didn't check for the NULL Method pointer. |
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 look at this output.
src/hotspot/share/oops/cpCache.cpp
Outdated
@@ -690,7 +687,7 @@ void ConstantPoolCacheEntry::print(outputStream* st, int index, const ConstantPo | |||
flag_state(), is_final(), is_volatile(), field_index()); | |||
st->print_cr(" - tos: %s\n - final: %d\n - volatile: %d\n - field index: %04x", | |||
type2name(as_BasicType(flag_state())), is_final(), is_volatile(), field_index()); | |||
//st->print_cr(" - is resolved: %s", pool->tag_at(constant_pool_index()->is_unresolved_klass()) ? "false" : "true"); | |||
st->print_cr(" - is resolved: %s", pool->tag_at(constant_pool_index()).is_unresolved_klass() ? "false" : "true"); |
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.
This is confusing and doesn't really help. "is_resolved" means that the bytecode_1 or bytecode_2 is filled in in the indices field. The constant pool index here is a JVM_CONSTANT_Fieldref which points to JVM_CONSTANT_NameAndType and JVM_CONSTANT_{UnresolvedClass,Class,UnresolvedClassInError}. I think this would always print false. I would just leave this line out.
st->print(" name_and_type_index=%d", uncached_name_and_type_ref_index_at(index)); | ||
// print strings not indices | ||
//st->print("klass_index=%d", uncached_klass_ref_index_at(index)); | ||
//st->print(" name_and_type_index=%d", uncached_name_and_type_ref_index_at(index)); |
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.
Should remove commented out code!
st->print("name_index=%d", name_ref_index_at(index)); | ||
st->print(" signature_index=%d", signature_ref_index_at(index)); | ||
// st->print("name_index=%d", name_ref_index_at(index)); | ||
// st->print(" signature_index=%d", signature_ref_index_at(index)); |
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.
Same here.
@@ -692,6 +692,30 @@ class ConstantPool : public Metadata { | |||
resolve_string_constants_impl(h_this, CHECK); | |||
} | |||
|
|||
// Acquire symbols from method and field entries | |||
// For fields and methods | |||
char* name_symbol_at(int which) { return symbol_at(name_ref_index_at(uncached_name_and_type_ref_index_at(which)))->as_C_string(); } |
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.
Can you align the {'s or use a line break and make these functions "const".
I made the mistake of pushing incomplete code which explains the chunks of commented code and other issues. I am currently further extending the information being printed both in the constant pool cache and the constant pool as requested by @iklam. That being said, I will take your corrections into account as I move forward! |
83a6cce
to
452ef59
Compare
@matias9927 Please do not rebase or force-push to an active PR as it invalidates existing review comments. All changes will be squashed into a single commit automatically when integrating. See OpenJDK Developers’ Guide for more information. |
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.
This looks good. The more verbose field entry information can be added in a further RFE.
@matias9927 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 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the 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, @coleenp, @iklam) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
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.
LGTM. Just a minor nit.
/integrate |
@matias9927 |
Thank you for the corrections and feedback @iklam @coleenp @dholmes-ora! |
@matias9927 |
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.
A couple of copyright notice issues need fixing. Thanks.
/integrate |
@matias9927 |
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.
Looks good. Thanks.
/sponsor |
Going to push as commit ba303c0.
Your commit was automatically rebased without conflicts. |
@coleenp @matias9927 Pushed as commit ba303c0. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
As an extension of JDK-8292699, this aims to further improve the printing of Constant Pool Cache entries. The contents and flag are decoded into human readable text with an appendix printed as before.
The text format and contents are tentative, please review.
Here is an example output when using
findmethod()
:Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10860/head:pull/10860
$ git checkout pull/10860
Update a local copy of the PR:
$ git checkout pull/10860
$ git pull https://git.openjdk.org/jdk pull/10860/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10860
View PR using the GUI difftool:
$ git pr show -t 10860
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10860.diff