RFR: 8316694: Implement relocation of nmethod within CodeCache [v18]
Chad Rakoczy
duke at openjdk.org
Wed May 28 20:45:58 UTC 2025
On Wed, 28 May 2025 20:41:43 GMT, Chad Rakoczy <duke at openjdk.org> wrote:
>> If a trampoline is null, it is a critical situation. The patched call instruction will be incorrect.
>> `NativeCall::set_destination` does not check whether a destination is reachable:
>> ```c++
>> void set_destination(address dest) {
>> int offset = dest - instruction_address();
>> unsigned int insn = 0b100101 << 26;
>> assert((offset & 3) == 0, "should be");
>> offset >>= 2;
>> offset &= (1 << 26) - 1; // mask off insn part
>> insn |= offset;
>> set_int_at(displacement_offset, insn);
>> }
>>
>>
>> So higher bits will be masked out.
>
>> The patched call instruction will be incorrect.
>
> That's not entirely correct. The null trampoline check is needed because on debug builds branches of distance >2M will fall into the `if (!Assembler::reachable_from_branch_at(addr(), x))` block but Graal would not have generated a trampoline for that call because it is still <128M. It is still safe to use that distance but it is just different than what HotSpot expects
If we want to guarantee that a trampoline exists if `Assembler::reachable_from_branch_at` fails we would need to update Graal to use the check as well
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23573#discussion_r2112717962
More information about the hotspot-compiler-dev
mailing list