RFR: 8308984: Relativize last_sp (and top_frame_sp) in interpreter frames
Fredrik Bredberg
fbredberg at openjdk.org
Thu Aug 10 10:25:37 UTC 2023
On Mon, 7 Aug 2023 14:48:48 GMT, Martin Doerr <mdoerr at openjdk.org> wrote:
>> Implementation of relativized last_sp (top_frame_sp on PowerPC) in interpreter frames for x64, aarch64, ppc64le and riscv.
>> Not relativized last_sp on arm, zero and s390 but done some changes to cope with the changed generic code.
>>
>> By changing the "last_sp" member in interpreter frames from being an absolute address into an offset that is relative to the frame pointer, we don't need to change the value as we freeze and thaw frames of virtual threads. This is since we might freeze and thaw from and to different worker threads, so the absolute address to locals might change, but the offset from the frame pointer will be constant.
>>
>> This subtask only handles "last_sp" (and its close equivalent "top_frame_sp" on PowerPC). The relativization of other interpreter frame members are handled in other subtasks to JDK-8289296.
>>
>> Tested tier1-tier7 on supported platforms. The rest was sanity tested using Qemu.
>
> I'd use `Rtemp2`. Note that one of the computations can be simplified:
>
>
> diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp
> index 00722171058..721a1467ed8 100644
> --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp
> +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp
> @@ -1994,10 +1994,10 @@ void InterpreterMacroAssembler::add_monitor_to_stack(bool stack_is_empty, Regist
> "size of a monitor must respect alignment of SP");
>
> resize_frame(-monitor_size, /*temp*/esp); // Allocate space for new monitor
> - sub(R11_scratch1, R1_SP, esp); // esp contains fp
> - sradi(R11_scratch1, R11_scratch1, Interpreter::logStackElementSize);
> + subf(Rtemp2, esp, R1_SP); // esp contains fp
> + sradi(Rtemp2, Rtemp2, Interpreter::logStackElementSize);
> // Store relativized top_frame_sp
> - std(R11_scratch1, _ijava_state_neg(top_frame_sp), esp); // esp contains fp
> + std(Rtemp2, _ijava_state_neg(top_frame_sp), esp); // esp contains fp
>
> // Shuffle expression stack down. Recall that stack_base points
> // just above the new expression stack bottom. Old_tos and new_tos
> diff --git a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
> index 7df95d5672e..e3a8b3fbd94 100644
> --- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
> +++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
> @@ -1061,9 +1061,8 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist
> __ std(R0, _ijava_state_neg(oop_tmp), R1_SP); // only used for native_call
>
> // Store sender's SP and this frame's top SP.
> - __ subf(R12_scratch2, Rtop_frame_size, R1_SP);
> __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP);
> - __ sub(R12_scratch2, R12_scratch2, R1_SP);
> + __ neg(R12_scratch2, Rtop_frame_size);
> __ sradi(R12_scratch2, R12_scratch2, Interpreter::logStackElementSize);
> // Store relativized top_frame_sp
> __ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP);
>
>
> Testing: tier1 and TestOptionsWithRangesDynamic.java have passed.
Yea Rtemp2 seems to work fine @TheRealMDoerr. Since Rtemp1 is used as an in-parameter (esp) and therefore not usable for me, I thought that Rtemp2 was also an in-parameter and not usable for me (the declaration of slot is very similar to esp). But after your comment I realized that Rtemp2 is not an in-parameter, so it's usable for me as a temp register. Also thankyou for drawing my attention to the fact that one of the computations could be simplified.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14545#issuecomment-1672926063
More information about the hotspot-dev
mailing list