RFR: 8364929: Assign unique id to each AdapterBlob stored in AOTCodeCache [v4]

Ioi Lam iklam at openjdk.org
Thu Oct 2 19:00:57 UTC 2025


On Thu, 2 Oct 2025 18:52:10 GMT, Ashutosh Mehra <asmehra at openjdk.org> wrote:

>> This patch assigns unique id to each AdapterHandlerEntry so as to avoid using hash computed from AdapterFingerPrint which may not be unique. Unique id allows AOTCodeCache to locate the AdapterBlob being requested to be loaded.
>> 
>> Testing:
>> Before this patch `runtime/cds/appcds/aotClassLinking/StringConcatStress.java` emits warning messages in the production run:
>> 
>> [0.009s][warning][aot,codecache,stubs] Saved blob's name 'LIIDIIIDL' is different from the expected name 'LIIDIIDL'
>> [0.009s][warning][aot                ] Failed to link AdapterHandlerEntry (fp=LIIDIIDL) to its code in the AOT code cache
>> [0.009s][warning][aot,codecache,stubs] Saved blob's name 'IILLLLIIIIII' is different from the expected name 'IILLLLLILIII'
>> [0.009s][warning][aot                ] Failed to link AdapterHandlerEntry (fp=IILLLLLILIII) to its code in the AOT code cache
>> 
>> With this patch, such warnings are not seen at all
>
> Ashutosh Mehra has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Replace overflow check if guarantee statement
>   
>   Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>

Looks good. Just a couple of nits.

src/hotspot/share/runtime/sharedRuntime.cpp line 2605:

> 2603: AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint) {
> 2604:   uint id = (uint)AtomicAccess::add((int*)&_id_counter, 1);
> 2605:   guarantee(id > 0, "id_counter overflow");

I think we can even change this to an assert. We limit the AOT metaspace size to `UnscaledClassSpaceMax` which is 4GB. 

https://github.com/openjdk/jdk/blob/1d55adee11fc2fdbf2e009e1308b763fd7217dad/src/hotspot/share/cds/aotMetaspace.cpp#L304C24-L304C45

All AOT methods would have to live within the AOT metaspace , so we will have much fewer than 2^32 methods, which means will we have much fewer than 2^32 signatures. So the `id` will never overflow. Maybe change this to:


assert(id > 0, "we can never overflow because AOT cache cannot contain more than 2^32 methods");

src/hotspot/share/runtime/sharedRuntime.hpp line 687:

> 685: 
> 686:  private:
> 687:   uint _id;

This can be moved near `_linked` so it can fit in the existing unused padding.

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

PR Review: https://git.openjdk.org/jdk/pull/27553#pullrequestreview-3295998278
PR Review Comment: https://git.openjdk.org/jdk/pull/27553#discussion_r2399787944
PR Review Comment: https://git.openjdk.org/jdk/pull/27553#discussion_r2399795492


More information about the hotspot-dev mailing list