From dc940ec8afcd3cd12ed3785d547f4cd602f65c15 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Tue, 19 Nov 2024 15:59:30 +0000 Subject: [PATCH] 8344387: RISC-V: C2: Improve encoding of LoadNKlass for compact headers Reviewed-by: fyang, luhenry --- src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp | 10 ---------- src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp | 2 -- src/hotspot/cpu/riscv/riscv.ad | 8 ++++++-- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 7b0316e208f..bf553b35770 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -3124,13 +3124,3 @@ void C2_MacroAssembler::extract_fp_v(FloatRegister dst, VectorRegister src, Basi vfmv_f_s(dst, tmp); } } - -void C2_MacroAssembler::load_narrow_klass_compact_c2(Register dst, Address src) { - // The incoming address is pointing into obj-start + klass_offset_in_bytes. We need to extract - // obj-start, so that we can load from the object's mark-word instead. Usually the address - // comes as obj-start in obj and klass_offset_in_bytes in disp. - assert(UseCompactObjectHeaders, "must"); - int offset = oopDesc::mark_offset_in_bytes() - oopDesc::klass_offset_in_bytes(); - ld(dst, Address(src.base(), src.offset() + offset)); - srli(dst, dst, markWord::klass_shift); -} diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp index 8f9d9cd2ccd..8736294e72c 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp @@ -281,6 +281,4 @@ void extract_v(Register dst, VectorRegister src, BasicType bt, int idx, VectorRegister tmp); void extract_fp_v(FloatRegister dst, VectorRegister src, BasicType bt, int idx, VectorRegister tmp); - void load_narrow_klass_compact_c2(Register dst, Address src); - #endif // CPU_RISCV_C2_MACROASSEMBLER_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index b944cc5b4b9..ae8565e1bcf 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -4814,10 +4814,14 @@ instruct loadNKlassCompactHeaders(iRegNNoSp dst, memory mem) match(Set dst (LoadNKlass mem)); ins_cost(LOAD_COST); - format %{ "load_narrow_klass_compact $dst, $mem\t# compressed class ptr, #@loadNKlassCompactHeaders" %} + format %{ + "lwu $dst, $mem\t# compressed klass ptr, shifted\n\t" + "srli $dst, $dst, markWord::klass_shift_at_offset" + %} ins_encode %{ - __ load_narrow_klass_compact_c2(as_Register($dst$$reg), Address(as_Register($mem$$base), $mem$$disp)); + __ lwu(as_Register($dst$$reg), Address(as_Register($mem$$base), $mem$$disp)); + __ srli(as_Register($dst$$reg), as_Register($dst$$reg), (unsigned) markWord::klass_shift_at_offset); %} ins_pipe(iload_reg_mem);