Skip to content

8380476: Implement JEP: Ahead-of-Time Code Compilation#30778

Draft
vnkozlov wants to merge 46 commits into
openjdk:masterfrom
vnkozlov:8380476
Draft

8380476: Implement JEP: Ahead-of-Time Code Compilation#30778
vnkozlov wants to merge 46 commits into
openjdk:masterfrom
vnkozlov:8380476

Conversation

@vnkozlov

@vnkozlov vnkozlov commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Help applications start up and warm up more quickly by shifting dynamic (JIT) method compilation from production runs to training runs, conveying the necessary native code via the AOT cache.

More details in the JEP.



Progress

  • Change requires CSR request JDK-8380477 to be approved
  • 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)

Issues

  • JDK-8380476: Implement JEP: Ahead-of-Time Code Compilation (Sub-task - P4)
  • JDK-8380477: Implement JEP: Ahead-of-Time Code Compilation (CSR)

Contributors

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30778

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

Using diff file

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

@bridgekeeper

bridgekeeper Bot commented Apr 16, 2026

Copy link
Copy Markdown

👋 Welcome back kvn! 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

openjdk Bot commented Apr 16, 2026

Copy link
Copy Markdown

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

@openjdk

openjdk Bot commented Apr 16, 2026

Copy link
Copy Markdown

@vnkozlov The following labels will be automatically applied to this pull request:

  • build
  • hotspot
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk

openjdk Bot commented Apr 16, 2026

Copy link
Copy Markdown

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.

@vnkozlov

Copy link
Copy Markdown
Contributor Author

/contributor add @rose00
/contributor add @adinn
/contributor add @ashu-mehra
/contributor add @DanHeidinga
/contributor add @iklam
/contributor add @iwanowww
/contributor add @katyapav
/contributor add @shipilev
/contributor add @veresov

@openjdk

openjdk Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vnkozlov
Contributor John R Rose <[email protected]> successfully added.

@openjdk

openjdk Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vnkozlov
Contributor Andrew Dinn <[email protected]> successfully added.

@openjdk

openjdk Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vnkozlov
Contributor Ashutosh Mehra <[email protected]> successfully added.

@openjdk

openjdk Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vnkozlov
Contributor Dan Heidinga <[email protected]> successfully added.

@openjdk

openjdk Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vnkozlov
Contributor Ioi Lam <[email protected]> successfully added.

@openjdk

openjdk Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vnkozlov
Contributor Vladimir Ivanov <[email protected]> successfully added.

@openjdk

openjdk Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vnkozlov
Contributor Ekaterina Pavlova <[email protected]> successfully added.

@openjdk

openjdk Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vnkozlov
Contributor Aleksey Shipilev <[email protected]> successfully added.

@openjdk

openjdk Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vnkozlov
Contributor Igor Veresov <[email protected]> successfully added.

@vnkozlov

Copy link
Copy Markdown
Contributor Author

Why I did not hit this in our internal testing?

assert(_extrs_length <= 380) failed: increase size

@vnkozlov

Copy link
Copy Markdown
Contributor Author

There is also crash on MacOS-x86 with -XX:+UseShenandoahGC during product run.

@shipilev

Copy link
Copy Markdown
Member

I can take a look at Shenandoah parts, if you want. We probably just missing a few C1 stubs for it?

@vnkozlov

Copy link
Copy Markdown
Contributor Author

I can take a look at Shenandoah parts, if you want. We probably just missing a few C1 stubs for it?

Please do. Look on AOTCodeAddressTable::set_c1_stubs_complete() where they are recorded.

@shipilev

Copy link
Copy Markdown
Member

I can take a look at Shenandoah parts, if you want. We probably just missing a few C1 stubs for it?

Please do. Look on AOTCodeAddressTable::set_c1_stubs_complete() where they are recorded.

This fixes the sizes assert:

