Skip to content

8382489: aarch64: Clean up redundant restore_locals() in TemplateTable::invokeinterface#30813

Closed
zifeihan wants to merge 1 commit intoopenjdk:masterfrom
zifeihan:JDK-8382489
Closed

8382489: aarch64: Clean up redundant restore_locals() in TemplateTable::invokeinterface#30813
zifeihan wants to merge 1 commit intoopenjdk:masterfrom
zifeihan:JDK-8382489

Conversation

@zifeihan
Copy link
Copy Markdown
Member

@zifeihan zifeihan commented Apr 19, 2026

Summary

Remove redundant restore_locals() calls in TemplateTable::invokeinterface() on AArch64 and RISC-V architectures. On x86, this call is necessary because the implementation explicitly uses rlocals (r14) as a temporary register throughout the invokeinterface handler, modifying it in multiple code paths. However, on AArch64 and RISC-V, the locals register (rlocals/xlocals) remains untouched throughout the entire invokeinterface execution, making the restore call redundant.

Problem

In templateTable_aarch64.cpp, the invokeinterface() bytecode handler contains a restore_locals()
call at the notVFinal label that is never needed because no preceding code path modifies the locals register.

Code Flow Analysis

void TemplateTable::invokeinterface(int byte_no) {
  load_resolved_method_entry_interface(...);  // May call call_VM → already restores locals
  prepare_invoke(...);                         // Does NOT use rlocals

  // Forced virtual path
  Label notObjectMethod;
  __ tbz(r3, ...is_forced_virtual_shift, notObjectMethod);
  invokevirtual_helper(rmethod, r2, r3);       // Uses r0, r3, r4 - NOT rlocals
  __ bind(notObjectMethod);

  Label no_such_interface;

  // vfinal path
  Label notVFinal;
  __ tbz(r3, ...is_vfinal_shift, notVFinal);
  __ load_klass(r3, r2);                       // Uses r3, NOT rlocals
  __ check_klass_subtype(r3, r0, r4, subtype); // Uses r3, r4 - NOT rlocals
  __ jump_from_interpreted(...);               // Jumps away, never returns to notVFinal

  // notVFinal path (only reached if NOT vfinal)
  __ bind(notVFinal);
  __ restore_locals();  // ← REDUNDANT: rlocals was never modified!
  __ load_klass(r3, r2);
  ...
}

Testing

  • tier1, tier2 tests on linux-aarch64(fastdebug)

  • I confirm that I make this contribution in accordance with the OpenJDK Interim AI Policy.


Progress

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

Issue

  • JDK-8382489: aarch64: Clean up redundant restore_locals() in TemplateTable::invokeinterface (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30813

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Apr 19, 2026

👋 Welcome back gcao! 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
Copy Markdown

openjdk Bot commented Apr 19, 2026

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

8382489: aarch64: Clean up redundant restore_locals() in TemplateTable::invokeinterface

Reviewed-by: aph, fyang, dzhang

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 33 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.

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 (@theRealAph, @RealFYang, @DingliZhang) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk Bot changed the title 8382489: aarch64: Clean up redundant restore_locals() in TemplateTabl… 8382489: aarch64: Clean up redundant restore_locals() in TemplateTable::invokeinterface Apr 19, 2026
@openjdk openjdk Bot added the hotspot hotspot-dev@openjdk.org label Apr 19, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 19, 2026

@zifeihan 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
Copy link
Copy Markdown

openjdk Bot commented Apr 19, 2026

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot. This can be overridden with the /reviewers command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label Apr 19, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented Apr 19, 2026

Webrevs

Copy link
Copy Markdown
Contributor

@theRealAph theRealAph 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, thanks.

Copy link
Copy Markdown
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Apr 21, 2026
Copy link
Copy Markdown
Member

@DingliZhang DingliZhang left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@lfoltan
Copy link
Copy Markdown
Member

lfoltan commented Apr 21, 2026

You appear to have used a generative AI tool to create this PR. This violates the OpenJDK AI Policy (https://openjdk.org/legal/ai). Please close this PR and open a new PR that does not contain any AI-generated content.

@zifeihan
Copy link
Copy Markdown
Member Author

You appear to have used a generative AI tool to create this PR. This violates the OpenJDK AI Policy (https://openjdk.org/legal/ai). Please close this PR and open a new PR that does not contain any AI-generated content.

Thank you for your suggestion. I used AI to help me write the PR description. I’ve already created a new PR. #30864

@zifeihan zifeihan closed this Apr 22, 2026
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.

5 participants