RFR: 8316694: Implement relocation of nmethod within CodeCache [v46]
Vladimir Kozlov
kvn at openjdk.org
Sat Aug 30 00:29:55 UTC 2025
On Fri, 29 Aug 2025 17:18:20 GMT, Chad Rakoczy <duke at openjdk.org> wrote:
>> This PR introduces a new function to replace nmethods, addressing [JDK-8316694](https://bugs.openjdk.org/browse/JDK-8316694). It enables the creation of new nmethods from existing ones, allowing method relocation in the code heap and supporting [JDK-8328186](https://bugs.openjdk.org/browse/JDK-8328186).
>>
>> When an nmethod is replaced, a deep copy is performed. The corresponding Java method is updated to reference the new nmethod, while the old one is marked as unused. The garbage collector handles final cleanup and deallocation.
>>
>> This does not modify existing code paths and therefore does not benefit much from existing tests. New tests were created to test the new functionality
>>
>> Additional Testing:
>> - [x] Linux x64 fastdebug tier 1/2/3/4
>> - [x] Linux aarch64 fastdebug tier 1/2/3/4
>
> Chad Rakoczy has updated the pull request incrementally with one additional commit since the last revision:
>
> Fix NMethodRelocationTest.java logging race
compiler/codecache/stress/UnexpectedDeoptimizationAllTest.java test failed on AMD EPIC (avx512):
# Internal Error (/workspace/open/src/hotspot/share/code/compiledIC.cpp:167), pid=1984031, tid=1984059
# assert(CompiledICLocker::is_safe(_method)) failed: mt unsafe call
#
# JRE version: Java(TM) SE Runtime Environment (26.0) (fastdebug build 26-internal-2025-08-29-2249418.vladimir.kozlov.jdkgit2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 26-internal-2025-08-29-2249418.vladimir.kozlov.jdkgit2, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xb98a10] CompiledIC_at(RelocIterator*)+0x130
#
Current thread (0x00007efe842b27d0): JavaThread "C2 CompilerThread2" daemon [_thread_in_vm, id=1984059, stack(0x00007efec428f000,0x00007efec438f000) (1024K)]
Current CompileTask:
C2:4006 6467 % ! 4 compiler.codecache.stress.Helper::callMethod @ 4 (64 bytes)
Stack: [0x00007efec428f000,0x00007efec438f000], sp=0x00007efec438a7a0, free space=1005k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0xb98a10] CompiledIC_at(RelocIterator*)+0x130 (compiledIC.cpp:167)
V [libjvm.so+0x173e00e] nmethod::metadata_do(MetadataClosure*)+0x21e (nmethod.cpp:2606)
V [libjvm.so+0x1742e94] nmethod::verify()+0x1d4 (nmethod.cpp:3289)
V [libjvm.so+0x1748646] nmethod::new_nmethod(methodHandle const&, int, int, CodeOffsets*, int, DebugInformationRecorder*, Dependencies*, CodeBuffer*, int, OopMapSet*, ExceptionHandlerTable*, ImplicitExceptionTable*, AbstractCompiler*, CompLevel, char*, int, JVMCINMethodData*)+0x366 (nmethod.cpp:1223)
V [libjvm.so+0xa31d5d] ciEnv::register_method(ciMethod*, int, CodeOffsets*, int, CodeBuffer*, int, OopMapSet*, ExceptionHandlerTable*, ImplicitExceptionTable*, AbstractCompiler*, bool, bool, bool, bool, int)+0x35d (ciEnv.cpp:1062)
V [libjvm.so+0x17fb40d] PhaseOutput::install_code(ciMethod*, int, AbstractCompiler*, bool, bool)+0x16d (output.cpp:3444)
V [libjvm.so+0xb7a918] Compile::Code_Gen()+0xa88 (compile.cpp:3125)
V [libjvm.so+0xb7fb7f] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x208f (compile.cpp:892)
V [libjvm.so+0x9a2176] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x466 (c2compiler.cpp:147)
V [libjvm.so+0xb8ef68] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xb48 (compileBroker.cpp:2340)
V [libjvm.so+0xb90180] CompileBroker::compiler_thread_loop()+0x5c0 (compileBroker.cpp:1984)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23573#issuecomment-3238759038
More information about the hotspot-compiler-dev
mailing list