diff --git a/src/hotspot/share/code/aotCodeCache.cpp b/src/hotspot/share/code/aotCodeCache.cpp
index 4a2c931adaa..b09fe7a68cb 100644
--- a/src/hotspot/share/code/aotCodeCache.cpp
+++ b/src/hotspot/share/code/aotCodeCache.cpp
@@ -3355,7 +3355,7 @@ void AOTCodeReader::read_dbg_strings(DbgStrings& dbg_strings, bool use_string_ta
 //   [_stubs_base, _stubs_base + _stubs_max -1],
 //   [_c_str_base, _c_str_base + _c_str_max -1],
 
-#define _extrs_max 380
+#define _extrs_max 400
 #define _stubs_max static_cast<int>(EntryId::NUM_ENTRYIDS)
 
 #define _extrs_base 0

I think your testing was done without Shenandoah built? I see there is a AOTCodeTest failure on macos-aarch64 too, I am trying to reproduce it locally.

@vnkozlov

Copy link
Copy Markdown
Contributor Author

From my local X86 testing with Z GC and additional output update:

[0.260s][info ][aot,codecache,init] External addresses 368 recorded and closed
...
[0.304s][debug][aot,codecache,init ] External C1 addresses 4 recorded

Which is very near 380 limit. It is possible we generate more intrinsics/stubs on GHA machines.

@vnkozlov

Copy link
Copy Markdown
Contributor Author

400 could be still small. I will change it to 500

@shipilev

Copy link
Copy Markdown
Member

I see there is a AOTCodeTest failure on macos-aarch64 too, I am trying to reproduce it locally.

Aha, for C1, we "just" miss relocations for the runtime entry points in barriers. So once we call through the AOT-saved method, the barrier addresses are not relocated and we jump to garbage locations. Apply this: shenandoah-aot-1.patch.

There is a failure that looks similar in C2, although I am not sure what's wrong there yet. Digging...

@openjdk openjdk Bot removed the merge-conflict Pull request has merge conflict with target branch label May 10, 2026
@vnkozlov

Copy link
Copy Markdown
Contributor Author

If you could merge from master, I can kick off another code analyzer run.

Merged

Comment thread src/hotspot/share/cds/cds_globals.hpp Outdated
Comment on lines +180 to +181
product(bool, SkipArchiveHeapVerification, false, DIAGNOSTIC, \
"Skip verification of CDS archive heap") \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this change necessary for AOT code?

@vnkozlov vnkozlov May 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No. I missed to remove it from my patch. I will remove it.

@openjdk openjdk Bot added the merge-conflict Pull request has merge conflict with target branch label May 22, 2026
@openjdk openjdk Bot removed the merge-conflict Pull request has merge conflict with target branch label May 27, 2026
@vnkozlov

Copy link
Copy Markdown
Contributor Author

@shipilev please look on GHA failure in runtime/cds/appcds/aotCode/AOTCodeTest.java#shenandoah test after merge from mainline.

@shipilev

shipilev commented May 28, 2026

Copy link
Copy Markdown
Member

@shipilev please look on GHA failure in runtime/cds/appcds/aotCode/AOTCodeTest.java#shenandoah test after merge from mainline.

I know what this is: https://bugs.openjdk.org/browse/JDK-8385557. Amusingly, we tried to take care of this AOT path in LBE code, so to avoid regressions for your PR here. And we apparently did things right with AOT constants for cset-base/region-shift, but missed the relocations for slow calls! Which is a problem if runtime calls relocate (ASLR?). So LBE passed with AOT code cache PR on Linux x86/AArch64 without problems, and only Mac AArch64 caught fire. Argh. I am going to amend this code in mainline.

@Delawen

Delawen commented Jun 9, 2026

Copy link
Copy Markdown
Member

Adding some logging for the map files: vnkozlov#1

Delawen added a commit to Delawen/leyden-analyzer that referenced this pull request Jun 15, 2026
8380476: Implement JEP: Ahead-of-Time Code Compilation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

7 participants