Skip to content

Conversation

@ashu-mehra
Copy link
Contributor

@ashu-mehra ashu-mehra commented Oct 23, 2025

This patch pre-resolves constant pool entries referred by getstatic, putstatic and invokestatic bytecodes in the assembly phase.
It also extends ResolvedConstants.java test to run in AOT mode workflow and additional test for checking resolution of static CP entries.

Before this PR, stats on pre-resolved CP entries in the assembly phase reported by -Xlog:aot=info:

[2.161s][info ][aot        ] Class  CP entries =  12553, archived =   3707 ( 29.5%), reverted =      0
[2.161s][info ][aot        ] Field  CP entries =   5236, archived =   1355 ( 25.9%), reverted =      0
[2.161s][info ][aot        ] Method CP entries =   3835, archived =   3818 ( 99.6%), reverted =     17
[2.161s][info ][aot        ] Indy   CP entries =      9, archived =      9 (100.0%), reverted =      0

After this PR:

2.323s][info ][aot        ] Class  CP entries =  12553, archived =   3700 ( 29.5%), reverted =      0
[2.323s][info ][aot        ] Field  CP entries =   5236, archived =   3519 ( 67.2%), reverted =      0
[2.323s][info ][aot        ] Method CP entries =  21027, archived =   5527 ( 26.3%), reverted =     17
[2.323s][info ][aot        ] Indy   CP entries =    353, archived =      9 (  2.5%), reverted =      0

Update: The stats quoted above are for a simple HelloWorld program


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-8334898: Resolve static field/method references at CDS dump time (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27958

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

Using diff file

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

Using Webrev

Link to Webrev Comment

Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
@bridgekeeper
Copy link

bridgekeeper bot commented Oct 23, 2025

👋 Welcome back asmehra! 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 Oct 23, 2025

@ashu-mehra 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:

8334898: Resolve static field/method references at CDS dump time

Reviewed-by: iklam

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 47 new commits pushed to the master branch:

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.

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

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Oct 23, 2025
@openjdk
Copy link

openjdk bot commented Oct 23, 2025

@ashu-mehra The following label will be automatically applied to this pull request:

  • hotspot

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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 23, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 23, 2025

Webrevs

@ashu-mehra
Copy link
Contributor Author

@iklam can you please review

Copy link
Member

@iklam iklam left a comment

Choose a reason for hiding this comment

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

LGTM. I am testing this PR in our CI.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 23, 2025
@iklam
Copy link
Member

iklam commented Oct 24, 2025

The zero builds fail with the following:

Creating jdk-26-internal_linux-x64_bin-tests-debug.tar.gz
Creating interim jimage
Compiling up to 2 files for CLASSLIST_JAR
Creating support/classlist.jar
ERROR: Failed to generate link optimization data. This is likely a problem with the newly built JVM/JDK.
Error occurred during initialization of VM
java.lang.InternalError: platform encoding not initialized
	at jdk.internal.util.SystemProps$Raw.platformProperties(java.base/Native Method)
	at jdk.internal.util.SystemProps$Raw.<init>(java.base/SystemProps.java:266)
	at jdk.internal.util.SystemProps.initProperties(java.base/SystemProps.java:67)
	at java.lang.System.initPhase1(java.base/System.java:1784)

GenerateLinkOptData.gmk:74: recipe for target '/workspace/build/linux-x64-zero-debug/support/link_opt/classlist' failed
make[3]: *** [/workspace/build/linux-x64-zero-debug/support/link_opt/classlist] Error 1
make/Main.gmk:657: recipe for target 'generate-link-opt-data' failed
make[2]: *** [generate-link-opt-data] Error 2

@iklam
Copy link
Member

iklam commented Oct 24, 2025

Other than the zero build failures, all other tests passed in our CI.

VM_Version::supports_fast_class_init_checks() is false

Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
…ast_class_init_checks() is false

Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
@ashu-mehra
Copy link
Contributor Author

ashu-mehra commented Oct 24, 2025

@iklam Zero does not support fast class init checks, so the CP entries for static bytecodes should not be resolved. I have pushed changes to do that.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 24, 2025
remove_resolved_method_entries_if_non_deterministic()

Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
@ashu-mehra
Copy link
Contributor Author

@iklam can you please review the new changes. With this update zero config builds fine.

Copy link
Member

@iklam iklam left a comment

Choose a reason for hiding this comment

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

Update looks good!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 25, 2025
resolved_klass->name()->as_C_string(),
(rme->is_resolved(Bytecodes::_invokestatic) ? " *** static" : ""));
}
ArchiveBuilder::alloc_stats()->record_method_cp_entry(archived, resolved && !archived);
Copy link
Contributor

Choose a reason for hiding this comment

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

It certainly looks right to move this outside the test for logging being enabled but does it make any practical difference i.e.is the statistic used for anything other than this logging category?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, I don't it affects anything other than the stats for logging. I think this was just a bug.

Copy link
Contributor

@adinn adinn 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 to me.

@ashu-mehra
Copy link
Contributor Author

@adinn if it looks okay, can you please approve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot hotspot-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants