RFR: Restore Method pointer for every AOTCodeEntry
Vladimir Kozlov
kvn at openjdk.org
Thu Aug 7 23:33:33 UTC 2025
On Thu, 7 Aug 2025 18:16:55 GMT, Ashutosh Mehra <asmehra at openjdk.org> wrote:
> There was a recent commit [0] that included code to invalidate preload entry when invalidating a normal `AOTCodeEntry`. This is done by reaching out to the preload entry through the normal `AOTCodeEntry::_method`:
>
> https://github.com/openjdk/leyden/blob/7b7648a4c9f67be509c6fccbcbc0502648388fdc/src/hotspot/share/code/aotCodeCache.cpp#L1056-L1070
>
> But unfortunately `AOTCodeEntry::_method` is restored only for the entries marked for preload:
> https://github.com/openjdk/leyden/blob/7b7648a4c9f67be509c6fccbcbc0502648388fdc/src/hotspot/share/code/aotCodeCache.cpp#L1938-L1939
>
> This PR fixes this bug by restoring `AOTCodeEntry::_method` for all AOTCodeEntry-s. This is achieved by using AOTCache's pointer bitmap to track `AOTCodeEntry::_method`. It removes the need to store method offset separately in the AOTCodeEntry.
> It also fixes a couple of related bugs:
> 1. In `AOTCodeCache::finish_write()` it is possible that the AOTCodeEntry array is not properly aligned.
> 2. When invalidating a preload entry, it is possible that the entry has not been loaded. This triggers the assert that expects an entry to be invalidated is always loaded.
>
> [0] https://github.com/openjdk/leyden/commit/392fbbb1859cd71521cb915b601a65cf59ba495b
I hit assert running `runtime/cds/appcds/applications/SpringPetClinic.java#aot`:
# Internal Error (/workspace/open/src/hotspot/share/code/aotCodeCache.hpp:714), pid=2727937, tid=2727940
# assert(kind >= AOTCodeEntry::None && kind < AOTCodeEntry::Kind_count) failed: Invalid AOTCodeEntry kind 8
Command Line: -XX:MaxRAMPercentage=4.16667 -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=0 -Xlog:cds -XX:NativeMemoryTracking=detail -Xlog:init,cds -DautoQuit=true -Dspring.output.ansi.enabled=NEVER -Dspring.aot.enabled=true -Dserver.port=0 --enable-native-access=ALL-UNNAMED -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -XX:+UnlockDiagnosticVMOptions -XX:VerifyArchivedFields=2 -Xlog:arguments,aot,cds:file=SpringPetClinic.production.log::filesize=0 -XX:AOTMode=on -XX:AOTCache=SpringPetClinic.aot org.springframework.samples.petclinic.PetClinicApplication
Native frames: (J=compiled Java code, A=AOT compiled, P=AOT preloaded, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x69fd4b] AOTCodeStats::check_kind(unsigned int) [clone .part.0]+0x2b (aotCodeCache.hpp:714)
V [libjvm.so+0x6c14ae] AOTCodeCache::print_statistics_on(outputStream*)+0x18be (aotCodeCache.cpp:3959)
V [libjvm.so+0x10d24a9] log_vm_init_stats()+0x319 (java.cpp:215)
V [libjvm.so+0x1bcc64f] Threads::create_vm(JavaVMInitArgs*, bool*)+0x105f (threads.cpp:945)
V [libjvm.so+0x12320d4] JNI_CreateJavaVM+0x54 (jni.cpp:3587)
You missed alignment in next line:
AOTCodeEntry* load_entries = (AOTCodeEntry*)(search_entries + 2 * count);
-------------
PR Comment: https://git.openjdk.org/leyden/pull/90#issuecomment-3166125558
More information about the leyden-dev
mailing list