RFR: 8316694: Implement relocation of nmethod within CodeCache [v32]
Evgeny Astigeevich
eastigeevich at openjdk.org
Tue Jul 1 10:19:57 UTC 2025
On Tue, 1 Jul 2025 09:49:08 GMT, Evgeny Astigeevich <eastigeevich 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 90 commits:
>>
>> - Merge remote-tracking branch 'origin/master' into JDK-8316694-Final
>> - Update how call sites are fixed
>> - Merge remote-tracking branch 'origin/master' into JDK-8316694-Final
>> - Fix pointer printing
>> - Use set_destination_mt_safe
>> - Print address as pointer
>> - Use new _metadata_size instead of _jvmci_data_size
>> - Merge remote-tracking branch 'origin/master' into JDK-8316694-Final
>> - Only check branch distance for aarch64 and riscv
>> - Move far branch fix to fix_relocation_after_move
>> - ... and 80 more: https://git.openjdk.org/jdk/compare/f799cf18...70e4164e
>
> src/hotspot/share/code/nmethod.cpp line 1547:
>
>> 1545: CodeBuffer dst(nm_copy);
>> 1546: while (iter.next()) {
>> 1547: iter.reloc()->fix_relocation_after_move(&src, &dst, true);
>
> What if, instead of a bool parameter we introduce a function `fix_relocation_after_copy`:
> ```c++
> virtual void Relocation::fix_relocation_after_copy(const CodeBuffer* src, CodeBuffer* dest) {
> fix_relocation_after_move(src, dest);
> }
>
> void CallRelocation::fix_relocation_after_copy(const CodeBuffer* src, CodeBuffer* dest) {
> address orig_addr = old_addr_for(addr(), src, dest);
> address callee = pd_call_destination(orig_addr);
>
> if (src->contains(callee)) {
> // If the original call is to an address in the src CodeBuffer (such as a stub call)
> // the updated call should be to the corresponding address in dest CodeBuffer
> ptrdiff_t offset = callee - orig_addr;
> callee = addr() + offset;
> }
>
> pd_set_call_destination(callee);
> }
>
>
> With this change we don't need to modify `relocInfo_*.cpp` files.
IMO, we might consider moving `pd_set_call_destination` to `CallRelocation` because only CallRelocation uses it.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23573#discussion_r2177119955
More information about the hotspot-compiler-dev
mailing list