RFR: 8316694: Implement relocation of nmethod within CodeCache [v42]
Chad Rakoczy
duke at openjdk.org
Fri Aug 22 23:35:49 UTC 2025
On Thu, 21 Aug 2025 12:26:25 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:
>> Chad Rakoczy has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 107 commits:
>>
>> - Merge remote-tracking branch 'origin/master' into JDK-8316694-Final
>> - Lock nmethod::relocate behind experimental flag
>> - Use CompiledICLocker instead of CompiledIC_lock
>> - Fix spacing
>> - Update NMethod.java with immutable data changes
>> - Rename method to nm
>> - Add assert before freeing immutable data
>> - Reorder is_relocatable checks
>> - Require caller to hold locks
>> - Revert is_always_within_branch_range changes
>> - ... and 97 more: https://git.openjdk.org/jdk/compare/9593730a...24c35689
>
> src/hotspot/share/prims/whitebox.cpp line 1659:
>
>> 1657: ResourceMark rm(THREAD);
>> 1658: CHECK_JNI_EXCEPTION(env);
>> 1659: nmethod* code = (nmethod*) addr;
>
> Hmm this might corrupt the code heap and cause crashes. The nmethod could have been freed and had something random else allocated across the same memory, and then casted nmethod even though it is some random instructions there now. Can't really do that.
I added a check to verify that the address points to a valid nmethod ([source](https://github.com/chadrako/jdk/blob/3344a72ab00134b796805ec217f155e26a7c843a/src/hotspot/share/prims/whitebox.cpp#L1656-L1678))
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23573#discussion_r2294932547
More information about the hotspot-compiler-dev
mailing list