8344387: RISC-V: C2: Improve encoding of LoadNKlass for compact headers

Reviewed-by: fyang, luhenry
This commit is contained in:
Hamlin Li 2024-11-19 15:59:30 +00:00
parent ded01e4316
commit dc940ec8af
3 changed files with 6 additions and 14 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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);