Skip to content
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

8344913: Improve -Xlog:cds+map+oop logging for Java mirrors #22345

Conversation

iklam
Copy link
Member

@iklam iklam commented Nov 24, 2024

The following information is added to the -Xlog:cds+map+oop output for examining the java/lang/Class oop instances inside the AOT cache:

  • Print the name of the class
  • Print the value of the static fields
  • Print the resolved_reference_array for this class, so it's easy to see what constant pool entries (for Lambdas, etc) are resolved.

Below is the new and modified output vs the previous version:

- 0x00000000ffe7af28: @@ Object (0xffe7af28) java.lang.Class
+ 0x00000000ffe7af28: @@ Object (0xffe7af28) java.lang.Class Ljava/lang/System;
  0x00000000ffe7af28:   40b7b001 0000035b 001bb638 00000000 001a9b90 00000008 00000000 00000000   ...@[...8.......................
  0x00000000ffe7af48:   00000013 0000000a 00000000 00000000 00000000 00000000 00000000 00000000   ................................
  0x00000000ffe7af68:   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000   ................................
  0x00000000ffe7af88:   00000000 00000000 00000000 fff04c58 00000000 00000000 00000000 00000000   ............XL..................
  0x00000000ffe7afa8:   00000000 00000000 00000000 00000000 00000000 00000000                     ........................
   - klass: 'java/lang/Class' 0x00000008001bb638
   - fields (19 words):
   - private volatile transient 'classRedefinedCount' 'I' @12  0 (0x00000000)
   - injected 'klass' 'J' @16 0x00000008001a9b90 (marked metadata pointer @0x00000000ffe7af38 )
   - injected 'array_klass' 'J' @24  0 (0x0000000000000000)
   - injected 'oop_size' 'I' @32  19 (0x00000013)
   - injected 'static_oop_field_count' 'I' @36  10 (0x0000000a)
   - private volatile transient 'cachedConstructor' 'Ljava/lang/reflect/Constructor;' @40 null
   - private transient 'name' 'Ljava/lang/String;' @44 null
   - private transient 'module' 'Ljava/lang/Module;' @48 null
   - private final 'classLoader' 'Ljava/lang/ClassLoader;' @52 null
   - private transient 'classData' 'Ljava/lang/Object;' @56 null
   - private transient 'signers' '[Ljava/lang/Object;' @60 null
   - private transient 'packageName' 'Ljava/lang/String;' @64 null
   - private final 'componentType' 'Ljava/lang/Class;' @68 null
   - private volatile transient 'reflectionData' 'Ljava/lang/ref/SoftReference;' @72 null
   - private volatile transient 'genericInfo' 'Lsun/reflect/generics/repository/ClassRepository;' @76 null
   - private volatile transient 'enumConstants' '[Ljava/lang/Object;' @80 null
   - private volatile transient 'enumConstantDirectory' 'Ljava/util/Map;' @84 null
   - private volatile transient 'annotationData' 'Ljava/lang/Class$AnnotationData;' @88 null
   - private volatile transient 'annotationType' 'Lsun/reflect/annotation/AnnotationType;' @92 null
   - transient 'classValueMap' 'Ljava/lang/ClassValue$ClassValueMap;' @96 null
   - injected 'protection_domain' 'Ljava/lang/Object;' @100 null
   - injected 'source_file' 'Ljava/lang/Object;' @104 null
   - injected '<init_lock>' 'Ljava/lang/Object;' @108 0x00000000fff04c58 (0xfff04c58) [I length: 0
+  - signature: Ljava/lang/System;
+  - archived_resolved_references: 0x00000000ffe31b18 (0xffe31b18) [Ljava.lang.Object; length: 29
+ - ---- static fields (10):
+  - public static final 'in' 'Ljava/io/InputStream;' @112 null
+  - public static final 'out' 'Ljava/io/PrintStream;' @116 null
+  - public static final 'err' 'Ljava/io/PrintStream;' @120 null
+  - private static 'initialIn' 'Ljava/io/InputStream;' @124 null
+  - private static 'initialErr' 'Ljava/io/PrintStream;' @128 null
+  - private static 'notSupportedJnuEncoding' 'Ljava/lang/String;' @132 null
+  - private static volatile 'cons' 'Ljava/io/Console;' @136 null
+  - private static 'props' 'Ljava/util/Properties;' @140 null
+  - private static 'lineSeparator' 'Ljava/lang/String;' @144 null
+  - static 'bootLayer' 'Ljava/lang/ModuleLayer;' @148 null

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8344913: Improve -Xlog:cds+map+oop logging for Java mirrors (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22345/head:pull/22345
$ git checkout pull/22345

Update a local copy of the PR:
$ git checkout pull/22345
$ git pull https://git.openjdk.org/jdk.git pull/22345/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22345

View PR using the GUI difftool:
$ git pr show -t 22345

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22345.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 24, 2024

👋 Welcome back iklam! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 24, 2024

@iklam 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:

8344913: Improve -Xlog:cds+map+oop logging for Java mirrors

Reviewed-by: dholmes, ccheung

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 24, 2024
@openjdk
Copy link

openjdk bot commented Nov 24, 2024

@iklam The following label will be automatically applied to this pull request:

  • hotspot-runtime

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.

@mlbridge
Copy link

mlbridge bot commented Nov 24, 2024

Webrevs

Comment on lines 1415 to 1461
static void print_oop_with_requested_addr_cr(outputStream* st, oop source_oop, bool print_addr = true) {
static void print_oop_with_requested_addr_cr(outputStream* st, oop source_oop, bool print_addr = true, bool print_aot_init = false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing but it seems very odd to me to have a function called print_oop_with_requested_addr and then have a parameter to control whether we print the addr.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the function name to print_oop_info_cr() and added comments about whether address(es) are printed, and in what format.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, albeit a bit complicated to follow what exactly is being printed where and why.

Comment on lines 1488 to 1498
if (print_aot_init) {
Klass* src_klass = java_lang_Class::as_Klass(scratch_mirror);
if (src_klass != nullptr && src_klass->is_instance_klass()) {
InstanceKlass* buffered_klass =
ArchiveBuilder::current()->get_buffered_addr(InstanceKlass::cast(src_klass));
if (buffered_klass->has_aot_initialized_mirror()) {
st->print(" (aot-inited)");
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we wouldn't always print whether or not it is aot-inited? It seems useful information.

@@ -1294,7 +1294,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {

if (source_oop != nullptr) {
// This is a regular oop that got archived.
print_oop_with_requested_addr_cr(&st, source_oop, false);
print_oop_with_requested_addr_cr(&st, source_oop, false, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the function takes two boolean args. I think it is good to add comments on those boolean args.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the comment about what the first false parameter means. I also removed the second parameter as suggested by David.

Copy link
Member

@calvinccheung calvinccheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 26, 2024
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update - looks good.

@iklam
Copy link
Member Author

iklam commented Nov 28, 2024

Thanks @dholmes-ora @calvinccheung for the review
/integrate

@openjdk
Copy link

openjdk bot commented Nov 28, 2024

Going to push as commit f51363e.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 28, 2024
@openjdk openjdk bot closed this Nov 28, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 28, 2024
@openjdk
Copy link

openjdk bot commented Nov 28, 2024

@iklam Pushed as commit f51363e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants