RFR: Use method offset as the hash for storing nmethods
Ashutosh Mehra
asmehra at openjdk.org
Thu Aug 14 13:53:35 UTC 2025
On Thu, 14 Aug 2025 00:37:35 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:
>> Currently AOTCodeEntry for nmethod uses a hash obtained from the method holder's name, method name and signature. This is not very reliable. With https://github.com/openjdk/leyden/pull/90, AOTCodeEntry is always linked to its corresponding Method, so we should be able to use the Method pointer as the hash for AOTCodeEntries for nmethod. However, the problem with pointers are not stable across runs. So instead of the pointer, we can use the offset of the Method in AOTCache. This should work because the Method is guaranteed to be in AOTCache.
>> This PR updates the code to use Method offset as the hash for AOTCodeEntries for nmethods.
>
> src/hotspot/share/code/aotCodeCache.cpp line 929:
>
>> 927: ResourceMark rm;
>> 928: const char* target_name = method->name_and_sig_as_C_string();
>> 929: uint hash = (uint)pointer_delta((address)method(), (address)SharedBaseAddress, 1);
>
> Can you add AOTCacheAccess method for calculating delta during product run? It should be together with other AOTCacheAccess methods we use here.
ok, I will add an api in AOTCacheAccess.
-------------
PR Review Comment: https://git.openjdk.org/leyden/pull/91#discussion_r2276702067
More information about the leyden-dev
mailing list