On Fri, 24 May 2024 14:49:05 GMT, Daniel Jeliński <djelin...@openjdk.org> wrote:

>> Just did the experiment and it turns out that `mov64(r15, 
>> (int64_t)small_jump_table)` and `lea(r15, 
>> ExternalAddress(small_jump_table))` produce exactly the same code:
>> 
>> `0x00007fffe463d68b:  49 bf a0 d5 63 e4 ff 7f 00 00   movabs 
>> r15,0x7fffe463d5a0`
>> 
>> The code in `MacroAssembler` for `lea` calls `mov_literal64` with no check 
>> for whether it can be ip-relative.
>> 
>> I tried doing it myself via `leaq(r15, Address(rip, 
>> (int64_t)small_jump_table - (int64_t)(__ pc())))` but there is no definition 
>> in `register_x86.hpp` for register `rip`.  So I'm not sure exactly how to 
>> produce RIP-relative addressing.
>
> Thanks for checking. Well I know that the `MacroAssembler::movdqu(XMMRegister 
> dst, AddressLiteral src, Register rscratch)` method actually generates 
> rip-relative addresses. Maybe we could copy some of that code.

Use `lea` and `InternalAddress()` for referencing jump tables since the 
addresses are in the same code section.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1613648648

Reply via email to