JDK-8358690 : Some initialization code asks for AOT cache status way too early
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 25
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-06-05
  • Updated: 2025-07-11
  • Resolved: 2025-06-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26 b03Fixed
Related Reports
Causes :  
Causes :  
Relates :  
Relates :  
Description
When chasing down a performance regression in Leyden/premain, I realized that 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. In mainline, I suspect this causes initial stubs to never practically restored/dumped. We picked up that problem in Leyden/premain as well, where it manifests as C1/C2 preloading threads not starting at all (JDK-8358693).

Here is the excerpt of our current init code:

jint init_globals() {
  ...
  // premain asks AOTCodeCache::is_code_load_thread_on() to decide whether to start AOT load threads
  compilationPolicy_init();  
  ...
  // Initial stubs get restored/dumped here, consulting AOTCache::open_for_use()/open_for_dump()
  SharedRuntime::generate_initial_stubs();
  ...
  // AOTCache::initialize runs here
  jint status = universe_init(); 
  ...
 
  // cache is published here after JDK-8357175.
  // From this moment on, the AOT cache status checks are trustworthy
  AOTCodeCache::init2();     

Apply the attached patch, and observe it fail even during the build. There might be more cases, but I was not able to run full test suite, given how it fails during the build.
Comments
I prefer to not backport this into JDK 25. This affect only AOT stubs caching which is hard coded off in JDK 25 (and still off in JDK 26). If I backport this I will have to backport fix (which is not ready yet) for Arn32 JDK-8361380 too.
11-07-2025

Since JDK-8357175 is in 25, this should go there as well?
11-07-2025

Changeset: 6e390ef1 Branch: master Author: Vladimir Kozlov <kvn@openjdk.org> Date: 2025-06-16 15:55:51 +0000 URL: https://git.openjdk.org/jdk/commit/6e390ef17cf4b6134d5d53ba4e3ae8281fedb3f3
16-06-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/25763 Date: 2025-06-11 23:08:44 +0000
11-06-2025

There was time (1997) during HotSpot development when we generated special stub when we run with -Xcomp (or whatever was equivalent back then) which was used for Vtable entries population: void vtableEntry::initialize(methodOop m) { method = m; if (RecompilationPolicy::mustBeCompiled(m)) { entry_point = StubRoutines::handle_must_compile_first_entry(); } else { LookupKey key(m->method_holder(), m->name(), m->signature()); LookupTarget target = LookupCache::lookup_target(&key); entry_point = target.verified_entry_point(); } } We still have reference to it in the comment: https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/stubRoutines.cpp#L185 I think we can move initial stubs generation after universe_init and AOTCodeCache::init2().
10-06-2025

[~thartmann] This affects only stubs AFAIK. Adapters should be fine but I will verify. Stubs are switched off in JDK 25 and I don't plan to switch them on there. My plan is to fix it only JDK 26. But it depend on adapters. I will add more info after I check them.
10-06-2025

ILW = Initial stubs not AOT'ed, with AOT, no known workaround = MLH = P4 [~kvn] Feel free to adjust priority if you think a P3 is justified here. I'm deferring this to JDK 26 for now.
10-06-2025

I will look.
05-06-2025

Vladimir, since you have handled both JDK-8350209 and JDK-8357175, assigning this to you :)
05-06-2025