RFR: Use method offset nmethods hash
Vladimir Kozlov
kvn at openjdk.org
Thu Aug 14 00:40:26 UTC 2025
On Wed, 13 Aug 2025 22:20:37 GMT, Ashutosh Mehra <asmehra 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.
src/hotspot/share/code/aotCodeCache.cpp line 934:
> 932: log_info(aot, codecache, nmethod)("Missing entry for '%s' (comp_level %d, hash: " UINT32_FORMAT_X_0 ")", target_name, (uint)comp_level, hash);
> 933: #ifdef ASSERT
> 934: } else if (method() != entry->method()) {
As you said we can't use pointers (base could be different).
I suggest to keep original code here.
-------------
PR Review Comment: https://git.openjdk.org/leyden/pull/91#discussion_r2274930796
PR Review Comment: https://git.openjdk.org/leyden/pull/91#discussion_r2274906010
More information about the leyden-dev
mailing list