RFR: 8308984: Relativize last_sp (and top_frame_sp) in interpreter frames
Martin Doerr
mdoerr at openjdk.org
Mon Aug 7 14:51:32 UTC 2023
On Mon, 19 Jun 2023 15:59:15 GMT, Fredrik Bredberg <fbredberg 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);
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14545#issuecomment-1668012425
More information about the hotspot-dev
mailing list