RFR: 8316694: Implement relocation of nmethod within CodeCache [v18]

Evgeny Astigeevich eastigeevich at openjdk.org
Wed May 28 20:38:03 UTC 2025


On Wed, 28 May 2025 16:46:31 GMT, Chad Rakoczy <duke at openjdk.org> wrote:

>> src/hotspot/cpu/aarch64/relocInfo_aarch64.cpp line 90:
>> 
>>> 88:       }
>>> 89:     }
>>> 90:     call->set_destination(x);
>> 
>> The new code does not update trampoline with `x`. Also you need to handle properly the case of `trampoline` being null. IMO it should never be null. So `if` is not needed. I'd use `guarantee` here.
>
> The trampoline should never been null when compiled with C1/C2. However when running on a debug build  `Assembler::reachable_from_branch_at` uses 2M (on aarch64) for the branch range where as Graal always uses the max of 128M regardless of release/debug. In that case it is possible for `trampoline` to be null.

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.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23573#discussion_r2112706525


More information about the hotspot-compiler-dev mailing list