Skip to content

Conversation

@adinn
Copy link
Contributor

@adinn adinn commented Nov 20, 2025

This PR adds save and restore of all generated stubs to the AOT code cache on x86 and aarch64. Other arches are modified to deal with the related generic PAI changes.

Small changes were required to the aarch64 and x86_64 generator code in order to meet two key constraints:

  1. the first declared entry of every stub starts at the first instruction in the stub code range
  2. all data/code cross-references from one stub to another target a declared stub entry

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

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28433

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 20, 2025

👋 Welcome back adinn! 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 20, 2025

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

@openjdk
Copy link

openjdk bot commented Nov 20, 2025

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

@adinn
Copy link
Contributor Author

adinn commented Nov 20, 2025

This PR still needs to ensure that pre-universe stub entries are registered in the AOT address table. These stubs cannot be saved and restored because the AOT cache does not exist before universe init. As a consequence their addresses cannot be registered using the normal generate time mechanism. The required fix will be to add them via special case handling as soon as the AOT cache and address table have been initialised (preferably at the point where the majority of external addresses are registered).

This omission is not a problem for this patch i.e. as far as reference from existing stubs is concerned since none of the saved stubs targets to a pre-universe stub entry. However, they ought to be registered in case that situation changes or in case an nmethod that gets saved to and reloaded from the AOT cache needs at some point to target a pre-universe stub.

Comment on lines +603 to +611
int entry_count = StubInfo::entry_count(stub_id);
assert(entry_count == 1, "sanity check");
if (find_archive_data(stub_id)) {
address start = nullptr;
address end = nullptr;
load_archive_data(stub_id, start, end);
return start;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This code pattern repeats a lot. Can we move it into load_archive_data()?

address start = load_archive_data(stub_id);
if (start != nullptr) {
  return start;
}

And have an other specialized load_archive_data if you need end value.

Comment on lines +13107 to +13115
void StubGenerator_AOTAddressTable_init() {
ResourceMark rm;
GrowableArray<address> external_addresses;
// publish static addresses referred to by aarch64 generator
StubGenerator::init_AOTAddressTable(external_addresses);
// publish external data addresses defined in nested aarch64 class
StubRoutines::aarch64::init_AOTAddressTable(external_addresses);
AOTCodeCache::publish_external_addresses(external_addresses);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This and *init_AOTAddressTable() methods should be under #if INCLUDE_CDS


// Non-generated init method

void StubRoutines::init_AOTAddressTable() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this body be in platform specific file.

@vnkozlov
Copy link
Contributor

I noticed that we have to add a lot of local data tables addresses for stubs (math intrinsics).
May be we should consider to have platform specific AOT address tables for such address (and platform specific stubs). To avoid search in one big table.

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

Development

Successfully merging this pull request may close these issues.

2 participants