On Thu, 16 Apr 2026 23:09:52 GMT, Vladimir Kozlov <[email protected]> wrote:
> Improve startup and warmup time by making optimized native code for an > application instantly available when the HotSpot Java Virtual Machine starts. > Achieve this by compiling application code to native code in a training run, > storing the native code in the [AOT > cache](https://openjdk.org/jeps/483#Description) for use in subsequent > production runs. > > More details in the [JEP](https://openjdk.org/jeps/544). > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). There is one thing we missed updating in leyden premain branch. AOTCache is now using `AOTCompressedPointers::narrowPtr` to encode the offsets. But the AOTCodeCache is still using raw offsets. We need to update `AOTCacheAccess` APIs to use `AOTCompressedPointers::narrowPtr`. I created a patch for that on top of this PR: https://github.com/ashu-mehra/jdk/commit/b7f8bc534964f6f3370a06af595bbd787beed3c4 hmm, I got a crash with my patch. I will debug that some time later. src/hotspot/share/cds/cds_globals.hpp line 178: > 176: "Test failure of adapter linking when loading from AOT > cache.") \ > 177: > \ > 178: product(bool, AOTCodeCPUFeatureCheck, true, DIAGNOSTIC, > \ Is there any use-case for disabling cpu feature check? Otherwise this flag can be removed, as it is not being used anywhere. src/hotspot/share/code/aotCodeCache.cpp line 282: > 280: } > 281: > 282: bool AOTCodeCache::allow_const_field(ciConstant& value) { IMO it seems this API is better suited in `ciEnv`. src/hotspot/share/code/aotCodeCache.cpp line 321: > 319: is_using = is_caching_enabled(); > 320: } > 321: if (ClassInitBarrierMode > 0 && !(is_dumping && AOTCodeCaching)) { Is this required given that `ClassInitBarrierMode` gets set to 0 if `is_dumping_code()` is false in `init2()`? src/hotspot/share/code/aotCodeCache.cpp line 994: > 992: } > 993: > 994: DirectiveSet* directives = > DirectivesStack::getMatchingDirective(method, nullptr); Missing call to `DirectivesStack::release`. There are other places in the code where `DirectivesStack::getMatchingDirective` does not have the corresponding call to `release`. I think it is better to wrap these pair of calls in a stack allocated object so that the `release` call is not missed. I will create a separate RFE for that. src/hotspot/share/code/aotCodeCache.cpp line 1096: > 1094: assert(_load_entries != nullptr, "sanity"); > 1095: { > 1096: uint name_offset = entry->offset() + entry->name_offset(); This block of code is repeated again below: uint name_offset = entry->offset() + entry->name_offset(); const char* name = _load_buffer + name_offset;; uint level = entry->comp_level(); uint comp_id = entry->comp_id(); bool for_preload = entry->for_preload(); bool clinit_brs = entry->has_clinit_barriers(); I think it is worth moving it out of `ifdef ASSERT` so that it doesn't have to be repeated. src/hotspot/share/code/aotCodeCache.cpp line 1143: > 1141: // We can still use normal AOT code if preload code is > 1142: // invalidated - normal AOT code has less restrictions. > 1143: Method* method = entry->method(); This is unused. src/hotspot/share/code/aotCodeCache.cpp line 3719: > 3717: if (UseG1GC) { > 3718: G1BarrierSetC1* bs = > (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1(); > 3719: > ADD_EXTERNAL_ADDRESS(bs->pre_barrier_c1_runtime_code_blob()->code_begin()); `set_c1_stubs_complete` and `set_c2_stubs_complete` can happen concurrently. Right now it is not a concern because c2 is not adding any external address. But it it also adds any external address, then there could be race in adding the address to `_extrs_addr` array and the `_hash_table`. src/hotspot/share/code/aotCodeCache.cpp line 4020: > 4018: #undef _extrs_max > 4019: #undef _stubs_max > 4020: #undef _shared_blobs_max `_shared_blobs_max`, `_C1_blobs_max`, `_C2_blobs_max`, `_blobs_max`, `_shared_blobs_base`, `_C1_blobs_base`, `_C2_blobs_base`, `_blobs_end` are not defined. These undef-s can be removed. src/hotspot/share/code/aotCodeCache.cpp line 4322: > 4320: struct AOTCodeStats { > 4321: private: > 4322: struct RTStats { I think we can get rid of this inner structures in `AOTCodeStats` and `AOTCodeEntryStats`. In premain I was using `AOTCodeStats` is a common interface for both these stats so I introduced two different inner structs. But now that there are two different interfaces, I think we don't need the inner struts. src/hotspot/share/code/aotCodeCache.hpp line 109: > 107: uint _name_size; > 108: uint _code_offset; // Start of code in cache > 109: uint _code_size; // Total size of all code sections this is unused; can be removed. src/hotspot/share/code/aotCodeCache.hpp line 447: > 445: #define AOTCODECACHE_DECLARE_FUN(type, name, func) type _saved_ ## name; > 446: > 447: struct AOTCodeSection { This struct is also not used anywhere; can be removed. ------------- PR Comment: https://git.openjdk.org/jdk/pull/30778#issuecomment-4271285624 PR Comment: https://git.openjdk.org/jdk/pull/30778#issuecomment-4271444327 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140428357 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140430079 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140430354 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140445912 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140447418 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140447878 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140450681 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140451364 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140451939 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140453049 PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r3140453839
