RFR: 8288971: AArch64: Clean up stack and register handling in interpreter

Andrew Haley aph at openjdk.org
Thu Jun 30 09:13:38 UTC 2022


On Wed, 29 Jun 2022 15:41:27 GMT, Andrew Dinn <adinn at openjdk.org> wrote:

>> There are several places in the interpreter that could be improved.
>> 
>> 1. We use r13 to pass the caller's SP to a callee through adapters. r13 is not a callee-saved register in the native ABI, so this causes some complications. Use a callee-saved register.
>> 2. We frequently recalculate the location where the native SP needs to go. We have a spare slot in the interpreter frame, so we should calculate it once, when the frame is created, and use it.
>> 3. Related to 1, we should clearly label all the places where the caller's SP is passed to a callee.
>
> src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp line 204:
> 
>> 202:     __ ldrd(v0, Address(esp, 2 * Interpreter::stackElementSize));
>> 203:     __ ldrd(v1, Address(esp));
>> 204:     __ mov(sp, r19_sender_sp);
> 
> Ok, finally a real bug! At line 200 we have
> 
>  200     __ mov(r19, lr);   <== this destroys sp in r19_sender_sp
>  201     continuation = r19;
> 
> 
> So, when you switch this from using `r13` to using `r19` here at line 204 you are effectively updating `sp` with `lr`.
> 
> Note this doesn't happen in the previous cases at line 193 because the assignments were done in the opposite order.

Aha!

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

PR: https://git.openjdk.org/jdk/pull/9239


More information about the hotspot-dev mailing list