Skip to content

Conversation

@ashu-mehra
Copy link
Contributor

@ashu-mehra ashu-mehra commented Nov 4, 2025

Preserve the "fast" version of getfield and putfield bytecodes in the AOTCache during the assembly phase if the constant pool entry referred by the bytecodes is stored in resolved state in the AOTCache.

Testing:
Testing with JTREG="AOT_JDK=true" TEST=hotspot_runtime_no_cds passed on x86-64


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-8371178: Preserve fast version of getfield and putfield in AOTCache (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28121

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

Using diff file

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

Using Webrev

Link to Webrev Comment

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

bridgekeeper bot commented Nov 4, 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 Nov 4, 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:

8371178: Preserve fast version of getfield and putfield in AOTCache

Reviewed-by: adinn, 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 219 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-runtime hotspot-runtime-dev@openjdk.org label Nov 4, 2025
@openjdk
Copy link

openjdk bot commented Nov 4, 2025

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

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

mlbridge bot commented Nov 4, 2025

Webrevs

@ashu-mehra
Copy link
Contributor Author

For the record, I tried to preserve _fast_Xaccess_0 bytecodes (these are the fast versions for the pair (aload_0, getfield)) but then these bytecodes breaks serviceability/jvmti/FieldAccessWatch/FieldAccessWatch.java test because the JVMTI event notifications for field access are skipped. Morevoer, I believe setting JVMTI breakpoint on the original location of the getfield bytecode won't work either.
While the notifications to field access can be fixed, enabling breakpoint is more challenging and probably not worth the effort.
So in this patch I only preserve the fast versions of getfield and putfield bytecodes.

@ashu-mehra
Copy link
Contributor Author

@iklam @adinn can you please review this patch.

Comment on lines 551 to 556
switch(rfe->tos_state()) {
case btos:
// fallthrough
case ztos:
new_code = Bytecodes::_fast_bgetfield;
break;
Copy link
Member

Choose a reason for hiding this comment

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

Why is this switch block necessary? Is it possible for new_code to be different than *bcs.bcp()? If not, it might be easier to initialize new_code to Bytecodes::_illegal and then do the rewriting only if new_code has been updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is this switch block necessary? Is it possible for new_code to be different than *bcs.bcp()?

During preimage dumping all the fast bytecodes will be converted to nofast version because the CP entries are not resolved. So in the assembly phase *bcs.bcp() would be nofast version. If the CP entry is resolved, we can convert it to fast version. And we determine the type of the fast version using tos_state of the resolved field entry. So the new_code will be different than the *bcs.bcp() in the assembly phase.
They may be same when dumping dynamic archives, but not when dumping static archive or the final AOTCache.
Does that help?

Copy link
Member

Choose a reason for hiding this comment

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

I see. Could you add a comment? Maybe the code should be reformatted like this to make it easier to navigate?

        case ftos:  new_code = Bytecodes::_fast_fgetfield;  break;
        case dtos: new_code = Bytecodes::_fast_dgetfield; break;
        default:  ShouldNotReachHere();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 634 to 635
case Bytecodes::_aload_0:
new_code = Bytecodes::_nofast_aload_0;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment here that _fast_Xaccess_0 bytecodes will be reverted?

Comment on lines 551 to 556
switch(rfe->tos_state()) {
case btos:
// fallthrough
case ztos:
new_code = Bytecodes::_fast_bgetfield;
break;
Copy link
Member

Choose a reason for hiding this comment

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

I see. Could you add a comment? Maybe the code should be reformatted like this to make it easier to navigate?

        case ftos:  new_code = Bytecodes::_fast_fgetfield;  break;
        case dtos: new_code = Bytecodes::_fast_dgetfield; break;
        default:  ShouldNotReachHere();

Comment on lines 544 to 549
#ifdef ASSERT
if (CDSConfig::is_dumping_preimage_static_archive()) {
assert(!is_resolved, "preimage should not have resolved field references");
}
#endif // ASSERT
if (is_resolved) {
Copy link
Member

Choose a reason for hiding this comment

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

I think the above can be simplified:

if (is_resolved) {
  assert(!CDSConfig::is_dumping_preimage_static_archive(), "preimage should not have resolved field references");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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

@iklam addressed the review comments in the new commit. I also updated function names to remove "nofast" to better reflect the updates to their functionality.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 5, 2025
@ashu-mehra
Copy link
Contributor Author

@adinn thanks for the 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

@ashu-mehra
Copy link
Contributor Author

@iklam thanks for the review.

@ashu-mehra
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 5, 2025

Going to push as commit 1357be9.
Since your change was applied there have been 219 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 5, 2025

@ashu-mehra Pushed as commit 1357be9.

💡 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 hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants