RFR: 8358690: Some initialization code asks for AOT cache status way too early

Vladimir Kozlov kvn at openjdk.org
Wed Jun 11 23:21:28 UTC 2025


On Wed, 11 Jun 2025 23:08:44 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

> Thanks to @shipilev for catching the issue.
> 
> [JDK-8350209](https://bugs.openjdk.org/browse/JDK-8350209) came with the bootstrapping problem by checking the AOT cache status way too early. Before full AOT cache init sequence runs, these checks would always reply that AOT cache is off. This causes initial stubs to never practically restored/dumped.
> 
> This does not affect JDK 25 because [JDK-8357514](https://github.com/openjdk/jdk/commit/8184ce39a8a732352ee841fed09cae905d27643c) switched off AOT stubs generation.
> 
> We can't resolve bootstrap issue as it is because `initial_stubs_init()` is  called before `universe_init()` where AOT code cache is created.  I looked why it is required (based on comments) that `initial_stubs_init()` be called before `universe_init()`. And I found that we had a special stub during HotSpot development (1997) which was used for Vtable entries population when we run with -Xcomp (or whatever was equivalent back then). We still have reference to it in the comment: [stubRoutines.cpp#L185](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/stubRoutines.cpp#L185).
> 
> We don't have that code anymore. I moved `initial_stubs_init()` after `universe_init()` and `AOTCodeCache::init2()`. I added asserts into some initial stubs to check that they are not NULL when used. I ran from hs-tier1 to hs-tier6 + hs-tier10-rt.
> 
> The only issue I found is that `AOTCodeCache::init_early_stubs()` needs to be call separately after `initial_stubs_init()` instead of from `AOTCodeCache::init2()`. This solved bootstrap issue.
> 
> I also did some cleanup to match `leyden/premain` branch for easy merges.
> 
> Tested hs-tier1-6, hs-tier1-rt, stress, xcomp

src/hotspot/share/cds/metaspaceShared.cpp line 2017:

> 2015:     TrainingData::print_archived_training_data_on(tty);
> 2016: 
> 2017:     AOTCodeCache::print_on(tty);

Move checks inside callee.

src/hotspot/share/code/aotCodeCache.cpp line 2:

> 1: /*
> 2:  * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.

Match leyden/premain

src/hotspot/share/code/aotCodeCache.cpp line 109:

> 107: // Next methods determine which action we do with AOT code depending
> 108: // on phase of AOT process: assembly or production.
> 109: 

This comment and following new AOT functions are added to match leyden/premain branch.

src/hotspot/share/code/aotCodeCache.cpp line 1741:

> 1739: // This is called after initialize() but before init2()
> 1740: // and _cache is not set yet.
> 1741: void AOTCodeCache::print_on(outputStream* st) {

Refactored because it could be called early.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25763#discussion_r2141250902
PR Review Comment: https://git.openjdk.org/jdk/pull/25763#discussion_r2141251200
PR Review Comment: https://git.openjdk.org/jdk/pull/25763#discussion_r2141251871
PR Review Comment: https://git.openjdk.org/jdk/pull/25763#discussion_r2141253105


More information about the hotspot-dev mailing list