Skip to content

8359359: AArch64: share trampolines between static calls to the same method #25954

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikabl-arm
Copy link
Contributor

@mikabl-arm mikabl-arm commented Jun 24, 2025

Modify the C2 compiler to share trampoline stubs between static calls that resolve to the same callee method. Since the relocation target for all static calls is initially set to the static call resolver stub, the call's target alone cannot be used to distinguish between different static method calls. Instead, trampoline stubs should be shared based on the actual callee.

The SharedTrampolineTest.java was designed to verify the sharing of trampolines among static calls. However, due to imprecise log analysis, the test currently passes even when trampolines are not shared. Additionally, comments within the test suggest ambiguity regarding whether it was intended to assess trampoline sharing for static calls or runtime calls. To address these issues and eliminate ambiguity, this patch renames and updates the existing test. Furthermore, a new test is introduced, using the existing one as a foundation, to accurately evaluate trampoline sharing for both static and runtime calls.

This has passed tier1-3 and jcstress testing on AArch64.


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-8359359: AArch64: share trampolines between static calls to the same method (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25954

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

Using diff file

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

Using Webrev

Link to Webrev Comment

…method

Modify the C2 compiler to share trampoline stubs between static calls
that resolve to the same callee method. Since the relocation target for
all static calls is initially set to the static call resolver stub, the
call's target alone cannot be used to distinguish between different
static method calls. Instead, trampoline stubs should be shared based
on the actual callee.

The `SharedTrampolineTest.java` was designed to verify the sharing of
trampolines among static calls. However, due to imprecise log analysis,
the test currently passes even when trampolines are not shared.
Additionally, comments within the test suggest ambiguity regarding
whether it was intended to assess trampoline sharing for static calls
or runtime calls. To address these issues and eliminate ambiguity, this
patch renames and updates the existing test. Furthermore, a new test is
introduced, using the existing one as a foundation, to accurately
evaluate trampoline sharing for both static and runtime calls.
@bridgekeeper
Copy link

bridgekeeper bot commented Jun 24, 2025

👋 Welcome back mablakatov! 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 Jun 24, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

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

openjdk bot commented Jun 24, 2025

@mikabl-arm 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.

@mlbridge
Copy link

mlbridge bot commented Jun 24, 2025

Webrevs

@theRealAph
Copy link
Contributor

One thing that looks a little odd: why do you maintain two separate lists and two sets of trampoline stub handlers?

@mikabl-arm
Copy link
Contributor Author

Hi @theRealAph , thank you for taking a look.

JIC, these are hash tables with (target address; list of requests (call site offsets)) as (k;v) pairs. I've considered unifying the two hash tables. The problem here is the keys. We need a way to distinguish between runtime call keys and static call keys as we iterate through the table. We could use CodeCache::is_non_nmethod(address addr) for that but this would only work when segmented code cache is enabled as far as I understand.

We could use something like Pair<callKind, address> for keys instead and use the first to distinguish between runtime and static calls. I'd need to extend template<...> class Pair so it properly supports hashing and comparison (at least equality) for this to work.

@mikabl-arm
Copy link
Contributor Author

@theRealAph , I've tried the above and it seems to work as intended. Please let me know if you find that solution more suitable and I'll prepare a patch for submission.

@theRealAph
Copy link
Contributor

We could use something like Pair<callKind, address> for keys instead and use the first to distinguish between runtime and static calls. I'd need to extend template<...> class Pair so it properly supports hashing and comparison (at least equality) for this to work.

Sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants